function Menu(num) {
	var Tab1 =document.getElementById("Tab1");
	var Tab2 =document.getElementById("Tab2");
	var Tab3 =document.getElementById("Tab3");
	var Tab1Tag =document.getElementById("Tab1Tag");
	var Tab2Tag =document.getElementById("Tab2Tag");
	var Tab3Tag =document.getElementById("Tab3Tag");
	if (Tab1 != null) {
		Tab1.style.display="none";
		Tab1Tag.style.background='url(/img/product/TagBG2.gif) top center no-repeat';
	}
	if (Tab2 != null) {
		Tab2.style.display="none";
		Tab2Tag.style.background='url(/img/product/TagBG2.gif) top center no-repeat';
	}
	if (Tab3 != null) {
		Tab3.style.display="none";
		Tab3Tag.style.background='url(/img/product/TagBG2.gif) top center no-repeat';
	}
	var level1 = document.getElementById(num);
	var tag = document.getElementById(""+num+"Tag");
	tag.style.background='url(/img/product/TagBG1.gif) top center no-repeat';
	level1.style.display="block";
} 
function OpenMenu(num) {
	var level2 = document.getElementById(num);
	level2.style.display="block";
	if(navigator.appName == "Netscape"){
	var level1 = level2.parentNode.firstChild.firstChild;
	}else if(navigator.appName == "Microsoft Internet Explorer"){
	var level1 = level2.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild.firstChild;	
	}
	level1.style.color="#CC6600";
} 
function CloseMenu(num) {
	var level2 = document.getElementById(num);
	level2.style.display="none";
	if(navigator.appName == "Netscape"){
	var level1 = level2.parentNode.firstChild.firstChild;
	}else if(navigator.appName == "Microsoft Internet Explorer"){
	var level1 = level2.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild.firstChild;	
	}
	level1.style.color="#FFFFFF";
} 

function fieldText(num){
	var field = document.getElementById(num);
	if(field.value == 'Search'){
		field.value = "";
	}else if(field.value.length == 0){
		field.value = "Search";
	}
}

function loadPng(){
	DD_belatedPNG.fix('.iconImg');
	DD_belatedPNG.fix('#popupForm');
}

function colorSelect(colorID) {
	var colors=new Array("Red","Blue","Green","Black","Grey");
	var targetColor = colorID.slice(11);
	var select = "colorSelect";
	for (x in colors){
		if(targetColor == colors[x]){
		var node= document.getElementById(colorID);
		//document.write(node);
		node.innerHTML = '<img alt="" src="imgs/product/color/'+colorID.slice(11)+'Selected.png" id="colorSelect'+colorID.slice(11)+'" border="0" />';
		}else{
		var selects = select.concat(colors[x]);
		var node= document.getElementById(selects);
		node.innerHTML = '<img alt="" src="imgs/product/color/'+colors[x]+'.png" id="colorSelect'+colors[x]+'" border="0" />';
		}

	}
}

function getWindowScroll() {
    var T, L, W, H;            
    var browserLanguage= detectBrowserLanguage();
    if (browserLanguage.browser != 'Netscape') {
      T = document.documentElement.scrollTop;
      L = document.documentElement.scrollLeft;
      W = document.documentElement.scrollWidth;
      H = document.documentElement.scrollHeight;
    } 
    else {
      var w = window;
      with (w.document) {
        if (w.document.documentElement && documentElement.scrollTop) {
          T = documentElement.scrollTop;
          L = documentElement.scrollLeft;
        } else if (w.document.body) {
          T = body.scrollTop;
          L = body.scrollLeft;
        }
        if (w.innerWidth) {
          W = w.innerWidth;
          H = w.innerHeight;
        } else if (w.document.documentElement && documentElement.clientWidth) {
          W = documentElement.clientWidth;
          H = documentElement.clientHeight;
        } else {
          W = body.offsetWidth;
          H = body.offsetHeight
        }
      }
    }
	return { top: T, left: L, width: W, height: H };
}

var t;

function slideDown() {
	 var windowScroll = getWindowScroll();  
	 var level1 = document.getElementById('welcome');
	 var level1Nodes = level1.childNodes;
	 for (i=0;i<level1Nodes.length;i++){
			if(level1Nodes[i].nodeName == "DIV"){
				gTitleDiv.style.margin = windowScroll.top + "px auto";
			}
	 }
	 t=setTimeout("slideDown()",100);
}

function detectBrowserLanguage(){
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
return {browser: browser ,version: version};
}

function getPageSize() {          
    var windowWidth, windowHeight;
    var pageHeight, pageWidth;
	var browserLanguage= detectBrowserLanguage();
    if (browserLanguage.browser != 'Netscape') {
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;  
      pageWidth = document.documentElement.scrollWidth;
      pageHeight = document.documentElement.scrollHeight;   
    } 
    else {
      var xScroll, yScroll;
      if (window.innerHeight && window.scrollMaxY) {  
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
      } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
      } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
      }


      if (self.innerHeight) {  // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
      }  

      // for small pages with total height less then height of the viewport
      if(yScroll < windowHeight){
        pageHeight = windowHeight;
      } else { 
        pageHeight = yScroll;
      }

      // for small pages with total width less then width of the viewport
      if(xScroll < windowWidth){  
        pageWidth = windowWidth;
      } else {
        pageWidth = xScroll;
      }
    }             
    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
}

var r;
var countNum = 0;

function opacity(num){
	var div = document.getElementById(num);
	countNum = 1;
	if(countNum <=1){
		div.style.opacity = countNum;
		div.style.filter = 'alpha(opacity='+countNum*100+')';
	}
	r=setTimeout("opacity('"+num+"')",50);
}

function resetOpacity(){
	stopCount(r);
	countNum = 0;
	}

var gTitleDiv;

function openPopup(num) {
		var num = num;
		var popupDiv = document.getElementById(num);
		popupDiv.style.display="block";
		var titleDiv = popupDiv.childNodes;
		if(document.getElementById('product360view')){
		var product360view = document.getElementById('product360view');
		product360view.style.visibility='hidden';
		}
		if(navigator.appName == "Netscape"){
			if(titleDiv[1].nodeName == 'DIV'){
				titleDiv[1].style.display="block";
				gTitleDiv = titleDiv[1];
				var pageSize = getPageSize();
				popupDiv.style.height = pageSize.pageHeight + "px";
				/*opacity(num);*/
			}
		}else if(navigator.appName == "Microsoft Internet Explorer"){
				if(titleDiv[0].nodeName == 'DIV'){
				titleDiv[0].style.display="block";
				gTitleDiv = titleDiv[0];
				var pageSize = getPageSize();
				popupDiv.style.height = pageSize.pageHeight + "px";
				/*opacity(num);*/
			}
		}
}

function hiddenSelect(){
	document.all.select1.style.visibility="hidden";
	document.all.select2.style.visibility="hidden";
	document.all.select3.style.visibility="hidden";
}

var loaded;
function loadTestimonial(id)
{
    if(document.getElementById('TestimonialList'+id+'')!=null)
    {
	    var list = document.getElementById('TestimonialList'+id+'');
	    var listNode = list.childNodes;
	    var DivNode =new Array();
	    var y = 0;
	    var w = 0;
    	
	    for(y in listNode){
		    if(listNode[y].nodeName == 'DIV'){
			    DivNode[w] = listNode[y];
			    w = w + 1;
		    }
	    }
    	
	    var num = Math.random() *100;
	    num = Math.round(num);    
   	
    	if(DivNode.length >0)
    	{
		  while (num > DivNode.length -1)
		   {
    	      num = Math.random() *100;
			  num = Math.round(num);
		   }
		   if(num < 1)
	    {
		    num = 0;
	    }
    	
	    if(num == loaded){
		    num++;	
	    }
	    if(num==DivNode.length)
	    {
	        num=num-1;
	    }	    
	    if(DivNode[num].nodeName == 'DIV'){
	    DivNode[num].style.display="block";
	    }
	    loaded = num;	
    	}
	}
}


// Remove leading and trailing whitespace from a string
function trimWhitespace(string) {
	var newString  = '';
	var substring  = '';
	beginningFound = false;

	// copy characters over to a new string
	// retain whitespace characters if they are between other characters
	for (var i = 0; i < string.length; i++) {

		// copy non-whitespace characters
		if (string.charAt(i) != ' ' && string.charCodeAt(i) != 9) {

			// if the temporary string contains some whitespace characters, copy them first
			if (substring != '') {
				newString += substring;
				substring = '';
			}
			newString += string.charAt(i);
			if (beginningFound == false) beginningFound = true;
		}

		// hold whitespace characters in a temporary string if they follow a non-whitespace character
		else if (beginningFound == true) substring += string.charAt(i);
	}
	return newString;
}
