$(document).ready(function() {
	$('#tab-about').hover(function() { $('#tab-about ul').removeClass('sHide'); $('#tab-about ul').addClass('sShow'); $('#tab-about span').addClass('hoverTab'); }, function() { $('#tab-about ul').addClass('sHide'); $('#tab-about ul').removeClass('sShow'); $('#tab-about span').removeClass('hoverTab'); });
	$('#tab-info').hover(function() { $('#tab-info ul').removeClass('sHide'); $('#tab-info ul').addClass('sShow'); $('#tab-info span').addClass('hoverTab'); }, function() { $('#tab-info ul').addClass('sHide'); $('#tab-info ul').removeClass('sShow'); $('#tab-info span').removeClass('hoverTab'); });
	$('#tab-contact').hover(function() { $('#tab-contact ul').removeClass('sHide'); $('#tab-contact ul').addClass('sShow'); $('#tab-contact span').addClass('hoverTab'); }, function() { $('#tab-contact ul').addClass('sHide'); $('#tab-contact ul').removeClass('sShow');	$('#tab-contact span').removeClass('hoverTab');	});
});

function $ajax(id){
	return document.getElementById(id);
}

function loadPage(){
	if($ajax("gototill")){
		$ajax("gototill").onclick = function(){
			return window.location.href = "kasa.html";
		}
	}
	if($ajax("gotocf")){
		$ajax("gotocf").onclick = function(){
			return window.location.href = "formularz-kredytowy.html";
		}
	}
	if($ajax("gotobasket")){
		$ajax("gotobasket").onclick = function(){
			return window.location.href = "moj-koszyk.html";
		}
	}
	if($ajax("priceproducts")){
		$ajax("priceproducts").onclick = function(){
			var hendle = $ajax("configuratorform");
			var selects = hendle.getElementsByTagName("select");
			var id = "";
			for(x=0;x<selects.length;x++){
				id = id + selects[x].value + ".";
			}
			advAJAX.get({
			    url: "modules/getprices.php?id=" + id,
			    onInitialization : function(obj) { 
					$ajax("viewprice").style.visibility = "visible";
					$ajax("viewprice").innerHTML = "Wyliczam sumę ..."; 
				},
				onSuccess : function(obj) { $ajax("viewprice").innerHTML = "Cena brutto skonfigurowanego zestawu: <strong>" + obj.responseText + " zł</strong> z VAT."; }
			});
		}
	}
	if($ajax("emailproducts")){
		$ajax("emailproducts").onclick = function(){
			if($ajax("email").value){
				var hendle = $ajax("configuratorform");
				var selects = hendle.getElementsByTagName("select");
				var id = "";
				for(x=0;x<selects.length;x++){
					id = id + selects[x].value + ".";
				}
				advAJAX.get({
				    url: "modules/sendprices.php?id=" + id + "&email=" + $ajax("email").value,
				    onInitialization : function(obj) { 
						$ajax("viewprice").style.visibility = "visible";
						$ajax("viewprice").innerHTML = "Wysyłam wycenę na adres <strong>" + $ajax("email").value + "</strong> ..."; 
					},
					onSuccess : function(obj) { $ajax("viewprice").innerHTML = "Wycena została pomyślnie wysłana na adres <strong>" + $ajax("email").value + "</strong>."; $ajax("email").value = "" }
				});
			}
			else {
				$ajax("viewprice").style.visibility = "visible";
				$ajax("viewprice").innerHTML = "Należy podać poprawny adres email, na który ma zostać wysłane zestawienie.";
			}
		}
	}
	if($ajax("printwindow")){
		$ajax("printwindow").onclick = function(){
			return window.print();
		}
	}
}

function changeProduct(kind,id){
	var number = $ajax("number_"+id).value;
	if(kind == 1)number--;
	if(kind == 2)number++;
	if(number <= 0)number = 0;
	$ajax("number_"+id).value = number;
}
