﻿// JScript File for Site.master

    function Initialize()
    {
        SetLogo();
    }  
    
    function SetSelectedCategory(CategoryName)
    {           
        var DeptName = document.getElementById('ctl00_LeftNav1_SelectedID');    
                    
        //DeptName.value =  DeptName.value + CategoryName + ",";
        DeptName.value =  CategoryName + ",";
            
    }   
    function BillMeLaterPopUp()
    {
        window.open('/checkout/bmlpopup.aspx', '_blank', 'width=510,height=550,status=0,menubar=0,location=0,titlebar=0,toolbar=0,resizable=0,scrollbars=1');
    }
                    
    function SetLogo()
    {
        var randomNumber = Math.floor(Math.random() * 6); 
        if (document.getElementById("MainLogo"))
            document.getElementById("MainLogo").setAttribute("src", "images/kitchenetc2/HomePage/kelogo_" + randomNumber + ".gif");
        else if (document.getElementById("ctl00_MainLogo"))
            document.getElementById("ctl00_MainLogo").setAttribute("src", "images/kitchenetc2/HomePage/kelogo_" + randomNumber + ".gif");            
    }
       
    function SetSubCategoryFocus(N) // called when list page loads after clicking on subcategory.
    {        
        var name = "N=" + N;               
        var selectedCategory = document.getElementById(name);                 
        if(selectedCategory) 
        {         
           
            //If the menu item can't be found, ignore this code.
            selectedCategory.parentNode.parentNode.parentNode.style.display = "block";
            var imageID = selectedCategory.parentNode.getElementsByTagName("td")[1].getAttribute("ImageID");
            var image = document.getElementById(imageID);
            if (image) 
            {
                var strNewImage = image.src.replace(".gif", "_x.gif");
                image.src = strNewImage;
            }
        }
    }
    
    function Toggle(table, imgID, plusImage, minusImage)
    {
        // Change the image of the button
    	var NavImage = document.getElementById(imgID);
    	var SelctedID = document.getElementById('SelectedID');
    	alert(SelctedID.value);
    	SelctedID.value = '10';
    	if (NavImage != null)
    	    if(NavImage.src.indexOf("x.gif") > 0)
        	    NavImage.src = plusImage.replace("&apos;", "'");
    	    else
        	    NavImage.src = minusImage.replace("&apos;", "'");

    	// Show or hide the sub categories
    	var SubCategories  = document.getElementById(table);
        if (SubCategories)
    	    if (SubCategories.style.display == "none")
    		    SubCategories.style.display = "block";
    	    else
	    	    SubCategories.style.display = "none";
    }  
    
    function EnlargeImagePopUp(pid, pName, pBrand, pSize, imagenum)
    {
        var appName = navigator.appName;
	    
	    if (appName == "Microsoft Internet Explorer") 
		    var mywin = window.open("EnlargeImagePopUp.aspx?R=" + pid + "&Name=" + pName + "&Brand=" + pBrand + "&Size=" + pSize + "&En=" + imagenum, "EnlargeView", "width=580px, height=535px, left=0, top=0, scrollbars=yes, resizable=yes");
	    else
	    	var mywin = window.open("EnlargeImagePopUp.aspx?R=" + pid + "&Name=" + pName + "&Brand=" + pBrand + "&Size=" + pSize + "&En=" + imagenum, "EnlargeView", "width=580px, height=535px, screenX=0, screenY=0, scrollbars=yes, resizable=yes");
	}	
	
	function OpenTrackingWindow(CarrierName, TrackNo)
	{
	    var CarrierURL = "";
	 
	    switch (CarrierName)
	    {	        
	        case "DHL":
	            CarrierURL = "http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=" + TrackNo;
	            break;
	            
	        case "UPS":
	            CarrierURL =  "/checkout/upstrack.asp?trackingno=" + TrackNo;
	            break;
	        	                   
	        case "USPS":
	            CarrierURL =  "/checkout/uspstrack.asp?trackingno=" + TrackNo;
	            break; 
	            
	        case "FEDEX":
	            CarrierURL = "http://www.fedex.com/cgi-bin/tracking?action=track&language=plain&cntry_code=us&initial=x&tracknumbers=" + TrackNo;
	            break;

	        case "SPB":
	            CarrierURL = "/checkout/uspstrack.asp?trackingno=" + TrackNo;
	            break;

	        case "UMI":
	            CarrierURL = "/checkout/uspstrack.asp?trackingno=" + TrackNo;
	            break;

	        case "SSAV":
	            CarrierURL = "/checkout/uspstrack.asp?trackingno=" + TrackNo;
	            break;

	        case "FESP":
	            CarrierURL = "/checkout/uspstrack.asp?trackingno=" + TrackNo;
	            break;  
	    }
	    
	    var InfoPopUp = window.open(CarrierURL, "OrderTracking", "width=670, height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1,top=20,left=20");
	}
	
	function OpenShipmentWindow(OrderID, ShipmentID)
	{
	    var InfoPopUp = window.open("ShipmentDetail.aspx?oid=" + OrderID + "&sid=" + ShipmentID);
	}
		
    function UpdateEmailText(SearchBox)
    {
        if (SearchBox.value =="Enter your email address")
        {
            SearchBox.value = "";
        }            
    }
    
    function DefaultEmailText(SearchBox)
    {
        if (SearchBox.value == "")
        {
            SearchBox.value = "Enter your email address";
        }
    }
    
    function confirmReport(reviewID)
    {
        var reviewID = reviewID;
        var win = confirm("Do you really want to submit this review as inappropriate?");
        
        if (win == true)
        {    
            window.open('ReviewPopUp.aspx?c=3&s=' + reviewID, 'CustomPopUp', 'width=300, height=250, menubar=no, resizable=no');
        }        
    }
