//Function for Setting the product Full image and Enlarge image
//cast(A.PROPERTY_ID as varchar) + '~' + A.PROPERTY_NAME + '~' + A.PROPERTY_VALUE + '~' + B.PRODUCT_PRICE + '~' + B.PRODUCT_SPECIAL_PRICE
//cast(A.PROPERTY_ID as varchar) + '~' + A.PROPERTY_NAME + '~' + A.PROPERTY_VALUE + '~' + B.PRODUCT_FULL_IMAGE + '~' + B.PRODUCT_ENLARGE_IMAGE
function SetProductColorImagesSingle(varPropertyString)
{
	//alert(varPropertyString);
	var varPropertyArray = varPropertyString.split("~");
	document.getElementById("imgProductImage").src = "Images/FullImage/" + varPropertyArray[3];
	document.getElementById("hdnEnlargeImage").value = "Images/EnlargeImage/" + varPropertyArray[4];
//	document.getElementById("ddlColorOptions").selectedIndex = 0;

	document.getElementById("ddlColorOptions").value = varPropertyString;
//	document.getElementById("ddlColorOptions").selected=true;
}

//Function for Setting the product Full image and Enlarge image
//cast(A.PROPERTY_ID as varchar) + '~' + A.PROPERTY_NAME + '~' + A.PROPERTY_VALUE + '~' + B.PRODUCT_FULL_IMAGE + '~' + B.PRODUCT_ENLARGE_IMAGE
function setProductColorImages()
{
	var varPropertyString = document.getElementById("ddlColorOptions").value;
	var varPropertyArray = varPropertyString.split("~");
	document.getElementById("imgProductImage").src = "Images/FullImage/" + varPropertyArray[3];
	document.getElementById("hdnEnlargeImage").value = "Images/EnlargeImage/" + varPropertyArray[4];
}

//Function for Setting the product Full image and Enlarge image
//cast(A.PROPERTY_ID as varchar) + '~' + A.PROPERTY_NAME + '~' + A.PROPERTY_VALUE + '~' + B.PRODUCT_PRICE + '~' + B.PRODUCT_SPECIAL_PRICE
function setProductSizePrices()
{
	var varSizeString = document.getElementById("ddlSizeOptions").value;
	var varSizeArray = varSizeString.split("~");
	document.getElementById("lblProductPrice").innerHTML = varSizeArray[3];
	document.getElementById("txtProductPrice").value = varSizeArray[3];
	document.getElementById("lblSplProductPrice").innerHTML = varSizeArray[4];
	document.getElementById("txtSplProductPrice").value = varSizeArray[4];
	if(parseFloat(varSizeArray[4]) > 0){
		document.getElementById("lblProductPrice").cssclass = "whitetextStrike";
	}
}

NEW_Image = new Image();
function SetZoomImage()
{
	var lstrImage = "";
	lstrImage = document.getElementById("hdnEnlargeImage").value;
	IMGNameEnlarge = lstrImage.replace("^.^"," ");
	NEW_Image.src = IMGNameEnlarge;
	setTimeout("abc()",1800)
}

function abc()
{
	var LStrProductName;
	var AStrHeight=0
	var AStrWidth=0
	AStrHeight=parseInt(NEW_Image.height)+70
	AStrWidth=parseInt(NEW_Image.width)+30
	newwindow=window.open("","name","width=" + AStrWidth + ", height=" + AStrHeight + ",left=150,top=20");			
	var tmp = newwindow.document;
	tmp.write("<html><head><title>Zoom View</title><body bgcolor=#eef6ff><center>");
	tmp.write('<Table border=0 cellspacing=2 cellpadding=0><tr><td align=center valign=top>');
	tmp.write("<img style=border-width:1px src='" + IMGNameEnlarge + "' alt='Zoom View.' title='Zoom View of " + LStrProductName + ".' border=0>");
	tmp.write('</td></tr>');
	tmp.write('<tr height=12><Td>&nbsp;</Td></tr>');
	tmp.write('<tr><td align=right><a href="javascript:self.close()"><img src=images/inner/close.jpg border=0 alt="Close Window" title="Close Window"></a></td></tr></table>');
	tmp.write('</center></body></html>');
	if (window.focus)
	{
		newwindow.focus()
	}
}

function CheckProductQuantity()
{
	
		var LtdInventory;
		var LtdInventory = document.getElementById("TxtLimitedInventory").value
		if (LtdInventory=='Y')
		{
		alert('This product is in limited supply and its delivery is not guaranteed');
		}
		
	if(CheckForNull('frmPage','Qty.','txtProductQty')==true)
	{
		var QtyMaxLevel = document.getElementById("txtQtyStock").value
		if ((QtyMaxLevel=="") || (QtyMaxLevel<=0)) {
			alert("Sorry, this product is Out of Stock.");
			return false;
		}
		if(CheckIsNumber('frmPage','Qty.','txtProductQty')==false) return false;
		if(MinVal('frmPage','Qty.','txtProductQty',1)==false) return false;
		if(MinMaxVal('frmPage','Qty.','txtProductQty',QtyMaxLevel)==false) return false;
		return true;
	}
	
		
	
	else
	{
		return false;
	}		
}

function CheckValidationGrdRowLvl(ObjPassed,Pid)
						{		
							alert(Pid)
							return false;
								var chkBoxObjName
								chkBoxObjName=ObjPassed.id
								
								chkBoxObjName=chkBoxObjName.replace("btnAssociateAddToCart","chkRowID")
								
								objName=ObjPassed.id
								
								
								objName=objName.replace("btnAssociateAddToCart","AttributeQuantity")							
							alert(objName)
								if (document.getElementById(objName).value=="")
								{
									alert("Quantity Must Be Entered.")
									document.getElementById(objName).focus();
									return false;
								}
								else
								{
									if(CheckIsNumber('frmPage','Quantity',document.getElementById(objName).id)==false) return false;
								}
								return true;
					}
function CheckValues(objQTY,AttribID){
//alert(objQTY);

var LstrLimitInventory = document.getElementById("hdnLimitedInvenrory_" + AttribID).value
	
	if (LstrLimitInventory=="Y")
	{
	alert("This product is in limited supply and its delivery is not guaranteed");
	}
	
	//alert(objQTY.value)
	var qty;
	qty =document.getElementById("AttributeQuantity_" + AttribID).value;
	
	if(qty==""){
	//alert("value must be entered!")
	document.getElementById("AttributeQuantity_" + AttribID).focus()
	return false;
	}
	if(qty!=""){
	
	
		/*if(isNaN(objQTY.value)){
			alert("Only numeric values are allowed!!")
			objQTY.focus()
			return false;
		}*/
		var QtyMaxLevel = document.getElementById("hdnAttributeQuantityStock_" + AttribID).value
	
		if ((QtyMaxLevel=="") || (QtyMaxLevel<=0)) {
			alert("Sorry,this product is Out of Stock.");
			document.getElementById("AttributeQuantity_" + AttribID).focus();
			return false;
		}
		if(CheckIsNumber('frmPage','Qty.',objQTY.id)==false) return false;
		if(MinVal('frmPage','Qty.',objQTY.id,1)==false) return false;
		if(MinMaxVal('frmPage','Qty.',objQTY.id,QtyMaxLevel)==false) return false;
		return true;
		
	}
}
function EnableQuantity(chkBox,AttribID)
{
	if(chkBox.checked==true){
		document.getElementById("AttributeQuantity_" + AttribID).disabled = false;
	}
	else
	{
		document.getElementById("AttributeQuantity_" + AttribID).disabled = true;
	}
}


function setAttributeFullImage(AttributeID){

document.getElementById("imgProductImage").src = "Images/FullImage/" + document.getElementById("hdnAttributeFullImage_" + AttributeID).value;
document.getElementById("hdnEnlargeImage").value = "Images/EnlargeImage/" + document.getElementById("hdnAttributeEnlargeImage_" + AttributeID).value;
var lstrImage = "";
lstrImage = document.getElementById("hdnEnlargeImage").value;
IMGNameEnlarge = lstrImage.replace("^.^"," ");
NEW_Image.src = IMGNameEnlarge;
setTimeout("abc()",1800)
}

function setAttributeColors(a,b){
//alert(a.value);
//alert(b);
	var varPropertyString = a.value;	
	var varPropertyArray = varPropertyString.split("~");
	document.getElementById("hdnAttributeFullImage_" + b).value = varPropertyArray[3];
	document.getElementById("hdnAttributeEnlargeImage_" + b).value = varPropertyArray[4];
	//var lstrImage = "";
	//lstrImage = document.getElementById("hdnEnlargeImage").value;
	//IMGNameEnlarge = lstrImage.replace("^.^"," ");
	//NEW_Image.src = IMGNameEnlarge;
	//setTimeout("abc()",1800)
}
function setAttributeSizes(a,b)
{
// alert(a.value);
//alert(b);
   var varSizeString = document.getElementById("slAttributeSizes_" + b).value;
	var varSizeArray = varSizeString.split("~");
	document.getElementById("hdnAttributePrice_" + b).value =  varSizeArray[3];
	document.getElementById("hdnAttributeSpPrice_" + b).value =  varSizeArray[4];
	document.getElementById("AttributePrice_" + b).innerHTML =  "$" + varSizeArray[3];
	document.getElementById("AttributeSpPrice_" + b).innerHTML = "$" + varSizeArray[4];
	if(parseFloat(varSizeArray[4]) > 0){
		document.getElementById("AttributePrice_" + b).innerHTML = "<font class='whitetextStrike' style='color:#000000'>" + "$" +  varSizeArray[3] + "</font>";
	}
}
function CheckboxSelection1()
	{
		var LIntCtr;
		
		var LIntSelectedCheckBoxes=0;
	
		//alert(document.forms[1].name)
		//alert(document.forms[0].name)
		
		for (LIntCtr=0; LIntCtr < document.forms[1].elements.length; LIntCtr++) {
		//alert(document.forms[1].elements[LIntCtr].name)
		//alert(document.forms[1].elements[LIntCtr].type)
		///	alert("here="+document.forms[0].elements.name);
			//aletr("here1"+document.frmPage.elements[LIntCtr].name.indexOf('chkRowID'));
			
			if (document.forms[1].elements[LIntCtr].type == 'checkbox') {
			//alert(document.forms[1].elements[LIntCtr].type)
			
				if(document.forms[1].elements[LIntCtr].checked == true){
					LIntSelectedCheckBoxes = parseInt(LIntSelectedCheckBoxes) + 1;
				}
			}
		}
		if(parseInt(LIntSelectedCheckBoxes)==0){
			alert('Item(s) Must Be Selected  !');
			return false;
		}
		
		
	}
function CheckSelectedItem(AttrId)
{

document.getElementById("AttributeQuantity_" + AttrId).focus();
var qty;
qty=document.getElementById("AttributeQuantity_" + AttrId).value
//alert(document.getElementById("AttributeQuantity_" + AttrId))
//alert(qty)
//return false;
if (qty==0)
{
//alert(document.getElementById("AttributeQuantity_" + AttrId).value)
//alert("Please enter qty greater than 0")
return false;
}
else
{		
document.getElementById("AttributeQuantity_" + AttrId).focus();
//if (CheckValues(qty,AttrId)==false) return false;

	
}
return true;
}

function CheckInventroy(AttribID)
{
var LstrLimitInventory = document.getElementById("hdnLimitedInvenrory_" + AttribID).value
	
	if (LstrLimitInventory=="Y")
	{
	alert("This product is in limited supply and its delivery is not guaranteed2");
	}
	return true;
}