/**

 * 调节图片的长度和宽度做限制

 * 长度和宽度哪个超出就限制哪个

 * img src="image" onload="adjustImageSize(this,45,160)"

 * @param imageObj  - img 控件

 * @param maxHeight - 图片长度限制

 * @param maxWidth  - 图片宽度限制

 */

function adjustImageSize(imageObj,maxHeight,maxWidth){

  if(maxHeight<imageObj.height){

    imageObj.height=maxHeight;

  }

  if(maxWidth<imageObj.width){

    imageObj.width=maxWidth;

  }

}
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    includedLanguages: 'ar,bg,pl,da,de,ru,fr,fi,ko,nl,cs,hr,ro,no,pt,ja,sv,th,es,el,it'
  }, 'google_translate_element');
}


/**

 * 调节图片的长度和宽度做限制

 * 长度和宽度哪个超出就限制哪个，如果都不超出则原尺寸

 * img src="image" onload="setImgSize(this.src,this,[size])"

 * @param imageObj  - img 控件

 * @sizeStand  - 图片标准高宽

 */



function setImgSize(theURL,sImage){

var imgObj;

var sizeStand = 110;

if(arguments.length>=3){

sizeStand = arguments[2];

}

imgObj = new Image();

imgObj.src = theURL;



if ((imgObj.width != 0) && (imgObj.height != 0)) {

	

	if(imgObj.width>sizeStand || imgObj.height>sizeStand){

		if(imgObj.width > imgObj.height) { 

		var iHeight = imgObj.height*sizeStand/imgObj.width;

		sImage.height = iHeight;

		sImage.width = sizeStand;

		} else {

		var iWidth = imgObj.width*sizeStand/imgObj.height;

		sImage.width = iWidth;

		sImage.height= sizeStand;

		}

	}else{

	sImage.width=imgObj.width;

	sImage.height=imgObj.height;

	}



}else{

sImage.width = sizeStand;

sImage.height= sizeStand;

}

}





/**

 * 调节图片的长度和宽度做限制,自定义高宽

 * 长度和宽度哪个超出就限制哪个，如果都不超出则原尺寸

 * img src="image" onload="setImgSizeWH(this.src,this,sizew,sizeh)"

 * @param theURL  - img 地址

 * @param sImage  - img object

 * @param imgW  - 限制宽度

 * @param imgH  - 限制高度

 */



function setImgSizeWH(theURL,sImage,imgW,imgH){

var imgObj;

imgObj = new Image();

imgObj.src = theURL;

if ((imgObj.width != 0) && (imgObj.height != 0)) {

	if(imgObj.width>imgW || imgObj.height>imgH){

		

		var iHeight = imgObj.height*imgW/imgObj.width;

		

		if(iHeight<=imgH){

			sImage.width=imgW;

			sImage.height=iHeight;

		}else{

		var iWidth=imgObj.width*imgH/imgObj.height;

		sImage.width=iWidth;

		sImage.height=imgH;

		}

	}else{

	sImage.width=imgObj.width;

	sImage.height=imgObj.height;

	}



}else{

sImage.width = imgW;

sImage.height= imgH;

}

}



/**

 * 调节图片的长度和宽度做限制

 * 长度和宽度哪个超出就限制哪个，如果都不超出则原尺寸

 * img src="image" onload="setImgSize(this.src,this,[size])"

 * @param imageObj  - img 控件

 * @sizeStand  - 图片标准高宽

 */



function setBigImgSize(theURL,sImage){

	var imgObj;

	var sizeStand = 250;

	if(arguments.length>=3){

		sizeStand = arguments[2];

	}

	imgObj = new Image();

	imgObj.src = theURL;

	imgObj.onLoad = setBigImgInner(imgObj,sImage,sizeStand);

}



function setBigImgInner(imgObj,sImage,sizeStand){

	if ((imgObj.width != 0) && (imgObj.height != 0)) {

			if(imgObj.width>sizeStand || imgObj.height>sizeStand){

				if(imgObj.width > imgObj.height) { 

		var iHeight = imgObj.height*sizeStand/imgObj.width;

		sImage.height = iHeight;

		sImage.width = sizeStand;

		} else {

		var iWidth = imgObj.width*sizeStand/imgObj.height;

		sImage.width = iWidth;

		sImage.height= sizeStand;

		}

	}else{

	sImage.width=imgObj.width;

	sImage.height=imgObj.height;

	}



}else{

	sImage.width = sizeStand;

	sImage.height= sizeStand;

}

}



function setGsBigImgSize(theURL,sImage){

var imgObj;

var sizeStand = 360;

imgObj = new Image();

imgObj.src = theURL;

imgObj.onLoad = setGsImgInner(imgObj,sImage,sizeStand);

}

		

		

function setGsImgInner(imgObj,sImage,sizeStand){

	if ((imgObj.width != 0) && (imgObj.height != 0)) {

		if(imgObj.width>sizeStand){

			var iHeight = imgObj.height*sizeStand/imgObj.width;

		   	sImage.height = iHeight;

		   	sImage.width = sizeStand;

		 }else{

		 	sImage.width=imgObj.width;

			sImage.height=imgObj.height;

		}

	}else{

			sImage.width = sizeStand;

			sImage.height= sizeStand;

	}

}

function clickcompareBox(id,box) 

{

	if(box.checked)

	{

		var trTag = document.getElementById("compareColor_"+id);

		trTag.style.background="EFEFEF";

	}else

	{

		var trTag = document.getElementById("compareColor_"+id);

		trTag.style.background="ffffff";

	}

}



browserName = navigator.appName;

browserVer = parseInt(navigator.appVersion);

condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ;

if (condition == true  )

    CanAnimate = true;

else

    CanAnimate = false;



function translator(pattern)

{

/////////////////////////////////////////////////////////////

// Script to use language convertor

// By Saradhi

/////////////////////////////////////////////////////////////



	/// Configuration parameters //////////////

	var open_in_same_window = 0;

	//////////// End Of Configuration /////////////



	var my_location = unescape(document.location.toString());

	var new_location ='';

	var new_pattern = '';

	if (my_location.indexOf('translate_c?') != -1) {

		/// From google...

		var indexof_u = my_location.indexOf('u=');

		if (indexof_u == -1) {

			new_location = document.location;

		}

		else {

			var subs = my_location.substring(indexof_u, my_location.length);

			var ss = subs.split('&');

			new_location = ss[0].substring(2, ss[0].length);

		}

	}

	else {

		new_location = document.location;

	}



	indexof_p = pattern.indexOf('|');



	var isen = '';

	if (indexof_p == -1) {

		indexof_p1 = pattern.indexOf('><');

		if (indexof_p1 == -1) {

			new_pattern = pattern;

			if (pattern == 'en') {

				isen = 1;

			}

		}

		else {

			var psplit =pattern.split('><');

			new_pattern = psplit[0]+'|'+psplit[1];

			if (psplit[1] == 'en') {

				isen = 1;

			}

		}

	}

	else {

		var psplit = pattern.split('|');

		new_pattern = psplit[0]+'|'+psplit[1];

		if (psplit[1] == 'en') {

			isen = 1;

		}

	}



	var thisurl = '';

	if (isen == 1) {

		thisurl = new_location;

	}

	else {

		thisurl = 'http://translate.google.com/translate_c?langpair=' + new_pattern + "&u=" + new_location;

	}



	if (open_in_same_window == 1) {

		window.location.href = thisurl;

	}

	else {

		if (CanAnimate ){

			msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');

			msgWindow.focus();

			msgWindow.location.href = thisurl;

		}

		else {

			msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');

		}

	}

}



function translator1(pattern)

{

	var thisurl = 'http://translate.google.com/translate_c?langpair=' + pattern + "&u=" + document.location;

	if (CanAnimate ){

        	msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');

	        msgWindow.focus();

        	msgWindow.location.href = thisurl;

	}

	else {

        	msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');

	}

}



function showDiv(objId,th){

   var objDiv=document.getElementById(objId);   

   if(objDiv.style.display=="none"){

      objDiv.style.display="";

	  th.src="images/ico-left_2.gif";

   }else{

   objDiv.style.display="none";

	th.src="images/ico-left.gif";

   }

}



function _showDiv(objId,th){

   var objDiv=document.getElementById(objId);   

   if(objDiv.style.display=="none"){

      objDiv.style.display="";

	  th.src=templatedir+"images/ico-left_2.gif";

   }else{

   objDiv.style.display="none";

	th.src=templatedir+"images/ico-left.gif";

   }

}