var OpenWin;
function productDetail(teaser, linkurl, prodcode, groupcode)
{
var strProdCode = prodcode;
var strGroupCode = groupcode;
var e = document.getElementById("cboProducts" + teaser);
if (e) {
    var strCboProduct = e.options[e.selectedIndex].value;
	//alert (strCboProduct);
	var strProdValues = strCboProduct.split("|");
	strProdCode = strProdValues[0];
	
}
document.location.href ="productdetails.aspx?"+linkurl+'&hdnGroupCode='+strGroupCode+'&hdnProdCode='+strProdCode
}



function addToCart(mem,teaser,perm,linkurl,prodcode,groupcode,customtext,hdnAnchor) {
    //alert(perm);
    //alert(document.getElementById("txtQty" + teaser).value);
    var qtybox = document.getElementById("txtQty" + teaser).value;
	
	//if (mem =='0')
	//{
	//	if (confirm("Please login to add an item to the Shopping Cart. Use the section above to login.\nAre you a new customer?\nClick OK to be taken to the Register Page, click Cancel to remain on this page.\nRegistration is instant and allows you to save your cart for later.")==true){
	//		document.location.href="register.asp";
	//	}
	//}
	//else
	
	
	if (qtybox =='' || qtybox == 0 || qtybox < 0 )
	{
		alert ("Please specify the quantity to be added to the Shopping Cart");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (isNaN(qtybox))
	{
		alert ("Invalid quantity value. Please enter a proper quantity.");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (qtybox.indexOf(".")!= -1 )
	{
		alert ("Please do not enter decimal values.");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (customtext == 'Y' && document.getElementById("txtCustom" + teaser).value == "")
	{
		alert ("Please enter in the text to be added to the sign.");
		document.getElementById("txtCustom" + teaser).focus();
	}
	else if (perm == 'T'){
	var strProdCode = prodcode;
	var strGroupCode = groupcode;
	var e = document.getElementById("cboProducts" + teaser);
	if (e) {
	    var strCboProduct = e.options[e.selectedIndex].value;
	    var strProdValues = strCboProduct.split("|");
	    strProdCode = strProdValues[0];
	}
		document.location.href ="productdetails.aspx?"+linkurl+'&hdnGroupCode='+strGroupCode+'&hdnProdCode='+strProdCode
		
	}
	else {
	    var e = document.getElementById("cboProducts" + teaser);
	    var f = document.getElementById("txtCustom" + teaser);
	    if (e) {
	        var strCboProduct = e.options[e.selectedIndex].value;
	        var strProdValues = strCboProduct.split("|");
	        document.getElementById("hdnProductCode" + teaser).value = strProdValues[0];
	        document.getElementById("hdnaddprodcode").value = strProdValues[0];
	        document.getElementById("hdnProductPrice" + teaser).value = strProdValues[1];
	        document.getElementById("hdnaddprice").value = strProdValues[1];
	        document.getElementById("hdnaddqty").value = qtybox;
	        document.getElementById("hdnaddtocart").value = "addtocart";
	        if (f) {
	            document.getElementById("hdnaddtocustome").value = f.value;
	        }
	    } else {
	        document.getElementById("hdnaddprodcode").value = document.getElementById("hdnProductCode" + teaser).value;
	        document.getElementById("hdnaddprice").value = document.getElementById("hdnProductPrice" + teaser).value;
	        document.getElementById("hdnaddqty").value = qtybox;
	        document.getElementById("hdnaddtocart").value = "addtocart";
	        if (f) {
	            document.getElementById("hdnaddtocustome").value = f.value;
	        }
	    }

	    document.getElementById("hdnach").value = hdnAnchor;
	    //document.getElementById("teaser").value = teaser;
	document.forms[0].submit();
	}
}

function checkForDecimals(txtcheck)
{
	var strError="";
	if(txtcheck.value != ""){
		if (isNaN(txtcheck.value)){
			strError = "Please enter in only numbers.";
			txtcheck.focus();
			return strError;
		}
		else
		{
			if(txtcheck.value.indexOf(".")!= -1){
				if (txtcheck.value.substr(txtcheck.value.indexOf(".")).length > 3){
				strError = "Please enter in only 2 nos after decimal.";
				txtcheck.focus();
				return strError;
				}
			}
		}
	}
	return strError;
}


function getOtherProduct(teaser, strGroupCode, linkurl) {
    //alert(teaser);
    var e = document.getElementById("cboProducts" + teaser);
    if (e) {
        var strCboProduct = e.options[e.selectedIndex].value; 
	//alert (strCboProduct);
        var strProdValues = strCboProduct.split("|");
        //alert(strProdValues);
	var strProdCode = strProdValues[0];
	}
	//alert (linkurl);
	if (linkurl != '') {
	    document.location.href = "productdetails.aspx?" + linkurl + '&hdnGroupCode=' + strGroupCode + '&hdnProdCode=' + strProdCode;
	}
	else {
	    document.location.href = "productdetails.aspx?hdnGroupCode=" + strGroupCode + '&hdnProdCode=' + strProdCode;
	}
	
}


function openTDS(techurl)
{
var wintech = 'TdsWindow';
var feat = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=400,left=50,screenx=35,top=0,screenY=50';
var page=techurl;
OpenWin = this.open(page, wintech, feat);	
}


function enlargedImage(imgurl)
{
var page='/images/large_images/'+imgurl;

var feat = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=300,left=50,screenx=35,top=0,screenY=50';
var generator=window.open('','enlargedWindow',feat);
  generator.document.write('<html><head><title>Leosignage - Enlarged Image</title><script language="javascript">function resize(){window.resizeTo(document.getElementById("enlimage").width+50,document.getElementById("enlimage").height+90);}window.focus();</script>');
  generator.document.write('<link href="css/styles.css" rel="stylesheet" type="text/css">');
  generator.document.write('</head><body onload=resize();>');
  generator.document.write('<table width="100%" border="0" align="center" cellpadding="3" cellspacing="3" bordercolor="#CCCCCC">');
  
  generator.document.write('<tr><td align="center"><img id="enlimage" src='+page+' border="0"></td></tr>');
  generator.document.write('<tr><td align="center" height="18" valign="top" ><div align="center"><a href="javascript:window.close()" ><font class="pro_txt">Close Window&nbsp;</font></a></div></td></tr></table>');
 
  generator.document.write('</body></html>');
  generator.document.close();


}

function AddToCartDetail(mem,teaser,perm,customtext) {

    var qtybox = document.getElementById("txtQty" + teaser).value;
    //alert(qtybox);
	//if (mem =='0')
	//{
	//	if (confirm("Please login to add an item to the Shopping Cart. Use the section above to login.\nAre you a new customer?\nClick OK to be taken to the Register Page, click Cancel to remain on this page.\nRegistration is instant and allows you to save your cart for later.")==true){
	//		document.location.href="register.asp";
	//	}
	//}
	if (qtybox =='' || qtybox == 0 || qtybox < 0 )
	{
		alert ("Please specify the quantity to be added to the Shopping Cart");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (isNaN(qtybox))
	{
		alert ("Invalid quantity value. Please enter a proper quantity.");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (qtybox.indexOf(".")!= -1 )
	{
		alert ("Please do not enter decimal values.");
		document.getElementById("txtQty" + teaser).focus();
	}
	else if (customtext=='Y' && document.getElementById("txtCustom").value == "" )
	{
		alert ("Please enter in the text to be added to the sign.");
		document.getElementById("txtCustom").focus();
	}
	else if (perm=='Y'){
		if ((document.getElementById("txtHeight").value == '' || document.getElementById("txtHeight").value == '0' ) && (perm=='Y'))
		{
			alert ("Height or Width cannot be zero.");
			document.getElementById("txtHeight").focus();
		}
		else if ((document.getElementById("txtWidth").value == '' || document.getElementById("txtWidth").value == '0' ) && (perm=='Y'))
		{
			alert ("Height or Width cannot be zero.");
			document.getElementById("txtWidth").focus();
		}
		else if (isNaN(document.getElementById("txtHeight").value) != '' && perm=='Y')
		{
			alert ("Please enter in only numbers.");
			document.getElementById("txtHeight").focus();
		}
		else if (isNaN(document.getElementById("txtWidth").value) != '' && perm=='Y')
		{
			alert ("Please enter in only numbers.");
			document.getElementById("txtWidth").focus();
		}
		else if (checkForDecimals(document.getElementById("txtHeight")) != '' && perm=='Y')
		{
			alert ("Please enter in only 2 nos after decimal.");
			document.getElementById("txtHeight").focus();
		}
		else if (checkForDecimals(document.getElementById("txtWidth")) != '' && perm=='Y')
		{
			alert ("Please enter in only 2 nos after decimal.");
			document.getElementById("txtWidth").focus();
		}
		else
		{
		    document.getElementById("hdncartp").value = "addtocart";
		    document.getElementById("hdnqty").value = document.getElementById("txtQty" + teaser).value;
		    document.forms[0].submit();
		}
		
	}
	else
	{
	    document.getElementById("hdncartp").value = "addtocart";
	    document.getElementById("hdnqty").value = document.getElementById("txtQty" + teaser).value;
	    document.forms[0].submit();
	}
}
