var xmlhttp;

// UPDATE PRODUCT INFO
function product_info(url){

popup('loading');

xmlhttp=products_GetXmlHttpObject();
xmlhttp.onreadystatechange=product_info_stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function product_info_stateChanged(){

				 if(xmlhttp.readyState==4){			 

				 xmlDoc=xmlhttp.responseXML;
				 document.getElementById("product_partno").innerHTML=xmlDoc.getElementsByTagName("product_partno")[0].childNodes[0].nodeValue;
				 document.getElementById("product_fitment").innerHTML=xmlDoc.getElementsByTagName("product_fitment")[0].childNodes[0].nodeValue;
				 document.getElementById("product_material").innerHTML=xmlDoc.getElementsByTagName("product_material")[0].childNodes[0].nodeValue;
				 document.getElementById("product_power").innerHTML=xmlDoc.getElementsByTagName("product_power")[0].childNodes[0].nodeValue;
				 document.getElementById("product_additional").innerHTML=xmlDoc.getElementsByTagName("product_additional")[0].childNodes[0].nodeValue;
				 document.getElementById("product_msrp").innerHTML=xmlDoc.getElementsByTagName("product_price")[0].childNodes[0].nodeValue;
				 document.getElementById("dealer_price").innerHTML=xmlDoc.getElementsByTagName("dealer_price")[0].childNodes[0].nodeValue;
				 document.getElementById("product_status").innerHTML=xmlDoc.getElementsByTagName("product_status")[0].childNodes[0].nodeValue;
				 document.getElementById("product_specification").innerHTML=xmlDoc.getElementsByTagName("product_specification")[0].childNodes[0].nodeValue;
				 popup('loading');

				 }

}
// END UPDATE PRODUCT INFO



// UPDATE PRODUCT TAB INFO
function products_info(url){

popup('loading');

xmlhttp=products_GetXmlHttpObject();
xmlhttp.onreadystatechange=products_info_stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function products_info_stateChanged(){

				 if(xmlhttp.readyState==4){

				 xmlDoc=xmlhttp.responseXML;
				 document.getElementById("products_info").innerHTML=xmlDoc.getElementsByTagName("products_info")[0].childNodes[0].nodeValue;
				 popup('loading');			 

				 }

}
// END UPDATE PRODUCT TAB INFO

// AJAX FUNCTIONS
function products_GetXmlHttpObject(){

	 // code for IE7+, Firefox, Chrome, Opera, Safari

	 if (window.XMLHttpRequest){

	 return new XMLHttpRequest();

	 }

	 // code for IE6, IE5

	 if (window.ActiveXObject){

	 return new ActiveXObject("Microsoft.XMLHTTP");

	 }

return null;

}
// END AJAX FUNCTIONS

// CALCULATE BLANKET SIZE

function blanket_size(popUpDivVar) {

	if (typeof window.innerWidth != 'undefined') {

		viewportheight = window.innerHeight;

	} else {

		viewportheight = document.documentElement.clientHeight;

	}

	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {

		blanket_height = viewportheight;

	} else {

		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {

			blanket_height = document.body.parentNode.clientHeight;

		} else {

			blanket_height = document.body.parentNode.scrollHeight;

		}

	}

	var blanket = document.getElementById('blanket');

	blanket.style.height = blanket_height + 'px';

}
// END CALCULATE BLANKET SIZE

// TOGGLE POPUPS ON/OFF

function toggle(div_id) {

	var el = document.getElementById(div_id);

	if ( el.style.display == 'none' ) {	el.style.display = 'block';}

	else {el.style.display = 'none';}

}

function popup(windowname) {

	blanket_size(windowname);

	toggle('blanket');

	toggle(windowname);		

}
// END TOGGLE POPUPS ON/OFF

// UPDATE PRODUCT ITEM COLOR

function itemcolor(product_list_item, maxitem) {

var i=1;

while (i<=maxitem)

  {

	var x = "product_list_item" + i;

	document.getElementById(x).style.backgroundColor = '#e0e0e0';

	document.getElementById(x).style.backgroundImage = 'none';

  i++;

  }



document.getElementById(product_list_item).style.backgroundColor = '#f3f3f3';
document.getElementById(product_list_item).style.backgroundImage = 'url(../../images/template/in_bg.gif)';
document.getElementById(product_list_item).style.backgroundPosition = 'top left';
document.getElementById(product_list_item).style.backgroundRepeat = 'no-repeat';

}

// END UPDATE PRODUCT ITEM COLOR

// UPDATE SHIPPING COLOR

function shippingcolor(ecart_shipping, maxitem) {

var i=1;

while (i<=maxitem)

  {

	var x = "ecart_shipping" + i;

	document.getElementById(x).style.backgroundColor = '#e0e0e0';

	document.getElementById(x).style.backgroundImage = 'none';

  i++;

  }


document.getElementById(ecart_shipping).style.backgroundColor = '#f3f3f3';
document.getElementById(ecart_shipping).style.backgroundImage = 'url(../../images/template/in_bg.gif)';
document.getElementById(ecart_shipping).style.backgroundPosition = 'top left';
document.getElementById(ecart_shipping).style.backgroundRepeat = 'no-repeat';

}
// END UPDATE SHIPPING COLOR

// UPDATE PRODUCT TAB COLOR

function tabcolor(tab) {

var i=1;

while (i<=3)

  {

	var x = "header_tab" + i;

	document.getElementById(x).style.color = '#860303';
	document.getElementById(x).style.height = '50px';
	document.getElementById(x).style.backgroundImage = 'url(http://www.teammfactory.com/images/template/tab-bg.gif)';
	document.getElementById(x).style.backgroundPosition = '0 0';
	document.getElementById(x).style.backgroundRepeat = 'repeat-x';
  i++;

  }

document.getElementById(tab).style.color = '#434343';
document.getElementById(tab).style.height = '53px';
document.getElementById(tab).style.backgroundColor = '#dedede';
document.getElementById(tab).style.backgroundImage = 'url(http://www.teammfactory.com/images/template/tab-hvr.gif)';
document.getElementById(tab).style.backgroundPosition = 'bottom center';
document.getElementById(tab).style.backgroundRepeat = 'no-repeat';

}
// END UPDATE PRODUCT TAB COLOR



