//scroll_banner_con
var prodInfo = getHTTPObject(); // We create the HTTP Object
var prodDis = getHTTPObject();
var site_url = window.location.protocol+"//"+window.location.hostname+"/";

var prodImageDisplayContent = getHTTPObject();
var prodImage_src="";
var timeDisplay = "";
function process_imageDisplay(product_id)
{
  var imageContent = document.getElementById('mainCon_productDetail');

             if(prodImageDisplayContent.readyState == 4)
                {
                         document.getElementById('image_display_part').src="";
                         document.getElementById('detailImage_loader').style.display='none';

                   if(prodImageDisplayContent.status=='200' || prodImageDisplayContent.status==200 )
                      {

                         var dataImages =  prodImageDisplayContent.responseText.split('----');


                         imageContent.style.height = dataImages[2];
                         imageContent.style.width =dataImages[1];
                         prodImage_src = dataImages[0];

                         document.getElementById('image_display_part').style.border="1px solid black";
                         document.getElementById('image_display_part').src=prodImage_src;

                        timeDisplay = setTimeout("DelayImageDisplay()",1000);


                      }
               }
}

function DelayImageDisplay()
{
  clearTimeout(timeDisplay);

   document.getElementById('mainCon_productDetail').style.background="#999999";
   document.getElementById('nav_large_image_con').style.display="block";
   document.getElementById('image_display_part').style.marginTop='0px';
}

 function getProductImageDisplay(product_id)
    {

        document.getElementById('image_display_part').src=site_url+'images/loading-bar-black.gif';
        document.getElementById('image_display_part').style.marginTop='120px';

        prodImageDisplayContent.open("GET",site_url+"includes/getImage_info.php?prod_id="+product_id, true);
        prodImageDisplayContent.onreadystatechange = process_imageDisplay;
        prodImageDisplayContent.send(null);

    }

/* ----------------------------------------------------------------------------------  AJAX SIDE */
       function process_product_con()
          {
             if(prodInfo.readyState == 4)
                {
                   if(prodInfo.status==200)
                      {
                        var datas = prodInfo.responseText.split('----');

                        document.getElementById('product_detail_con').innerHTML = datas[0];


                        if(datas[1]==0 || datas[1]=='0')
                            {
                              getDiscountData();
                            }

                      }
                   else
                      {
                          var container = document.getElementById('product_discount');
                          container.innerHTML = "<div style='padding-top: 120px;'><img src='images/loading-bar-black.gif'/> </div> <div style='margin-top: -5px; color: #ffffff'>Data Retrieving</div>";
                          var discountcon =  document.getElementById('product_discount');
                          discountcon.innerHTML = "<div style='padding-top: 15px;'><img src='images/loading-bar-black.gif'/> </div> <div style='margin-top: -5px;  color: #ffffff; padding-bottom: 30px'>Data Retrieving and Calculating </div>";
                      }
               }
           }
       function process_discount_con()
          {
             if(prodDis.readyState == 4)
                {
                   if(prodDis.status==200)
                      {
                        document.getElementById('product_discount').innerHTML = prodDis.responseText;
                      }
                   else
                     {
                        alert("Discount Sytem got an error");
                     }
               }

           }

        function getProductData(product_id)
          {
            prodInfo.open("GET",site_url+"includes/getProductDetail_info.php?prod_id="+product_id, true);
            prodInfo.onreadystatechange = process_product_con;
            prodInfo.send(null);
          }

        function getDiscountData()
          {
            prodDis.open("GET",site_url+"includes/getDiscount_info.php", true);
            prodDis.onreadystatechange = process_discount_con;
            prodDis.send(null);
          }

function getHTTPObject()
 {
  var xmlhttp;

  if(window.XMLHttpRequest){  xmlhttp = new XMLHttpRequest();  }
  else
     if (window.ActiveXObject)
           {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 if (!xmlhttp){ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
           }
  return xmlhttp;
}


