﻿function thumbimg(obj,size){
    $(obj).each(function(){
        var P;//父元素
        var img = new Image();
        img.src = this.src;
        
        if($(this).parent("a").length > 0)
            P = $(this).parent().parent();
        else
            P = $(this).parent(); 
        //P.css("position","relative");
        P.css("textAlign","center");
        
        if(img.width> size || img.height > size){
            if(img.width > img.height)
                $(this).width(size);
            else
                $(this).height(size);
        }else{
            $(this).width(this.width);
            $(this).height(this.height);
        }
        
        $(this).css({
            "visibility":"visible",
            "background":"none",
            //"position":"absolute",
            //"top":(P.height()-this.height)/2+"px",
            //"left":(P.width()-this.width)/2+"px"
            "marginTop":(P.height()-this.height)/2+"px"
            });
    });
}

//Search function
function searchfn(){
	var strkey = $("#txtKey").val();
	if(strkey == ""){
	    alert("Please Enter!");
	    $("#txtKey").focus();
	}
	else
	    document.location.href='ProductList.aspx?key='+escape(strkey);
}

function submenu(obj){
    $(obj).each(function(){
	  $(this).hover(
		function(){
		  $(this).find('ul:eq(0)').show();
		},
		function(){
		  $(this).find('ul:eq(0)').hide();
		},1);
	});
}
