﻿// JScript File

function Search()
{
    var strValue = document.getElementById("txtsearch").value;
    if (strValue!='')
    {
        window.location="Products.aspx?search=" + strValue; 
    }
}
//
//
function getKeyCode(event)
{
	event = event || window.event;
	return event.keyCode;
}
//
//
function KeyPress(event){
	if (getKeyCode(event) == 13) {
	    Search();
	}
}
//
//
function ViewBasket()
{
    //alert("View basket ");
    window.location="Cart.aspx";
}
//
//
function Login()
{
    window.location="Login.aspx?conn=2";
}
//
//
function CleanURL()
{
    //Clean Logout
    var strURL = top.location.href;
    if(strURL.indexOf("&logout") > -1){
        strURL = strURL.substring(0, strURL.indexOf("&logout"));
    }else {
        if(strURL.indexOf("logout") > -1){
            strURL = strURL.substring(0, strURL.indexOf("logout"));
        }
    }
    //Clean Login
    if(strURL.indexOf("&conn") > -1){
        strURL = strURL.substring(0, strURL.indexOf("&conn"));
    }else {
        if(strURL.indexOf("conn") > -1){
            strURL = strURL.substring(0, strURL.indexOf("conn"));
        }
    }
    //Clean Location
    if(strURL.indexOf("&nwcity") > -1){
        strURL = strURL.substring(0, strURL.indexOf("&nwcity"));
    }else {
        if(strURL.indexOf("nwcity") > -1){
            strURL = strURL.substring(0, strURL.indexOf("nwcity"));
        }
    }
    //Clean Currency
    if(strURL.indexOf("&curry") > -1){
        strURL = strURL.substring(0, strURL.indexOf("&curry"));
    }else {
        if(strURL.indexOf("curry") > -1){
            strURL = strURL.substring(0, strURL.indexOf("curry"));
        }
    }
    //Clean BillType
    if(strURL.indexOf("&btype") > -1){
        strURL = strURL.substring(0, strURL.indexOf("&btype"));
    }else {
        if(strURL.indexOf("btype") > -1){
            strURL = strURL.substring(0, strURL.indexOf("btype"));
        }
    }
    
    
    return strURL;
}
//
//
function LogOut()
{
    var currentURL = window.location;
    var strParam = currentURL.search;
    
    if (strParam ==''){
        window.location = top.location.href + "?logout=99" ;
    } else {
        var strURL = top.location.href;
        strURL = CleanURL();
        window.location = strURL + "&logout=99";
    }
}//
//
function ChangeCurre(val)
{
    //var IndexValue = document.getElementById('<%=drpCurrency.ClientID %>').selectedIndex;
    //var SelectedVal = document.getElementById('<%=drpCurrency.ClientID %>').options[IndexValue].value;
    var SelectedVal = val;
    var currentURL = window.location;
    var strParam = currentURL.search;
    
    if (strParam ==''){
        window.location=top.location.href + "?curry=" + SelectedVal;
    }
    else {
        var strURL = top.location.href;
        strURL = CleanURL();
        window.location = strURL + "&curry=" + SelectedVal;
    }
}
//
//
function ChangeLoca(val)
{
    var SelectedVal = val;
    var currentURL = window.location;
    var strParam = currentURL.search;
    
    if (strParam ==''){
        window.location = top.location.href + "?nwcity=" + SelectedVal;
    } else {
        var strURL = top.location.href;
        strURL = CleanURL();
        window.location = strURL + "&nwcity=" + SelectedVal;
    }
}
//
//
function BillTypeSwitch(val)
{
    var SelectedVal = val;
    var currentURL = window.location;
    var strParam = currentURL.search;
    
    if (strParam ==''){
        window.location = top.location.href + "?btype=" + SelectedVal;
    } else {
        var strURL = top.location.href;
        strURL = CleanURL();
        window.location = strURL + "&btype=" + SelectedVal;
    }
}


