﻿
 var jQuery=$;
      window.onload = function() {
        var h1 = jQuery("#leftpage").height(); var h2 = jQuery("#rightpage").height();
        if (h2 > h1) { jQuery("#leftpage").height(h2); };      
        }   
// JScript 文件

//图片对象,一般用this
//maxWidth设置图片宽度界限
//maxHeight设置图片高度界限
function SetImgAutoSize(myimg,mywidth,myheight)
{
      var tmp_img = new Image();
tmp_img.src=myimg.src;
image_x=tmp_img.width;
image_y=tmp_img.height;
	if(image_x > mywidth){
	tmp_img.height=image_y * mywidth / image_x;
	tmp_img.width=mywidth;
		if(tmp_img.height>myheight){
			tmp_img.width=tmp_img.width * myheight / tmp_img.height;
			tmp_img.height=myheight;
			}
	}else if(image_y > myheight)
	{
	tmp_img.width=image_x * myheight / image_y;
	tmp_img.height=myheight;
		if(tmp_img.width>mywidth){
			tmp_img.height=tmp_img.height * mywidth / tmp_img.width;
			tmp_img.width=mywidth;
			}
	}
	myimg.width=tmp_img.width;
	myimg.height=tmp_img.height;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function $$(id){
	return document.getElementById(id);	
}

function Search()
{
    var url=$$("rootpath").value+"product.html";
    var keywords = $$('skey').value;
     
    if(keywords!='') url+='?keywords=' + keywords;
    location.href = url;
}

function Inquir()
{
    var url=$$("rootpath").value+'contactnow.html?tosubject=';
    var r='';
    r= getValue();
    if(r=='')
    {
       alert('No item(s) selected.');
       return;    
    }
    else
    {
      url+=r;    
    }
    location.href = url;
}

//Email;
function isEmail(s){
	s = trim(s); 
 	var p = /^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.){1,4}[a-z]{2,3}$/i; 
 	return p.test(s);
}


//去左右空格; 
function trim(s){
 	return rtrim(ltrim(s)); 
}
//去左空格;  
function ltrim(s){
 	return s.replace( /^\s*/, ""); 
} 
//去右空格; 
function rtrim(s){ 
 	return s.replace( /\s*$/, ""); 
}


function   getValue()   
 { 
 　var r='';
 　var   inputs   = document.getElementsByTagName("input");   
   for( var i=0;i<inputs.length;i++)   //   遍历页面上所有的   input     
　 {   
　　　　if   (inputs[i].type   ==   "checkbox"   )   
　　　　{   
　　　　　　if(inputs[i].checked)   
　　　　　　r+=inputs[i].value+" | "

　　　　}             
 　}   
   return r;      　　　　　　　   
    　　　　　   
 }  
 
 var icon = '<img src="images/check_error.gif" border="0" align="absmiddle">';
var icon1 = '<img src="images/check_right.gif" border="0" align="absmiddle">';
function showInfo(n, s) {
    var f = $$(n + "_msg");
    var p = $$(n);
    if (typeof s == 'undefined') {
        f.innerHTML = icon1;
        p.className = "";

    }
    else {
        f.innerHTML = icon + s;

        p.className = "inputwarn";
    }
}

function onChange(i){
childSort=document.getElementById("child" + i);
	if(childSort.style.display=="none"){

		childSort.style.display="";}
	else{

		childSort.style.display="none";}
}
