﻿// JScript File

var strDomain = "http://localhost:51497/sendflowerstoindia/";
//var strDomain="http://www.giftsflowerstoindia.com/";
var top = 0;
var button = 3;
var searchanchor;
var tempload;
var tophttpRequest1 = false;

function topmakeObjecttop() {
    var tophttpRequest;
    if (window.XMLHttpRequest) {
        tophttpRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try {
            tophttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            tophttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    return tophttpRequest;
}
tophttpRequest1 = topmakeObjecttop();
function Top_processRequest_load_Removeitem() 
{
    if (tophttpRequest1 == null) 
    {
        tophttpRequest1 = topmakeObjecttop();
    }
   if (tophttpRequest1.readyState < 4) {
      // document.getElementById('span_'+prodid).style.display = "block";
        //           document.getElementById("tdloader").innerHTML="<img src=\"images/loadinfo.net.gif\"  alt=\"loading\" />"
     //  alert('ok');
    }
    if (tophttpRequest1.readyState == 4) 
    {
        if (tophttpRequest1.status == 200) 
        {
            var response1 = tophttpRequest1.responseText;
            var arrres1 = new Array();
           // alert('ok1');
           // alert(response1);
            if (response1.indexOf("|@#$") != -1)
            {
                arrres1 = response1.split("|@#$");
            }
            
             if(arrres1[0].indexOf('continue shopping')>-1)
            {
             document.getElementById("dvrelatedcat").style.display = "none";
            }
          document.getElementById("category").innerHTML = arrres1[0];
            if(arrres1[1]=="")
            {
                document.getElementById("uchead_dvshopping").style.display = "none";
               
            }
            else if(arrres1[1]!="") {
           // alert(arrres1[1]);
                document.getElementById("uchead_dvshopping").innerHTML = arrres1[1];
            }
            //document.getElementById("divshow").innerHTML = response;          
        }
    }
}
function Top_processRequest_load_discount() 
{
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
//    if (tophttpRequest1.readyState < 4) {
        //           document.getElementById("tdloader").style.display="block";
        //           document.getElementById("tdloader").innerHTML="<img src=\"images/loadinfo.net.gif\"  alt=\"loading\" />"

//    }
    if (tophttpRequest1.readyState == 4) {

        if (tophttpRequest1.status == 200) {
            var response2 = tophttpRequest1.responseText;
            var arrres2=new Array();
            if(response2.indexOf("|")!=-1)
            {
                arrres2=response2.split("|");
            }
            document.getElementById("category").innerHTML = arrres2[0];
            document.getElementById("uchead_dvshopping").innerHTML = arrres2[1];
            //document.getElementById("divshow").innerHTML = response2;
        }
    }
}
function Top_processRequest_load_edititem() 
{
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
//    if (tophttpRequest1.readyState < 4) {
        //           document.getElementById("tdloader").style.display="block";
        //           document.getElementById("tdloader").innerHTML="<img src=\"images/loadinfo.net.gif\"  alt=\"loading\" />"

//    }
    if (tophttpRequest1.readyState == 4) 
    {
        if (tophttpRequest1.status == 200) {
            var response = tophttpRequest1.responseText;
            var arrres=new Array();
            if(response.indexOf("|")!=-1)
            {
                arrres=response.split("|");
            }
            document.getElementById("category").innerHTML = arrres[0];
            document.getElementById("uchead_dvshopping").innerHTML = arrres[1];
            //document.getElementById("divshow").innerHTML = response;
        }
    }
}


function Top_processRequest_removeallitem() {
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
    if (tophttpRequest1.readyState < 4) {
        // document.getElementById('span_'+prodid).style.display = "block";
        //           document.getElementById("tdloader").innerHTML="<img src=\"images/loadinfo.net.gif\"  alt=\"loading\" />"

    }
    if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
            var response1 = tophttpRequest1.responseText;
            var arrres1 = new Array();

            if (response1.indexOf("|@#$") != -1) {
                arrres1 = response1.split("|@#$");
            }

            if (arrres1[0].indexOf('continue shopping') > -1) {
                document.getElementById("dvrelatedcat").style.display = "none";
            }
            document.getElementById("category").innerHTML = arrres1[0];
            if (arrres1[1] == "") {
                document.getElementById("uchead_dvshopping").style.display = "none";
            }
            else if (arrres1[1] != "") {
                document.getElementById("uchead_dvshopping").innerHTML = arrres1[1];
            }
            //document.getElementById("divshow").innerHTML = response;          
        }
    }
}




function Top_processRequest_load_login() {
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
    if (tophttpRequest1.readyState < 4) {
        // document.getElementById('span_'+prodid).style.display = "block";
        //           document.getElementById("tdloader").innerHTML="<img src=\"images/loadinfo.net.gif\"  alt=\"loading\" />"

    }
    if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
            var response1 = tophttpRequest1.responseText;

            if (response1 != "notentered") {
                document.getElementById("ucrightpanel_dvlogin").style.display = "none";
                document.getElementById("uchead_dvwith").style.display = "block";

                var headerlogin = "<p><span id=\"spanid\">Welcome  " + response1 + "</span>" +
			                   "<span><a class=\"logout\" title=\"Log Out\" href=\"logout.aspx\">Log Out</a></span><span><a title=\"Track Your Order\" href=\"orderstatus.aspx\">Track Your Order</a></span></p>";


                document.getElementById("uchead_dvwith").innerHTML = headerlogin;
                
                //document.getElementById("uchead_spanid").innerHTML = response1;
                document.getElementById("ucrightpanel_dvbenifit").style.display = "none";
                document.getElementById("ucrightpanel_dvsendrakhi").style.display = "none";

            }
            else {
                document.getElementById("ucrightpanel_perror").style.display = "block";
                
            }
            
      
        }
    }
}




function Top_processRequest_Blur() {

    if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
            //alert('OK')

            ClearAndSetddllistItems(tophttpRequest1.responseXML.documentElement);
        }
        else {
            alert("There was a problem retrieving data from the server.");
        }
    }
}
//
function ClearAndSetddllistItems(TableNode) {

    var ddllist = document.getElementById("dropstate");
    for (var count = ddllist.options.length - 1; count > -1; count--) {
        ddllist.options[count] = null;
    }

    var FieldNode = TableNode.getElementsByTagName('State_Name');
    var FieldNode1 = TableNode.getElementsByTagName('State_Id');

    var textValue;
    var textID;
    var optionItem;


    for (var count = 0; count < FieldNode.length; count++) {
        textValue = FieldNode.item(count).firstChild.nodeValue;
        textID = FieldNode1.item(count).firstChild.nodeValue
        optionItem = new Option(textValue, textID, false, false);
        ddllist.options[ddllist.length] = optionItem;
    }
}




function deleteItem(Obj) 
{
    deleteid = encodeURIComponent(Obj);
    tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_load_Removeitem;
    tophttpRequest1.send("deleteid=" + deleteid + "&mode=60");
}

function EditItem(Obj, qty) {
    editid = encodeURIComponent(Obj);
    qtytotal = encodeURIComponent(qty);
    tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_load_edititem;
    tophttpRequest1.send("editid=" + editid + "&qtytotal=" + qtytotal + "&mode=61");
}
function discountcalculation(discountcode1) {
    if (document.getElementById('textfield2').value == '') {
        document.getElementById('textfield2').focus();
           }
    else {
        discountcode = encodeURIComponent(discountcode1);
        tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
        tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        tophttpRequest1.onreadystatechange = Top_processRequest_load_discount;
       
        tophttpRequest1.send("discountcode=" + discountcode + "&mode=statusdiscount");
    }
}
function returnshoppingid(catagoryid,prodid) {

    var Quantity = document.getElementById("qty").value;
   // alert(Quantity);
    catagoryid = encodeURIComponent(catagoryid);
    prodid = encodeURIComponent(prodid);
    Quantity = encodeURIComponent(Quantity);
    //window.location.href = "" + strDomain + "AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    window.location.href ="AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    
    
    
    
    //window.location.href = ""+strDomain+"shoppingcrt.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    //window.location.href = ""+strDomain+"shoppingcrt.aspx";
}
function returnshoppingidsendrakhi(catagoryid, prodid) {

    var Quantity = 1;
  //  alert(Quantity);
    catagoryid = encodeURIComponent(catagoryid);
    prodid = encodeURIComponent(prodid);
    Quantity = encodeURIComponent(Quantity);
    //window.location.href = "" + strDomain + "AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    window.location.href = "AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;




    //window.location.href = ""+strDomain+"shoppingcrt.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    //window.location.href = ""+strDomain+"shoppingcrt.aspx";
}


function checknullvalue() 
{
    if (document.getElementById("qty").value == "0" || document.getElementById("qty").value == "") 
    {
        document.getElementById("qty").value = "1"
    }
}
function checknullvalue1(Obj) 
{
    if (document.getElementById(Obj.id).value == "0" || document.getElementById(Obj.id).value == "") 
    {
        document.getElementById(Obj.id).value = "1"
    }

}


function buyproduct(catid, prodid) {
    var categoryid = encodeURIComponent(catid);
    var productid = encodeURIComponent(prodid);
    var quantity = 1;
    window.location = "AddtoCart.aspx?prodid=" + productid + "&Quantity=" + quantity + "&catagoryid=" + categoryid;
}

function returnshoppingidfront(catagoryid, prodid) {
    var Quantity = 1;
    catagoryid = encodeURIComponent(catagoryid);
    prodid = encodeURIComponent(prodid);
    Quantity = encodeURIComponent(Quantity);
    document.getElementById('a_'+ prodid).style.display = "none";
    document.getElementById(prodid).style.display = "block";
    //window.location.href = "" + strDomain + "AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    window.location.href = "AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;




    //window.location.href = ""+strDomain+"shoppingcrt.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;
    //window.location.href = ""+strDomain+"shoppingcrt.aspx";
}


function SelectTxtid(prodid, qty) {
    document.getElementById("hdsetprodid").value = prodid;
    document.getElementById("hdsetqty").value = qty;
}


function Removeallproduct() {
    tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_removeallitem;
    tophttpRequest1.send("mode=statusremoveallitem");

}


function checkemptyfield() {
 
    var rtn = '';
    if (document.getElementById("uchead_Uc_search_txtSearch").value == "") {
        document.getElementById("uchead_Uc_search_txtSearch").style.backgroundColor = "#ff00ff";
        document.getElementById("uchead_Uc_search_txtSearch").focus();
        rtn = false;
    }
    else {
        rtn = true;
    }
    return rtn;

}



function logincustomer() {
  //  alert(document.getElementById("ucleftpanel_txtemail").value);
     var userid = document.getElementById("ucrightpanel_txtemail").value;
    var upasswrd = document.getElementById("ucrightpanel_txtpassword").value;

    tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_load_login;
    tophttpRequest1.send("userid=" + userid + "&upasswrd=" + upasswrd + "&mode=login");

}


function searchsubdetailsdrop() {
    var bindstate = document.getElementById("dropcountry").value;
    var country_name = document.getElementById("country");
    var country = document.getElementById("dropcountry");
    var country_index = country.selectedIndex;
    country_name.value = country.options[country_index].text;
   // alert(bindstate);
    if (bindstate != 0) {

        bindstate = encodeURIComponent(bindstate);

        tophttpRequest1.open("POST", "AjaxRemoveItem.aspx", true);
        tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        tophttpRequest1.onreadystatechange = Top_processRequest_Blur;
        tophttpRequest1.send("bindstate=" + bindstate + "&mode=fillState");

    }

}



