﻿// JScript File
var rules=new Array();
rules[0]=null;

function Page_OnLoad()
{
    document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").select();
}
			
function addtocart(obj1,obj2,obj3)
{
    var Qty = document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").value;
    if(Qty == '')
    {
        alert("Quantity Must be entered")
        document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").select();
        return false;
    }
	else if(Qty != '')
	{
	    if(IsNumeric(Qty))
		{
            if(CheckIsNumber('aspnetForm','Quantity','ctl00_ContentPlaceHolder1_TxtQty')==false)
            {
                document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").focus();
                return false;
            }
        }
        else
        {
            alert("Only Numeric Value Allowed");
            document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").select();
            return false;
        }    
		if(Qty == "0")
		{
		    alert("Zero Quantity Not Valid")
			document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").select();
			return false;
		}
    }
    else
	{
        document.getElementById("ctl00_ContentPlaceHolder1_TxtQty").select();
        return false;
    }
				        
			
    if(encodeURI(obj2)=="Cart")
        document.location.href = "view_cart.aspx?Qty="+Qty+"&type=P&ProdId="+encodeURI(obj1)+"&CatId="+encodeURI(obj3) 
    else if(encodeURI(obj2)=="Whish")
        document.location.href = "wishlist.aspx?Qty="+Qty+"&type=P&ProdId="+encodeURI(obj1)+"&CatId="+encodeURI(obj3)
	        
}
		
		
function IsNumeric(sText)
{
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;
               
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
    return IsNumber;
}

function ShowImage(ImgPath,ImgName,width,height)
{
    window.open("ShowProductImage.aspx?ImgPath="+ImgPath+"&ImgName="+ImgName,"PopUp","top=100,left=200,scrollbars=no,height" + (parseInt(height)+10) + ",width=" + (parseInt(width)+17));
}
			
function aspnetForm_onkeypress(e) 
{
    var browserName=navigator.appName; 
    var unicode;
    if (browserName=="Microsoft Internet Explorer") 
        unicode = window.event.keyCode;     //IE
    else
        unicode = e.which;     //firefox
        
    if (unicode == 13)
    { 
        document.getElementById("ctl00_ContentPlaceHolder1_CartHREF1").click();
        return false;
    }
}
            