﻿// JavaScript Document

function newWindow ( url, w, h ) {
	t = ( screen.availHeight - h ) / 2;
	l = ( screen.availWidth - w ) / 2;
	w = w+10;
	h = h+10;
	winStats = 'toolbar=0,location=no,directories=no,menubar=no,scrollbars=0,status=0,resizable=0,width='+w+',height='+h+', left='+l+',top='+t;
	adWindow = window.open("","",winStats);
	adWindow.document.writeln("<body  topmargin=0 leftmargin=5  rightmargin=5 bottommargin=5 bgcolor=#FFFFFF><center><table height=100% border=0 cellspacing=0 cellpadding=0><tr><td align=center valign=middle><img src="+url+" border=0 vspace=5></td></tr></table></center></body></html>");
	//adWindow.document.writeln("<body topmargin=0 leftmargin=0 onclick='javascript:window.close()'><img onclick='javascript:window.close()'src="+url+" border=0></body>");
	adWindow.focus();
}

function newPrintWindow ( url, w, h ) {
	t = ( screen.availHeight - h ) / 2;
	l = ( screen.availWidth - w ) / 2;
	w = w+10;
	h = h+10;
	winStats = 'toolbar=0,location=no,directories=no,menubar=no,scrollbars=1,status=0,resizable=1,width='+w+',height='+h+', left='+l+',top='+t;
	adWindow = window.open("","",winStats);
	adWindow.document.location = url;
	adWindow.focus();
}

function toggle( targetId ){
  if (document.getElementById){
        target = document.getElementById( targetId );
           if (target.style.display == "none"){
              target.style.display = "";
           } else {
              target.style.display = "none";
           }
     }
}


function showImages() {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('preloaderGalerii').style.visibility = 'hidden';
		document.getElementById('listaMediow').style.visibility = 'visible';
	} else {
		if (document.layers) { // Netscape 4
			document.preloaderGalerii.visibility = 'hidden';
			document.listaMediow.visibility = 'visible'; 
		} else { // IE 4
			document.all.preloaderGalerii.style.visibility = 'hidden';
			document.all.listaMediow.style.visibility = 'visible'; 
		}
	} 
}


function onLink(id) {
document.getElementById('n'+id).style.textDecoration='underline';
document.getElementById('t'+id).style.textDecoration='underline';
document.getElementById('s'+id).style.border='1px solid #EAEAEA';
}
function offLink(id) {
document.getElementById('n'+id).style.textDecoration='none';
document.getElementById('t'+id).style.textDecoration='none';
document.getElementById('s'+id).style.border='1px solid #FFFFFF';      
}   

function toggleVisibility( targetId ) {
	if (document.getElementById){
      	target = document.getElementById( targetId );
       	if (target.style.display == "none"){
          	target.style.display = "";
       	} else {
          	target.style.display = "none";
       	}
   	}
}


function odswiezMetodeWysylki(formularz,nazwa_pola) {
	pole = document.getElementById("op");
	form = document.getElementById(formularz);
	document.zamowienie.op.value="uw";
	//pole.value = "uw";
	form.action="purchase.php";
	form.submit();
}

function addTradeAmountToInput(obj, tradeamount)
{
		input_field = jQuery(obj).parents(".productAmountPicker").parent().find(".cartAmountInput input:text");
		new_cart = parseFloat(input_field.val()) + parseFloat(tradeamount);
		input_field.val(new_cart.toFixed(2));
}
function rmTradeAmountToInput(obj, tradeamount)
{
		input_field = jQuery(obj).parents(".productAmountPicker").parent().find(".cartAmountInput input:text");
		if ((parseFloat(input_field.val()) > parseFloat(tradeamount))
			&& ((parseFloat(input_field.val()) - parseFloat(tradeamount)) > 0)
		) {
			new_cart = parseFloat(input_field.val()) - parseFloat(tradeamount);
			input_field.val(new_cart.toFixed(2));
		} else {
			input_field.val("0");
		}
}

function addToPriceQuery(obj)
{
	jQuery(obj).parent().find('.orderType').val('priceOffer');
	jQuery(obj).parents('form').submit();
}

function zmien_rozmiar_id(id_elementu, wartosc) {
	var rozmiar = new Array("11px", "12px", "13px");
//	var height = new Array("1.4em", "1.5em", "1.7em");
	for(i = 0; i < id_elementu.length; i++){
		var e = document.getElementById(id_elementu[i]);
		//window.alert(id_elementu[i]);
		e.style.fontSize = rozmiar[wartosc];
//		e.style.lineHeight = height[wartosc];
	}
}

	function setCoo(size){
    	document.cookie='rozmiar_czcionki='+size+'; path=/';
	}

	function getCookie(name) {
		var start=document.cookie.indexOf(name+"=");
		if(start==-1)
			return null;
		var len=start+name.length+1;
		var end=document.cookie.indexOf(";", len);
		if(end==-1)
			end=document.cookie.length;
		return document.cookie.substring(len, end)
	}

	function getCoo(tag){
		//window.alert("Welcome back");
		if(getCookie("rozmiar_czcionki"))
		{
			//window.alert("Welcome back, " + getCookie("rozmiar_czcionki"));
			//window.alert("Czcionka w "+tag+" powinna zmienic sie na "+getCookie("rozmiar_czcionki"));
			//zmien_rozmiar_tag(tag, 2);
			zmien_rozmiar_id(tag, getCookie("rozmiar_czcionki"));
		}
	}

var tag_name = new Array("content");
