﻿$(document).ready(
function() {
    LargeImage();
   
}
);


var xhr = false;

function createxhr() {
    var xhttp = false;
    if (window.XMLHttpRequest) {
        try {
            xhttp = new XMLHttpRequest;
        }
        catch (e) {
            alert("cannot create XMLHttpRequest object : ");
            return false;
        }
    }
    else {
        try {
            xhttp = new ActiveXObject("Microsoft.XMLHttp");
        }
        catch (e) {
            alert("cannot create XMLHttpRequest object");
            return false;
        }

    }
    return xhttp;

}





function JusttabClick(id) {

    $(document).ready(

    function() {



        var getID = id.id;

        if (getID == "Detail") {
            $("#DIV_Detail").slideDown(600);
            $("#DIV_Specs").hide();
            $(".btnSpecs").css({ 'background-color': '#E8EEF6','font-weight':'Normal' });
            $(".btnDetail").css({ 'background-color': '#B1C7E3', 'font-weight': 'bold' });

        }
        else {

            $("#DIV_Detail").hide();
            $("#DIV_Specs").slideDown(600);
            $(".btnSpecs").css({ 'background-color': '#B1C7E3', 'font-weight': 'bold' });
            $(".btnDetail").css({ 'background-color': '#E8EEF6', 'font-weight': 'Normal' });
        }

    }
   );
}
function divSwitch(id) {
    var getID = id;
    if (getID == "ddlSearch") {


        document.getElementById('ddlShow').style.display = 'block';
        document.getElementById('ddlblock').style.display = 'None';
        document.getElementById('btnpolystrapping').className = 'buttonDiv';
        document.getElementById('btnHillas').className = 'buttonDivActiv';
       
    }
    else if (getID == "other") {

    document.getElementById('ddlShow').style.display = 'None';
    document.getElementById('ddlblock').style.display = 'block';
    document.getElementById('btnpolystrapping').className = 'buttonDivActiv';
    document.getElementById('btnHillas').className = 'buttonDiv';
    }

}

function openwindow(ItemID, title) {
    var leftalign = screen.width - 500;
    var url = "GetThumbNail.aspx?Type=item&amp;image=" + ItemID + "&amp;Size=400&amp;site_Name=www.stretch-film.com"; 
    window.open(url, title, 'left='+leftalign+',top=20,width=500px,height=400px'); 
}

function selectIndex(searchText, siteID, siteName) {
    var ItemsPerPage = document.getElementById("ddlItemsperpage").value;
        var url = "SearchPage.aspx?SearchText=" + searchText + "&pageNum=1&SiteID=" + siteID + "&ItemsPerPage=" + ItemsPerPage + "&siteName=" + siteName;
        window.location = url;
    }

//////////////////////image magnify///////////////////////

    function LargeImage() {

        this.imagePreview = function() {
            /* CONFIG */

            xOffset = 250;
            yOffset = 0;

            // these 2 variable determine popup's distance from the cursor
            // you might want to adjust to get the right result

            /* END CONFIG */
            $("a.preview").hover(function(e) {
                this.t = this.title;
                this.title = "";
                var c = (this.t != "") ? "<br/>" + this.t : "";
                $("body").append("<p id='preview'><img src='" + this.href + "' alt='Image preview' />" + c + "</p>");
                $("#preview")
                //			.css("top", (e.pageY - xOffset) + "px")
                //			.css("left", (e.pageX + yOffset) + "px")
			.css("top", 100 + "px")
			.css("left", 420 + "px")
			.fadeIn("slow");
            },
	function() {
	    this.title = this.t;
	    $("#preview").remove();
	});
            $("a.preview").mousemove(function(e) {
                $("#preview")
                //			.css("top", (e.pageY - xOffset) + "px")
                //			.css("left", (e.pageX + yOffset) + "px")
			.css("top", 100 + "px")
			.css("left", 420 + "px")
			.fadeIn("slow");
            });
        };


        // starting the script on page load
        $(document).ready(function() {
            imagePreview();
        });
    }


    function searchText() {
        
        var sText = document.getElementById("txtSearch").value;

        var siteindex = document.getElementById("ddlSearch").selectedIndex;
        var siteID = document.getElementById("ddlSearch").options[siteindex].value;

       document.location = "Search.aspx?PageNo=1&SiteID="+siteID+"&SearchTerm="+sText;


   }

   function searchOneStore(getid, getText, treeLvl) {
    
       var id = getid.id;
       id = id + "_searchRegion";
       getText = getText.replace("$#", " ");
       
       //       $("#ajaxImage").html("<b>Searching...</b><br /><img src='Images/processing.gif' alt=''>");  +"&treeLvl="+treeLvl
       $.ajax({
       url: "searchResult.aspx?searchText=" + encodeURIComponent(getText) + "&treeLvl=" + treeLvl,
           cache: true,
           async: true,
           success: function(data) {
               $("body").css("cursor", "default");
               //$("#ajaxImage").html("");
               $("#" + id).html(data);
           }
       });
   }

//   function getPageNo(getsiteid, divIDPageNo, getParam, totalpages, siteDistinct) {
//       var c = 0;
//       var pageID = "";
//      
//       getParam = getParam.replace("$&", " ")
//      
//       xhr = createxhr();
//       if (xhr) {
//           document.getElementById(divIDPageNo).innerHTML = "<div style='width:100%;height:200px;padding-top:100px;;text-align:center;font-size:14px;font-weight:bold;'><lable style='width:50px; height:50px;border:solid 5px gray;'>Wait...</lable></div>";
//           document.body.style.cursor = 'wait';
//           xhr.onreadystatechange = function() {
//               if (xhr.readyState == 4) {
//                   if (xhr.status == 200) {
//                       document.body.style.cursor = 'default';
//                       document.getElementById("divIDPageNo").innerHTML = xhr.responseText;
//                   }
//               }
//           }

//           xhr.open("GET", "searchResult.aspx?searchText=" + encodeURIComponent(getParam);
//           xhr.send(null);
//       
//       }
//      }   
      
//       for (c = 0; c < totalpages; c++) {
//           pageID = "pageNo" + (c + 1) + "_" + siteDistinct+"TD";

//           document.getElementById(pageID).style.backgroundColor = 'White';
//           document.getElementById(getsiteid.id + "TD").style.color = 'Black';
//           
//          
//       }
//       document.getElementById(getsiteid.id + "TD").style.backgroundColor = '#EDD2BF';
//       document.getElementById(getsiteid.id + "TD").style.color = 'Red';
//       

//       document.getElementById(divIDPageNo).innerHTML = "<div style='width:100%;height:200px;padding-top:100px;;text-align:center;font-size:14px;font-weight:bold;'><lable style='width:50px; height:50px;border:solid 5px gray;'>Wait...</lable></div>";
//       $.ajax({
//       url: "searchResult.aspx?searchText=" + encodeURIComponent(getParam),
//           cache: true,
//           async: true,
//           success: function(data) {
//               $("body").css("cursor", "default");
//               //$("#ajaxImage").html("");
//               $("#" + divIDPageNo).html(data);
//           }
//       });



   function getPageNoForCategory(getsiteid, divIDPageNo, getParam, totalpages, siteDistinct) {
     
       var c = 0;
       var pageID = "";
       for (c = 0; c < totalpages; c++) {
           pageID = "pageNo" + (c + 1) + "_" + siteDistinct + "TD";

           document.getElementById(pageID).style.backgroundColor = 'White';
           document.getElementById(getsiteid.id + "TD").style.color = 'Black';


       }
       document.getElementById(getsiteid.id + "TD").style.backgroundColor = '#EDD2BF';
       document.getElementById(getsiteid.id + "TD").style.color = 'Red';

       document.getElementById(divIDPageNo).innerHTML = "<div style='width:100%;height:200px;padding-top:100px;;text-align:center;font-size:14px;font-weight:bold;'><lable style='width:50px; height:50px;border:solid 5px gray;'>Wait...</lable></div>";
       $.ajax({
       url: "searchResultForCategory.aspx?searchText=" + encodeURIComponent(getParam),
           cache: true,
           async: true,
           success: function(data) {
               $("body").css("cursor", "default");
               //$("#ajaxImage").html("");
               $("#" + divIDPageNo).html(data);
           }
       });
   }



   function getPageNo(getsiteid, divIDPageNo, getParam, totalpages, siteDistinct) {
       
       var c = 0;
       var pageID = "";
       var tdd = "";
       getParam = getParam.replace("$&", " ")

       for (c = 0; c < totalpages; c++) {
           pageID = "pageNo" + (c + 1) + "_" + siteDistinct + "TD";

           tdd = pageID = "pageNo" + (c + 1) + "_" + siteDistinct;
           document.getElementById(tdd).style.backgroundColor = 'White';
           document.getElementById(pageID).style.backgroundColor = 'White';
           document.getElementById(getsiteid.id + "TD").style.color = 'Black';
           document.getElementById(getsiteid.id).style.backgroundColor = 'White';


       }
//       document.getElementById(getsiteid.id + "TD").style.backgroundColor = '#EDD2BF';
       document.getElementById(getsiteid.id).style.backgroundColor = '#EDD2BF';
       document.getElementById(getsiteid.id + "TD").style.color = 'Red';


       document.getElementById(divIDPageNo).innerHTML = "<div style='width:100%;height:200px;padding-top:100px;;text-align:center;font-size:14px;font-weight:bold;'><lable style='width:50px; height:50px;border:solid 5px gray;'>Wait...</lable></div>";
       $.ajax({
           url: "searchResult.aspx?searchText=" + encodeURIComponent(getParam),
           cache: true,
           async: true,
           success: function(data) {
               $("body").css("cursor", "default");
               //$("#ajaxImage").html("");
               $("#" + divIDPageNo).html(data);
           }
       });
   }

