function printContents()
{
	iWidth = window.screen.width;
	iHeight = window.screen.height;
	wt = 640;
	ht = 480;
	lt = (iWidth - wt) / 2;
	tp = (iHeight - ht) / 2;
	window.open("print.php", '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,resizable=no,scrollbars=yes'); 
}

function preview(file, desc, width, height)
{
	if (desc == null) {
		desc = '';
	}
	var left = (screen.width - width) / 2;
	var top = (screen.height - height + 20) / 2;
	window.open("preview.php?file="+file+"&desc="+desc, "_preview_", "width="+width+",height="+height+",top="+top+",left="+left);
}

function photos(id,pos)
{
	iWidth = window.screen.width;
	iHeight = window.screen.height;
	wt = 740;
	ht = 700;
	lt = (iWidth - wt) / 2;
	tp = (iHeight - ht) / 2;
	window.open("photos.php?id="+id+"&pos="+pos, "tester", "width="+wt+",height="+ht+",top="+tp+",left="+lt);
}

var refSendToFriendWindow = null;

function sendToFriend(query) 
{
	iWidth = screen.width;
	iHeight = screen.height;
	ht = 420;
	wt = 455;
	lt = (iWidth - wt) / 2;
	tp = (iHeight - ht) / 2;
	
	if (refSendToFriendWindow == null || refSendToFriendWindow.closed)
		refSendToFriendWindow = window.open('sendtofriend.php?url_query='+query, '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,scrollbars=no');
	else
		refSendToFriendWindow.focus();
}


function showSizes()
{
	iWidth = window.screen.width;
	iHeight = window.screen.height;
	wt = 640;
	ht = 480;
	lt = (iWidth - wt) / 2;
	tp = (iHeight - ht) / 2;
	window.open("sizes.php", '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,resizable=no,scrollbars=yes'); 
}

var commentWin = 0;

function commentWindow() {
	if (commentWin == 0) {
		document.getElementById('commentForm').style.display = 'block';
		commentWin = 1;
	} else {
		document.getElementById('commentForm').style.display = 'none';
		commentWin = 0;
	}
}

var sendToFriendWin = 0;

function sendToFriendWindow() {
	if (sendToFriendWin == 0) {
		document.getElementById('sendtofriendForm').style.display = 'block';
		sendToFriendWin = 1;
	} else {
		document.getElementById('sendtofriendForm').style.display = 'none';
		sendToFriendWin = 0;
	}
}

function underline (obj) {
	obj.style.textDecoration='underline';
}
	
function nounderline (obj) {
	obj.style.textDecoration='none';
}

function updateCost (value) {
	var val = total + costs[value];
	document.getElementById('total').innerHTML = val.toFixed(2).replace('.',',') + '&nbsp;zł';
}

function updateCostByType(value) {

	country = document.getElementById("country").value;
	zone = map[country];

	if (value == 101) {
		var val = total + post[zone];
	}
	if (value == 102) {
		var val = total + courier[zone];
	}

	document.getElementById('total').innerHTML =  val.toFixed(2).replace('.',',') + '&nbsp;zł';
}

function updatePrices(country) {
	
	zone = map[country];

	document.getElementById('abroadpostcost').innerHTML = post[zone] + ',00&nbsp;zł';
	document.getElementById('abroadcouriercost').innerHTML = courier[zone] + ',00&nbsp;zł';

	if (document.getElementById('abroad_101').checked == true) {
		var val = total + post[zone];
	}
	if (document.getElementById('abroad_102').checked == true) {
		var val = total + courier[zone];
	}
	document.getElementById('total').innerHTML =  val.toFixed(2).replace('.',',') + '&nbsp;zł';
}

function showCountry(value, def) {
	if (value == true) {
	
		if (document.getElementById('ship_1'))
			document.getElementById('ship_1').disabled = true;
		if (document.getElementById('ship_2'))
			document.getElementById('ship_2').disabled = true;
		if (document.getElementById('ship_3'))
			document.getElementById('ship_3').disabled = true;
		if (document.getElementById('ship_4'))
			document.getElementById('ship_4').disabled = true;

		document.getElementById("country").style.visibility = "visible";
		document.getElementById("other").style.display = "block";

		country = document.getElementById("country").value;
		zone = map[country];

		document.getElementById('abroadpostcost').innerHTML = post[zone] + ',00&nbsp;zł';
		document.getElementById('abroadcouriercost').innerHTML = courier[zone] + ',00&nbsp;zł';

		if (document.getElementById('abroad_101').checked == false &&
			document.getElementById('abroad_102').checked == false) {
			document.getElementById('abroad_101').checked = true; 
		}

		if (document.getElementById('abroad_101').checked == true) {
			var val = total + post[zone];
		}
		if (document.getElementById('abroad_102').checked == true) {
			var val = total + courier[zone];
		}
		document.getElementById('total').innerHTML = val.toFixed(2).replace('.',',') + '&nbsp;zł';
	}
	else {
		if (document.getElementById('ship_1'))
			document.getElementById('ship_1').disabled = false;
		if (document.getElementById('ship_2'))
			document.getElementById('ship_2').disabled = false;
		if (document.getElementById('ship_3'))
			document.getElementById('ship_3').disabled = false;
		if (document.getElementById('ship_4'))
			document.getElementById('ship_4').disabled = false;

		document.getElementById("country").style.visibility = "hidden";
		document.getElementById("other").style.display = "none";

		document.getElementById("ship_" + def).checked = "checked";

		var val = total + costs[def];
		document.getElementById('total').innerHTML = val.toFixed(2).replace('.',',') + '&nbsp;zł';

	}
}

function updatePage() {
	
	if (document.getElementById) {	
		var right = document.getElementById("right");
		var centre = document.getElementById("subpage");
	} else if (document.all) {
		var right = document.all["right"];
		var centre = document.all["subpage"];
	}

	if (centre && right) {
		cH = centre.offsetHeight;
		rH = right.offsetHeight;

		if (rH > cH) {
			centre.style.height = rH + 'px';
		}
	}
}

function updateShippingCost(type) {

	document.getElementById("poczta").innerHTML = poczta + " (+"+post[type].toFixed(2).replace('.',',') + "&nbsp;zł)";
	document.getElementById("kurier").innerHTML = kurier + " (+"+courier[type].toFixed(2).replace('.',',') + "&nbsp;zł)";
}

function updateAvailability(value) {
	if (available[value] == 1) {
		document.getElementById("wysylka").style.display = 'block';
	}
	else {
		document.getElementById("wysylka").style.display = 'none';
	}
}

