function zmianaAliasu(alias,alias_staly){
	if(alias!=''){
		document.forms[0].action=alias;
	}else{
		document.forms[0].action=alias_staly;
	}
}
function przelicz(){
	//var ilosc = document.forms[0].elements.length;
	var ilosc = tablica_guzikow.length;
	var idguzika;
	var guzik;
	var suma = 0;
	var ilosc_t = 0;
	var cena_t = 0;
	for(var i=0;i<ilosc;i++){
		idguzika = "Produkty"+tablica_guzikow[i];
		guzik = document.getElementById(idguzika)
		if(guzik.type=="text" && guzik.value>0){
			ilosc_t=parseInt(guzik.value);
			cena_t=parseInt(tablica_cen[i]);
			suma=suma + ilosc_t*cena_t;
		}
		if(guzik.type=="hidden"){
			ilosc_t=parseInt(guzik.value);
			cena_t=parseInt(tablica_cen[i]);
			suma=suma + ilosc_t*cena_t;
		}
		if(guzik.type=="checkbox" && guzik.checked){
			ilosc_t=parseInt(guzik.value);
			cena_t=parseInt(tablica_cen[i]);
			suma=suma + ilosc_t*cena_t;
		}
		
	}
	suma=parseFloat(suma/100)+",00";
	var pole_suma=document.getElementById("cena_calkowita");
	pole_suma.innerHTML=suma;
	
}
function menu(thismenu){
	
	var idmenu = thismenu.id;
	$("#menuglowne ul li ul li").hide();
	$("#menuglowne ul li#"+idmenu+" ul li").show();
	
}
function menuzaznaczone(){
	
	
	$("#menuglowne ul li ul li").hide();
	$("#menuglowne ul li.childrenSelected ul li").show();
}
function filmyISL(film){
	var biezace_id = $("li a.odtwarzany").attr("id");
	if(biezace_id=="film_"+film)return void(0);
	
	$("li a.odtwarzany").removeClass();
	$("li a#film_"+film).addClass("odtwarzany");
	/*
	$("#centrum-isl-filmy-lewy").html("");
	$.ajax({
		  type: "POST",
		  url: "/lukasz.chmielewski/croogo-1.3/contacts/centrum_isl",
		  data: "film="+film,
		  success: function(msg){
			
		  	$("#centrum-isl-filmy-lewy").html(msg);
		  }
		});
	*/
}

function centrum_isl_email(){
	var email = $("#email").val();
	$.ajax({
		  type: "POST",
		  url: "/contacts/centrum_isl_email",
		  data: "email="+email,
		  success: function(msg){
			if(msg==1){
		  		$("#FormEmail").html("<div style='text-align:center;'>Dziękujemy za dodanie maila.</div>");
		  	}else{
		  		$("#email").css("color","red")
		  		$("#email").val("Wpisz poprawny adres Email.")
		  	}
		  }
		});
}
function wiecej_mniej(h4,idp){
	$("#"+idp).toggle('blind');
	var h4_tlo = h4.style.backgroundPosition;
	
	if(h4_tlo=="0px -6px"){
		h4.style.backgroundPosition = '0px 5px';
	}else{
		h4.style.backgroundPosition = '0px -6px';
	}
	
	
}
function domena(){
	var wartosc = $("#ContactDomenaEtransfer1Etransfer:checked").length;
	if(wartosc==1) $("#domena").html("@etransfer.pl")
	else $("#domena").html("@spolka.net")
}

function validate_email(email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   var address = email;
	   if(reg.test(address) == false) {
	      alert('Invalid Email Address');
	      return false;
	   }
}
function etransferZamowienie(){
	
	var nazwaKonta = getElementById("ContactNazwaKonta");
	var ReprezentantImie = getElementById("ContactReprezentantImie");
	var ReprezentantNazwisko = getElementById("ContactReprezentantNazwisko");
	var ReprezentantEmail = getElementById("ContactReprezentantEmail");
	var ReprezentantTelefon = getElementById("ContactReprezentantTelefon");
	validate_email(ReprezentantEmail.value);
	
	alert("aa");
	//document.forms[0].submit();
	//return true;
	return false;
	
}
function scrollY(Y){
	
	var xpos= document.documentElement.scrollLeft ;
	var ypos= document.documentElement.scrollTop;
	//alert(xpos+' '+ypos);
	if(ypos<Y){
		ypos=ypos+15;
		if(ypos>=Y){
			window.scrollTo(xpos,Y);
		}else{
			window.scrollTo(xpos,ypos);
			 setTimeout('scrollY('+Y+')',3);
		}
	}
	if(ypos>1100){
		ypos=ypos-5;
	}
	
	
}
//funkcja uzywana w portfolio
var zmiana = 0;
function teksty(DivId){
	if(zmiana==0){
		zmiana = 1;
		$(".portfoliotekst[id!='"+DivId+"']").fadeOut(300,function(){
			$("#"+DivId).delay(600).fadeIn(300,function(){
				zmiana = 0;
			});
			
		});
	}
}

	

$(document).ready(function() {

	$("#menuglowne ul li.hasChildren").mouseover(function(){
		menu(this)
	})
	
	$("#menuglowne ul li.hasChildren").mouseout(function(){
		menuzaznaczone()
	})
	
	$("#menuglowne ul li.childrenSelected").mouseover(function(){
		menu(this)
	})
	
})

$.fn.qtip.styles.cream2 = { // Last part is the name of the style
  	width: 250,
      padding: 5,
      fontWeight:'500',
      fontSize:'12px',
      tip: 'topLeft',
      name: 'cream' // Inherit the rest of the attributes from the preset dark style
}

$.fn.qtip.styles.cream3 = { // Last part is the name of the style
  	width: 250,
      padding: 5,
      fontWeight:'500',
      fontSize:'12px',
      tip: 'bottomMiddle',
      name: 'cream' // Inherit the rest of the attributes from the preset dark style
}

