﻿// 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 $(id){
	return document.getElementById(id);	
}

function Search()
{
    var url=$("rootpath").value+"product.html";
    var keywords =$('skey').value;
    var cid = $('category').value;
     if(keywords!='') url+='?keywords=' + escape(keywords);
    if(cid!='')    
    {
    if(keywords!='')
    {
    url+='&cid=' + cid;
    }else
    {
    url+='?cid=' + cid;
    
    }
    }
    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;
}


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;       　　　　　　　   
    　　　　　　   
 }   
