function ajaxServerTime() {
	if (!document.getElementById) return false;
	if (!document.getElementById("dotdTime")) return false;
	var obj = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		obj = new XMLHttpRequest();
		if (obj.overrideMimeType) {
			obj.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (obj) {
	    obj.onreadystatechange = function() {
	        if (obj.readyState == 4) {
	            if (obj.status == 200) {	                
	                document.getElementById("dotdTime").innerHTML = obj.responseText;               
	            }
	        }
	    }
		var date = new Date();
		var timestamp = date.getTime();
		obj.open("GET", "ajaxTime.ashx?time=" + timestamp, true);
		obj.send(null);
	}
	setTimeout("ajaxServerTime()",1000);
}

function matchColumns() {
	if (!document.getElementById('homeIsFeatured')) { return false; alert('false'); }
	var divs, contDivs, maxHeight, maxHeight2, divHeight, d;
	divs = document.getElementsByTagName('div');
	contDivs = [];
	contDivs2 = [];
	maxHeight = 0;
	maxHeight2 = 0;
	for (var i = 0; i < divs.length; i++) {
		if (/\bbtmTop\b/.test(divs[i].className)) {
			d = divs[i];
			contDivs[contDivs.length] = d;
			if (d.offsetHeight) {
				divHeight = d.offsetHeight;
			} else if (d.style.pixelHeight) {
				divHeight = d.style.pixelHeight;
			}
			maxHeight = Math.max(maxHeight, divHeight);
		}
		if (/\bbtmBottom\b/.test(divs[i].className)) {
			d = divs[i];
			contDivs2[contDivs2.length] = d;
			if (d.offsetHeight) {
				divHeight = d.offsetHeight;
			} else if (d.style.pixelHeight) {
				divHeight = d.style.pixelHeight;
			}
			maxHeight2 = Math.max(maxHeight2, divHeight);
		}
	}
	for (var i = 0; i < contDivs.length; i++) {
		contDivs[i].style.height = maxHeight + "px";
	}
	for (var i = 0; i < contDivs2.length; i++) {
		contDivs2[i].style.height = maxHeight2 + "px";
	}
}

var WindowObject = null;
function imagepopup(image,w,h) {
	var strUrl = 'images/product/large/' + image + '.jpg';
	if (WindowObject == null || WindowObject.closed) {
		WindowObject = window.open(strUrl,'Popup9524','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+w+',height='+h+',left=0,top=0');
		WindowObject.focus();
		return true;
	} else {
		WindowObject = window.open(strUrl,'Popup9524','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+w+',height='+h+',left=0,top=0');
		WindowObject.resizeTo(w+6,h+49);
		WindowObject.focus();
		return true;
	}
}

function revMultiVariantForm(form, type) {
	if (!document.getElementById) return false;
	// type: addtocart=0, addtowish=1, addtogift=2
	if (type == 0) {
		document.getElementById("revIsWishList").value = 0;
		document.getElementById("revIsGiftRegistry").value = 0;
	} else if (type == 1) {
		document.getElementById("revIsWishList").value = 1;
		document.getElementById("revIsGiftRegistry").value = 0;
	} else if (type == 2) {
		document.getElementById("revIsWishList").value = 0;
		document.getElementById("revIsGiftRegistry").value = 1;
	}
	form.submit();
}

window.onload=function () {
	if(document.getElementsByTagName && document.getElementById) {
		matchColumns();
	
		if (document.getElementById('searchBox')) {
			document.getElementById('searchBox').focus();
		}
		
		if (document.getElementById("dotdTime")) {
			ajaxServerTime();
		}
	}
}
