﻿// JScript File
//--> Disable Enter Key Press of Page
function kH(e) {
var pK = e ? e.which : window.event.keyCode;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

//--> Short Search
function shortSearch() {
    var SearchKey = getObj("top1_txtSearchKey").value;
    var CatID = getObj("top1_cmbCategories").options[getObj("top1_cmbCategories").selectedIndex].value;

    var SearchURL = new String();
    SearchURL = "SearchResult.aspx?SearchType=ShortSearch&";
    SearchURL += "SearchKey=" + SearchKey + "&";
    SearchURL += "CatID=" + CatID;
    alert(SearchURL);
}
 
//***************** Methods about Shopping Cart ***********
function addToCart(divCart)
{
        var params = new String();
        
		//k var txtQtys = document.all.tags("input");
		var txtQtys = document.getElementsByTagName("input");
		var index = 0;
		for (var i = 0; i < txtQtys.length; i++)
		{
			if (txtQtys[i].type.toUpperCase() == "TEXT" && txtQtys[i].id.search("txtQty") != -1)
			{
			    if (txtQtys[i].value != "" && IsNumeric(txtQtys[i].value) && Number(txtQtys[i].value) > 0)
			    {
			        var txtQtyID = txtQtys[i].id; 
			        //print(txtQtyID);
			        var pID  = txtQtyID.split("_")[1];
			        var qty = txtQtys[i].value;
			        txtQtys[i].value = "";
			        params += pID + "^1" +qty+"^2";
			    }
			    index += 1;
			}
		}
		postPage("ajShoppingCart.aspx",divCart,"Method=AddItem&Params="+params);
}

function showTopShoppingCart(divAjax) {
    postPage("ajShoppingCart.aspx",divAjax,"Method=ListItem");
}

function clearQtyBoxs()
{
		//var txtQtys = document.all.tags("input");
		var txtQtys = document.getElementsByTagName("input");
		for (var i = 0; i < txtQtys.length; i++)
		{
			if (txtQtys[i].type.toUpperCase() == "TEXT" && txtQtys[i].id.search("txtQty") != -1)
			{
			    txtQtys[i].value = "";
			}
		}
}

function validQty(objQty,validateText)
{
    if (!IsNumeric(objQty.value))
    {
        alert(validateText);
        objQty.value = ""; 
    }
}

//--> Forgot password
 function showForgotPasswordPopup(divName)
{
    showPage("ajForgotPassword.aspx?x=1",divName); 
}

//-->function mouse on topline
var oldColor;
function tlmover(obj){oldColor = obj.style.color; obj.style.color = "orange";}
function tlmout(obj){obj.style.color=oldColor;}

// Quick Search
function showQuickSearch(divName)
{
    showPage("ajQuickSearch.aspx?x=1",divName); 
}