﻿// JScript File

var strDomain = "http://www.reliableflorists.com/";
//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();
            if (response1.indexOf("|@#$") != -1)
            {
                arrres1 = response1.split("|@#$");
            }
           

            document.getElementById("divshow").innerHTML = arrres1[0];
            if(arrres1[1]=="")
            {
                document.getElementById("uchead_dvshopping").style.display = "none";
               
            }
            else if(arrres1[1]!="") {
                document.getElementById("uchead_dvshopping").innerHTML = arrres1[1];
            }
                      
        }
    }
}
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("|");
            }
            if (arrres2[2] != 'y') {
               jAlert(arrres2[2], 'Discount Alert!');
           }
            document.getElementById("divshow").innerHTML = arrres2[0];
            document.getElementById("uchead_dvshopping").innerHTML = arrres2[1];
           
        }
    }
}


function Top_processRequest_load_discount_shopcart() {
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
    
    if (tophttpRequest1.readyState == 4) {

        if (tophttpRequest1.status == 200) {
            var response2 = tophttpRequest1.responseText;
            var arrres2 = new Array();
            if (response2.indexOf("|") != -1) {
                arrres2 = response2.split("|");
            }
            if (arrres2[1] != 'y') {
                $('#divShopCart').show();
                document.getElementById("divShopCart").style.display = "block";
                document.getElementById("divShopCart").innerHTML = arrres2[0];
                jAlert(arrres2[1], 'Discount Alert!');
            }
            else {
                
                $('#divShopCart').show();
                document.getElementById("divShopCart").style.display = "block";
                document.getElementById("cartArea").innerHTML = arrres2[2];
                document.getElementById("divShopCart").innerHTML = arrres2[0];
            }
            

        }
    }
}
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("divshow").innerHTML = arrres[0];
            document.getElementById("uchead_dvshopping").innerHTML = arrres[1];
            
        }
    }
}






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("|@#$");
            }
            document.getElementById("divshow").innerHTML = arrres1[0];
            if (arrres1[1] == "") {
                document.getElementById("uchead_dvshopping").style.display = "none";
            }
            else if (arrres1[1] != "") {
                document.getElementById("uchead_dvshopping").innerHTML = arrres1[1];
            }
                   
        }
    }
}
function Top_processRequest_load_cartfadediv() {
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
    if (tophttpRequest1.readyState < 4) {
        $('#divShopCart').show();
        var stringbind = "<div><div ><a href=\"#\"></a><br/><span></span><br/></div><div><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"265\"><tbody><tr><td height=\"37px\"></td><td width=\"170\" valign=\"middle\" align=\"center\"><img src=\"http://www.reliableflorists.com/images/images.gif\"  alt=\"loading\" /></td></tr></tbody></table></div></div>";
        document.getElementById("divShopCart").innerHTML = stringbind;
       

    }
       if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
            var response = tophttpRequest1.responseText;
            document.getElementById("uchead_dvshopping").innerHTML = response;
			 $('html, body').animate({ scrollTop: 0 }, 'normal');
            $('#divShopCart').hide();
            $("#divShopCart").fadeIn(2000);
            $("#divShopCart").fadeOut(9000);

            
        }
    }
}

function Top_processRequest_load_cartfadediv_category() {
    if (tophttpRequest1 == null) {
        tophttpRequest1 = topmakeObjecttop();
    }
    if (tophttpRequest1.readyState < 4) {
        $('#divShopCart').show();
        var stringbind = "<div><div ><a href=\"#\"></a><br/><span></span><br/></div><div><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"265\"><tbody><tr><td height=\"37px\"></td><td width=\"170\" valign=\"middle\" align=\"center\"><img src=\"http://www.reliableflorists.com/images/images.gif\"  alt=\"loading\" /></td></tr></tbody></table></div></div>";
        document.getElementById("divShopCart").innerHTML = stringbind;
       

    }
    if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
            var response = tophttpRequest1.responseText;
            document.getElementById("uchead_dvshopping").innerHTML = response;
            $('html, body').animate({ scrollTop: 0 }, 'normal');
            $('#divShopCart').hide();
            $("#divShopCart").fadeIn(2000);
            $("#divShopCart").fadeOut(9000);

        }
    }
}
function Top_processRequest_Blur() {

    if (tophttpRequest1.readyState == 4) {
        if (tophttpRequest1.status == 200) {
           
            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);
    document.getElementById('spandel_' + deleteid).style.display = "none";
    document.getElementById('span_' + deleteid).style.display = "block";
    tophttpRequest1.open("POST", "http://www.reliableflorists.com/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", "http://www.reliableflorists.com/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", "http://www.reliableflorists.com/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 discountcalculationShopcart(discountcode1) {
    if (document.getElementById('txtdiscount').value == '') {
        document.getElementById('txtdiscount').focus();
    }
    else {
        discountcode = encodeURIComponent(discountcode1);
        tophttpRequest1.open("POST", "http://www.reliableflorists.com/AjaxRemoveItem.aspx", true);
        tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        tophttpRequest1.onreadystatechange = Top_processRequest_load_discount_shopcart;

        tophttpRequest1.send("discountcode=" + discountcode + "&mode=statusdiscountShopCart");
       
    }
}
function returnshoppingid(catagoryid,prodid) {

    var Quantity = document.getElementById('dropqty').options[document.getElementById('dropqty').selectedIndex].text;
    catagoryid = encodeURIComponent(catagoryid);
    prodid = encodeURIComponent(prodid);
    Quantity = encodeURIComponent(Quantity);
    tophttpRequest1.open("POST", "http://www.reliableflorists.com/AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_load_cartfadediv;
    tophttpRequest1.send("prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid="+catagoryid+"&mode=productcart");
    
}
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 = "http://www.reliableflorists.com/AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;

}


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;
    tophttpRequest1.open("POST", "http://www.reliableflorists.com/AjaxRemoveItem.aspx", true);
    tophttpRequest1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    tophttpRequest1.onreadystatechange = Top_processRequest_load_cartfadediv_category;
    tophttpRequest1.send("productid=" + productid + "&quantity=" + quantity + "&categoryid=" + categoryid + "&mode=categorycart");
    
}

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 = "http://www.reliableflorists.com/AddtoCart.aspx?prodid=" + prodid + "&Quantity=" + Quantity + "&catagoryid=" + catagoryid;

}


function SelectTxtid(prodid, qty) {
    document.getElementById("hdsetprodid").value = prodid;
    document.getElementById("hdsetqty").value = qty;
}


function Removeallproduct() {
    tophttpRequest1.open("POST", "http://www.reliableflorists.com/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 searchsubdetailsdrop() {
    var bindstate = document.getElementById("dropcountry").value;
   // 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");

    }

}


function callfunctiondiv() {
    $(function () {
        $('#dvshow').hide();
        $("#show").click(function () {
            $("#dvshow").fadeIn(1000);
            $("#dvshow").fadeOut(400);
        });
    });
}


function buyproductallbought(catid, prodid) {
    var categoryid = encodeURIComponent(catid);
    var productid = encodeURIComponent(prodid);
    var quantity = 1;
    window.location = "http://www.reliableflorists.com/AddtoCart.aspx?prodid=" + productid + "&Quantity=" + quantity + "&catagoryid=" + categoryid;
}

function checkno(z) {
    var y = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    //var z = document.getElementById("txtmob").value;
    var x = true
    if (z.length > 0) {
        var i = 0;
        for (i = 0; i < z.length; i++) {
            if (y.indexOf(z.substring(i, i + 1)) < 0) {
                x = false
                break;
            }
        }
    }
    return x;
}

function check() {
   
        if (!checkno(document.getElementById("textfield2").value)) {
            document.getElementById("textfield2").focus();
            document.getElementById("textfield2").value = "";
            rtn = false;
        }

    }

    function check1() {
        if (!checkno(document.getElementById("txtdiscount").value)) {
            document.getElementById("txtdiscount").focus();
            document.getElementById("txtdiscount").value = "";
            rtn = false;
        }
    }

