﻿function openWin(url,name,w,h)
 {
    var x=(window.screen.width-w)/2;
	var y=(window.screen.height-h)/2;
	var win=window.open(url,name,'toolbar=0,location=0,status=0,top='+y+',left='+x+',width='+w+',height='+h );
	win.focus();
	return win;
 }
 function openSuitWin(url,name)
 {
	var sw=window.screen.width;
	var sh=window.screen.height;
	var w=sw-300;
	var h=sh-300;
	var x=(sw-w)/2;
	var y=0;
	var win=window.open(url,name,'toolbar=0,scrollbars=1,location=1,menubar=1,resizable=1,status=1,top='+y+',left='+x+',width='+w+',height='+h );
	win.focus();
 } 
 var last_img_btn_chg_prd=null;
 function ImgBtnChgPrd_Mouseover(obj,mainpictureurl,largepictureurl)
 {
    if(last_img_btn_chg_prd!=null) 
        last_img_btn_chg_prd.className='img_btn_chg_prd';
    last_img_btn_chg_prd=obj;
    obj.className='img_btn_chg_prd_active';
    document.getElementById('img_show_prd').src=mainpictureurl;
	document.getElementById('img_show_prd').onclick=function(){ImgBtnChgPrd_Click(this,largepictureurl);}
	document.getElementById('spn_tobig').onclick=function(){ImgBtnChgPrd_Click(this,largepictureurl);}
 }
 function ImgBtnChgPrd_Click(obj,largepictureurl)
 {
    document.getElementById('hid_largepictureurl').value=largepictureurl;
	var win=openWin('/ProductExp.aspx','preview',700,580);
	win.opener=this;
 }
function suitImage(img,w,h)
{
		var image=new Image();
        image.src=img.src;
		var iw=image.width;
		var ih=image.height;
		var iratio=iw/ih;
        if(iw>w)
		{
		                iw=w;
				ih=w/iratio;
        }
        if(ih>h)
		{
                ih=h;
                iw=h*iratio;
        }  
		img.width=iw;
		img.height=ih;
}
window.onerror=function()
{
	return true;
}
function getposOffset(what, offsettype)
{ 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
} 
function showLocSelect(objid,divId,x_offset,y_offset)
{	
	var locdiv=document.getElementById(divId);
	var obj=document.getElementById(objid);	
    locdiv.style.top=(getposOffset(obj,"top")-y_offset)+"px";
	locdiv.style.left=(getposOffset(obj,"left")-x_offset)+"px";
	locdiv.style.display="block";
}
function hideLocSelect(divId)
{	
	document.getElementById(divId).style.display="none";
}
function ImgBtnChgPrd_Mouseover(img_name,img_path,proid)
{ 
       var img= document.getElementById(img_name);
       var mainimg= document.getElementById("mainImg");       
       mainimg.src=img_path;
       img.style.border="1px blue solid";       
       document.getElementById("hidProductId").value = proid;       
      OutputSereisProductInfo();
          }    
     function ImgBtnChgPrd_Mouseover1(img_name,img_path)
    {
       var img= document.getElementById(img_name);
       var mainimg= document.getElementById("mainImg");       
       mainimg.src=img_path;
       img.style.border="1px blue solid";         
    }    
    function OutputSereisProductInfo()
    {          
          var producttool=  "<iframe id=Iframeproducttool marginWidth='0' marginHeight='1'  src='/Products/ProductTool.aspx?id=" +  document.getElementById("hidProductId").value + "' frameBorder='0' width='100%' height='28' scrolling='no'></iframe>";
           //var recomanditems=  "<iframe id=ifrmExplain marginWidth=0 marginHeight='1'  src='/Products/Interest.aspx?id=" + document.getElementById("hidProductId").value + "' frameBorder='0' width='100%' height='700' scrolling='no'></iframe>";
          document.getElementById("producttool").innerHTML = producttool;  
         // document.getElementById("recomanditems").innerHTML = recomanditems;                    
          LoadProductvisitedCount(document.getElementById("hidProductId").value);
                
         // document.getElementById("productName").innerHTML =  "<iframe id=IframeproductName marginWidth='0' marginHeight='1'  src='/Products/SeriesProductBaseInfo.aspx?id=" +  document.getElementById("hidProductId").value + " frameBorder='0' width='100%' height='28' scrolling='no'></iframe>";
    }
    function LoadProductvisitedCount(id)
    {    
             $.ajax({
              type:"POST",
              url:"/Products/BrowseCount.aspx?id="+ id,
              dataType:"html",
              data:"",
              beforeSend:function()
              {
                 //
              },
              error : function()
              {
                //
              },
              success:function(result)
              {
                 $("#visited" + id).html(result);
              }  
              });    
    }

	function SetCopy()
	{
		if(navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
			clipboardData.setData('Text',location.href);
			alert ("Copy success!");
		}
		else 
		{
			prompt("Please copy the weblink!",location.href); 
		}
	}
    function url()
    {
        var mainimg= document.getElementById("mainImg");
        var urlpath = mainimg.src.replace("Mini/","");
        window.open(urlpath,'black');        
    }
    function showitem(item)
    {    
        var introduce = document.getElementById("Introduce");
        var note = document.getElementById("Note");
        var bill = document.getElementById("Bill");
        var commendword = document.getElementById('CommendWord');
        var imgintroduce = document.getElementById("imgIntroduce");
        var imgnote = document.getElementById("imgNote");
        var imgbill = document.getElementById("imgBill");
        var imgcommendword = document.getElementById('imgCommendWord');
        switch(item)
        {
            case "Introduce":                        
                introduce.style.display = "inline";
                note.style.display = "none";
                bill.style.display = "none";
                commendword.style.display = "none";
                
                imgintroduce.src="images/prodian1.gif";
                imgnote.src="images/prodian2-1.gif";
                imgbill.src="images/prodian3-1.gif";
                imgcommendword.src="images/prodian4-1.gif";                
                break;
            case "Note":                
                introduce.style.display = "none";
                note.style.display = "inline";
                bill.style.display = "none";
                commendword.style.display = "none";
                imgintroduce.src="images/prodian1-1.gif";
                imgnote.src="images/prodian2.GIF";
                imgbill.src="images/prodian3-1.gif";
                imgcommendword.src="images/prodian4-1.gif";          
                break;
            case "Bill":                
                introduce.style.display = "none";
                note.style.display = "none";
                bill.style.display = "inline";
                commendword.style.display = "none";
                imgintroduce.src="images/prodian1-1.gif";
                imgnote.src="images/prodian2-1.gif";
                imgbill.src="images/prodian3.gif";
                imgcommendword.src="images/prodian4-1.gif";          
                break;
            case "CommendWord":                
                introduce.style.display = "none";
                note.style.display = "none";
                bill.style.display = "none";
                commendword.style.display = "inline";
                
                imgintroduce.src="images/prodian1-1.gif";
                imgnote.src="images/prodian2-1.gif";
                imgbill.src="images/prodian3-1.gif";
                imgcommendword.src="images/prodian4.gif";          
                break;
        }
    }
