function checkElement(elementId) {
	var el = document.getElementById(elementId);
	var ret = (typeof(el) == 'object' && el != null) ? true : false;
    return ret;
}
function deleteFromNewsletter() {
    if(checkElement('ndel')) {
		var oEml = document.getElementById('ndel');
		oEml.value='del';	
	}
}
function changePrice(s,p) {
	var old_price
	if (s.options[s.selectedIndex].getAttribute('oldprice') != 0.00) {
		var old_price = '<span class="old-price" >'+s.options[s.selectedIndex].getAttribute('oldprice')+'</span><br />';
	} else {
		var old_price = '';		
	}
	if (s.options[s.selectedIndex].getAttribute('price') != 0.00) {
		p.innerHTML = old_price+s.options[s.selectedIndex].getAttribute('price')+' PLN';
	} else {
		p.innerHTML = '';		
	}
}
function changeLink(a) {
	a.href = a.href + self.document.formPSC.size.options[self.document.formPSC.size.selectedIndex].value;
}
function popup(o) {
	// open a new window with the location of the link's href
	window.open(o.href,'newwin','height=400,width=400,resizable,scrollbars');
	return false;
}
function popupmap(o) {
	// open a new window with the location of the link's href
	window.open(o.href,'newwinmap','height=500,width=500,scrollbars');
	return false;
}
function init() {
    if(checkElement('products')) {
		stripe('products', '#fff', '#ffc');
	} 
    if(checkElement('recomendations')) {
		stripe('recomendations', '#fff', '#ffc');
	} 
	if(checkElement('productsizecolor')) {
		stripe('productsizecolor', '#fff', '#ffc');
	} 
	if(checkElement('basketitems')) {
		stripe('basketitems', '#fff', '#ffc');
	} 
	if(checkElement('sizecomparisonchart')) {
		stripe('sizecomparisonchart', '#fff', '#ffc');
	}
    if(checkElement('news')) {
		stripe('news', '#ffc', '#fff');
	} 
	if(checkElement('varsizeprice') && checkElement('size')) {
		var p = document.getElementById('varsizeprice');
		var s = document.getElementById('size');
		changePrice(s,p);
		s.onchange=function(){changePrice(s,p);};
	}
	if(checkElement('lnkbaskettxt')) {		
		var atxt = document.getElementById('lnkbaskettxt');
		atxt.onclick=function(){changeLink(atxt);}		
	}
	if(checkElement('lnkbasketimg')) {		
		var aimg = document.getElementById('lnkbasketimg');
		aimg.onclick=function(){changeLink(aimg);}		
	}
	/*
	if(checkElement('lnk2bigpic')) {
		var lnk2bp = document.getElementById('lnk2bigpic');
		if(lnk2bp.getAttribute('target') != '') {
			lnk2bp.onclick=function(){return(popup(this));};
			//lnk2bp.onkeypress=function(){return(popup(this));};
		}
	}
	*/
	checkDelivery();
}
// if the browser can deal with DOM, call the function onload		
if(document.getElementById && document.createTextNode) {
	window.onload=init;
}

// raty żagiel

function team(url, width, height) {
 	var Win = window.open(url,"team",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,toolbar=no,top=100,left=200' );
}

function showHide(id) {

	obj = document.getElementById(id);
	obj.style.display = (obj.style.display == "block" ? "none" : "block");
}


function checkDelivery() {
	if(checkElement('zagiel')){
		for (i=0;i<document.form.delivery.length;i++){
		if (document.form.delivery[i].checked==true)
			if(document.form.delivery[i].value==5||document.form.delivery[i].value==6) {
				obj = document.getElementById('zagiel');
				obj.style.display = "block";
			} else {
				obj = document.getElementById('zagiel');
				obj.style.display = "none";
			}
		
		}
	}
}	

function nowe_okno() {
	window.open('http://www.zagiel.com.pl/kalkulator/jak_kupic.html', 'nowe_okno',	'width=600,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}



function validate_Zagiel() {
	obj = document.getElementById('zagiel');
	if (document.form.zgoda.checked==false&&obj.style.display == "block"){
		alert ("Zanim złożysz zamówienie, zapoznaj sie z procedurą udzielenia kredytu ratalnego eKredyt Żagiel.");
		return false;
	} else {
		return true;
	}
}

