function getXMLHTTP() {
    try { return new XMLHttpRequest(); } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
    alert("Your browser does not support AJAX.");
    return null;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function confirmAction(message) {
	if (typeof (message) == 'string') {
		return confirm(message);
	}
	return confirm("Are you sure?");
}

function verifyClick(message) {
	if (typeof (message) == 'string') {
		return confirm(message)
	}
	return confirm("Are you sure?")
}

function showAllReviews() {
	xmlHttp = getXMLHTTP();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			document.getElementById('reviews').innerHTML = xmlHttp.responseText;
		} else {
			document.getElementById('reviews').innerHTML = "<span class=\"loaderStyle\"><img src=/images/bigAjaxLoader.gif></span>";
		}
	}
	var id = document.productId.productId.value;
	xmlHttp.open("GET", "/ajax/cart.php?passed=showAllReviews&productId=" + id);
	xmlHttp.send(null);
}


function sizedPopup(linkname, windowname, ww, wh) {
	var href;
	if (!window.focus)
		return true;
	if (typeof (linkname) == 'string') {
		href = linkname
	} else {
		href = linkname.href
	}
	window.open(href, windowname, 'width=' + ww + ', height= ' + wh
		+ ' ,scrollbars=no, resizable=no');
	return false
}
function changeImage(imageName, newImage) {
	if (document.images) {
		document[imageName].src = newImage
	}
}
function updateSelectList(key, selected, selectObj, selectArray) {
	while (selectObj.hasChildNodes()) {
		selectObj.removeChild(selectObj.firstChild)
	}
	var catArray = selectArray[key];
	for (optionVal in catArray) {
		if (optionVal.length == 2) {
			newOption = document.createElement('OPTION');
			newOption.setAttribute('value', optionVal);
			newOption.appendChild(document.createTextNode(catArray[optionVal]));
			if (catArray[optionVal] == selected) {
				newOption.defaultSelected = true
			} else {
				newOption.defaultSelected = false
			}
			selectObj.appendChild(newOption)
		}
	}
}
var currentTabId = 'imageTab';
function showTab(tabId, top, left) {
	if (document.getElementById(tabId)) {
		hideTab(currentTabId);
		document.getElementById(tabId).style.display = 'block';
		document.getElementById(tabId).style.top = top;
		document.getElementById(tabId).style.left = left;
		currentTabId = tabId
	}
	return false
}
function hideTab(tabId) {
	if (document.getElementById(tabId)) {
		document.getElementById(tabId).style.display = 'none'
	}
	return false
}




