﻿function initImg(obj,w,h)
{
	var image=new Image();
	image.src=obj.src;
	var ow = image.width ;
	var oh = image.height ;
	if( ow > w || oh > h)
	{
		var ws = ow / w ;
		var hs = oh / h ;
		if( ws > hs)
		{
			obj.width = w ;
			obj.height = oh / ws;
		}
		else
		{
			obj.width = ow / hs ;
			obj.height = h ;
		}
	}
}
function openWindow(url)
{
    window.open(url,'newwindow','');
}
function checkSearch(form)
{
    if(form.searchKey.value=="")
    {
        alert("please input a search team!");
        return false;
    }
}
function ShowOrHideParam()
{
    objTable=document.getElementById("tblProductParam");
    objUl=document.getElementById("ulsohpp");
    isShow=(objUl.innerHTML=="Show More"?true:false);
    if(objTable.rows.length>7)
    {
        if(isShow)
        {
            for(var i=6;i<objTable.rows.length-1;i++)
            {
                objTable.rows[i].style.display="";
                objUl.innerHTML="Show Less";
            }
        }
        else
        {
            for(var i=6;i<objTable.rows.length-1;i++)
            {
                objTable.rows[i].style.display="none";
                objUl.innerHTML="Show More";
            }
        }
    }
}
function checkDropDownListIsSelect(source,args)
{     
    args.IsValid=!(args.Value==0||args.Value=="");
}
function validateSearchFrom(){
  var search_keyword = document.getElementById("ucHeader_search_keyword"); 
  reWhiteSpace = new RegExp(/^\s+$/);
  search_keyword.value = search_keyword.value.replace(/^\s+|\s+$/g, "") ;   
 if(search_keyword.value==""||search_keyword==null){
    alert("Please enter what you are searching for.");
    search_keyword.focus();
    return false;
  }else if (search_keyword.value.length < 3 ){
    alert("Please enter alteast 3 characters.");
    search_keyword.focus();
    return false;
  }
  window.location="/searchResult.aspx?searchKey="+search_keyword.value;
}

