var divs = Array( 'left', 'right', 'mainbody' );
var divs_diff = Array( 0, 0, 191);
function setHeight() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
			_offsetY = window.pageYOffset;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.documentElement.clientHeight;
			_offsetY = document.documentElement.scrollTop;
		}
	}

	max_h = winH;
	for( i=0;i<divs.length;i++ ) {
		layer = document.getElementById(divs[i]);
		max_h = Math.max(layer.offsetHeight-divs_diff[i], max_h);
	}

	for( i=0;i<divs.length;i++ ) {
		layer = document.getElementById(divs[i]).style.height = max_h-divs_diff[i]+'px';
	}
}

function gotoProduct( x, form_id ) {
	var new_id = '';

	form = document.getElementById( form_id );

	if ( x.type == 'select-one') {
		form.action = x.options[x.selectedIndex].value;
	}

//	alert(form.action);
	form.submit();

}

function showprint( URL, Page ) {
	window.open( URL+'print.php?page='+Page,'printversion', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=700,left = 262,top = 134');
}

function gotoProduct( x, form_id ) {
	var new_id = '';

	form = document.getElementById( form_id );

	if ( x.type == 'select-one') {
		form.action = x.options[x.selectedIndex].value;
	}

//	alert(form.action);
	form.submit();

}

function goTo (page) {

	if (page != "" ) {
		document.location.href = page;
	}
	return false;
}

function setCartId() {
	if ( document.getElementById('color') ) {
		color = document.getElementById('color').value;
		product_id = document.getElementById('product_id').value;

		cartId = product_id+'_'+color;

		if ( document.getElementById('size') ) {
			size = document.getElementById('size').value;
			cartId += '_'+size;
		}


		document.getElementById('product_cart_id').value = cartId;
	}

	showProductNumber();
}

function expandLink( obj, field, name ) {
	setCartId();
	if ( !name )
		name = field;
	obj.href += '&'+name+'='+document.getElementById(field).value;
}

function showProductNumber() {
	pid = document.getElementById('product_cart_id').value;

	new Ajax.Request('?l1=webstore&l2=plug_webstore_cart&l3=showProductNumber&pid='+pid+'&print=1',
	  {
	    method:'get',
	    onSuccess: function(transport){
	      var response = transport.responseText || "no response text";
		  if ( response != "no response text" ) {
			  document.getElementById('product_number').value = response;
		  }
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });
}

function changeCalendar( year, month ) {
	new Ajax.Updater('calendar', '?l1=calendar&l2=plug_calendar&l3=showCalender&date='+year+'-'+month+'&ajax=1', { method: 'get' });
	return false;
}

function setIMGtop( img, height ) {
	img.style.paddingTop = (height-img.height)/2+'px';
}
