window.load = init();



function DetectFlash(){
  var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  
  // Check to see if the version meets the requirements for playback
  if (!hasReqestedVersion) {
  
    var pid = getVar('pid');
    if(pid == ''){
      window.location = "http://www.adobe.com/go/gntray_dl_getflashplayer";
    }
  }

}


function action(strAction)
   {
   document.location.href = strAction;
   }

function resizeFlash(height) {
 var header =  document.getElementById('header');
 if (height > 50) header.style.zIndex = 6;
 else  header.style.zIndex = '';
 //alert(menu.style.zIndex);
 var flashmenudiv = document.getElementById('flashmenu');
 flashmenudiv.style.height = height+'px';
 var flashobject = document.getElementById('flashmenuID');
 flashobject.style.height = height+'px';
}


function init(){
  //DetectFlash();
}

function getVar(name)
         {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
         }



var _pageID=0;
var _productID=0;
function ajax_ShowProductInfo(productID,pageID) {
 _pageID= pageID;
 _productID = productID;
 //get the productinformation (ajax/json)
 //get the product->linkedpage content ->content div
 makeRequest('/_ajax.php','?action=getproductinfo&productID='+_productID,ajax_ShowProductInfo_response)
}

function ajax_ShowProductInfo_response() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            var responseText = http_request.responseText;
            setAndExecute('product_details_container',responseText)
            makeRequest('/_ajax.php','?action=getcontentpagina&pid='+_pageID,ajax_ShowContentpage_response)
            }
         }
      }
function ajax_ShowContentpage_response() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            var responseText = http_request.responseText;
            setAndExecute('contentContainer',responseText)
            makeRequest('/_ajax.php','?action=getmaterialthumbs&productID='+_productID,ajax_ShowMaterialThumbs_response)
            }
         }
      }      
function ajax_ShowMaterialThumbs_response() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            var responseText = http_request.responseText;
            setAndExecute('thumbs_container',responseText)
         }
      }
}
function setAndExecute(divId, innerHTML){   
    var div = document.getElementById(divId);   
    div.innerHTML = innerHTML;   
    var x = div.getElementsByTagName("script");    
    for(var i=0;i<x.length;i++)   {       
        eval(x[i].text);   
    }
}

var http_request = false;
function makeRequest(url, parameters,onComplete) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = onComplete;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
}





/* PNG fix for IE6 */
if (typeof window.attachEvent != "undefined")
 { 
 window.attachEvent("onload", correctPNG);
 window.attachEvent("onload", alphaBackgrounds);
 }

function correctPNG() // correctly handle PNG "IMG Element" transparency in Win IE 5.5 or higher.
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i];
if (img.src)
{
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
}

function alphaBackgrounds() // correctly handle PNG "BACKGROUNDCOLOUR" transparency in Win IE 5.5 or higher.
{
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='crop')";
document.all[i].style.backgroundImage = "url('/images/1pixel.gif')";
}
}
}
}



