function getId(objectId){if(document.all && !document.getElementById){return document.all(objectId)}else{return document.getElementById(objectId)}}

function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}

var t; // setTimeout var used in loadDataButWait()
var longDelay = 700;

// LOAD PRODUCT DATA IN CENTER PAGE (ajax) - also, LOAD SHOPPING CART DATA UPDATED
function loadData(phpLoader,data,eId){ 
    var xhr; 
	if(window.XMLHttpRequest){     // Object of the current windows 
		xhr = new XMLHttpRequest();     // Firefox, Safari, ...
	}else if(window.ActiveXObject){   // ActiveX version
		xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer 
	}
	xhr.onreadystatechange = function(){ // instructions to process the response
		if (xhr.readyState == 4){// Received, OK
			var myData = xhr.responseText;
			// show Cart and displayCart if not in index.php
			var myURL = window.location.href.indexOf("product_detail.php");
			getId(eId).innerHTML = myData;
			opacity(eId, 50, 100, 300);
			if(myURL!==-1){
				getId('Cart').style.display='block';
				getId(eId).style.visibility='visible';
				// update cart count in container (container will be visible if hide button is clicked)
				var cartCount = getId('cartCount').innerHTML;
				cartCount = parseInt(cartCount)+1;
				getId('cartCount').innerHTML = cartCount;
			}
			
			//if(changeDelay=='changeDelay'){longDelay = 1500;} // reset "longDelay" to 0 if data has loaded
		}else{
			opacity(eId, 100, 50, 0);
		}
	}
	xhr.open('GET', phpLoader+'?data='+data, true);
	xhr.send(null);
}
// SET TIMEOUT for thumbnails in inner rows, so that data is not loaded to quickly...
function loadDataButWait(phpLoader,data,eId,delay){
	t=setTimeout("loadData('"+phpLoader+"','"+data+"','"+eId+"')",delay);
}

/* FADE FUNCTIONS */
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

/*// SHOW-HIDE DROP-DOWN MENU FOR WHOLESALE
function hide(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode
	if (reltg== tg) return;
		getId('drop').className='hide';
}*/