﻿function participant_select(id) {
	cena();
}

function participant_select2(){
	if($('participant').value!="")
	{
	var p=parseFloat($('participant').value)+1;
		if(($("symposium3").checked!=true)&&($("symposium4").checked!=true))
		{
		$("symposium"+$('participant').value).checked=true;	
		}		
		
	$("tutorial2").disabled=true;
	$("tutorial3").disabled=true;
		if($("tutorial").checked==true)
		{
			$("tutorial"+p).checked=true;
			$("tutorial"+p).disabled=false;			
		}
	}
	if(p==2)
	{		
		if($("symposium4").checked==true)
		{
		$("symposium"+(p+1)).checked=true;
		
		}
		$("symposium1").disabled=false;	
		$("symposium2").disabled=true;	
		$("symposium3").disabled=false;	
		$("symposium4").disabled=true;
		
		$("individual11").checked=true;
		$("individual21").checked=true;
		$("individual11").disabled=true;
		$("individual12").disabled=true;
		$("individual21").disabled=true;
		$("individual22").disabled=true;
	}
	if(p==3)
	{
		if($("symposium3").checked==true)
		{
		$("symposium"+(p+1)).checked=true;
		}
		$("symposium1").disabled=true;	
		$("symposium2").disabled=false;	
		$("symposium3").disabled=true;	
		$("symposium4").disabled=false;
		
		$("individual11").checked=true;
		$("individual21").checked=true;
		$("individual11").disabled=true;
		$("individual12").disabled=true;
		$("individual21").disabled=true;
		$("individual22").disabled=true;
	}
	
	if(!(($("symposium3").checked!=true)&&($("symposium4").checked!=true)))
	{
	individual_on_dey();
	}
	
	cena();
}

function individual_on_dey()
{
	$("individual11").disabled=false;
	$("individual12").disabled=false;
	$("individual21").disabled=false;
	$("individual22").disabled=false;	
	$("individual11").checked=false;
	$("individual21").checked=false;
	cena();
}

function individual_on_dey_off()
{
	$("individual11").disabled=true;
	$("individual12").disabled=true;
	$("individual21").disabled=true;
	$("individual22").disabled=true;
	$("individual11").checked=true;
	$("individual21").checked=true;
	cena();
}

function cena() {
	var pom=0;
	if($("symposium1").checked==true)
	{
		if(l_or_p==1)
		{
			pom=pom+1800;
		}
		else
		{
			pom=pom+2100;
		}
		
	}
	
	if($("symposium2").checked==true)
	{
		if(l_or_p==1)
		{
			pom=pom+1000;
		}
		else
		{
			pom=pom+1200;
		}
		
	}
	
	if($("symposium3").checked==true)
	{
		if(l_or_p==1)
		{
			pom=pom+1200;
		}
		else
		{
			pom=pom+1500;
		}
		if($("individual11").checked==true)
		{
			pom=pom+150;
		}
		if($("individual21").checked==true)
		{
			pom=pom+220;
		}
	}
	
	if($("symposium4").checked==true)
	{
		if(l_or_p==1)
		{
			pom=pom+600;
		}
		else
		{
			pom=pom+750;
		}
		if($("individual11").checked==true)
		{
			pom=pom+150;
		}
		if($("individual21").checked==true)
		{
			pom=pom+220;
		}
	}
	
	if($("individual31").checked==true)
	{
		pom=pom+70;
	}
	if($("individual41").checked==true)
	{
		pom=pom+200;
	}
	if($("individual51").checked==true)
	{
		pom=pom+250;
	}
	
	if($("accompanying").checked==true)
	{
		if($("acc1").checked==true)
		{
				pom=pom+500;	
		}
		
		if($("acc2").checked==true)
		{
			pom=pom+900;		
		}
	}
	
	
	if($("tutorial").checked==true)
	{		
		if($("tutorial2").checked==true)
		{
				pom=pom+250;	
		}
		
		if($("tutorial3").checked==true)
		{
			pom=pom+200;		
		}	
	}	
	
	
	$('total').value=pom+",00";
	$('total2').value=pom;
}


function onlydec(event,f)
{
if (event.srcElement) {kc = event.keyCode;} else {kc = event.which;}
if ((kc < 47 || kc > 57 ) && kc != 8 && kc != 0) return false;

return true;

}


function BE(ktory)
{
		if(ktory!=1)
		{
			$("be6").checked="checked";
			$("be1").checked=false;
		}
		else
		{
			$('be7').value="";
		}
	
}

function hid(ktory)
{
	if(ktory==1)
	{
		$("participant2").disabled=false;
		$("acc1").disabled=false;
		$("acc2").disabled=false;
	}
	else
	{
		$("participant2").disabled=true;
		$("participant2").value="";
		$("acc1").disabled=true;
		$("acc2").disabled=true;
		$("acc1").checked=false;
		$("acc2").checked=false;
	}
	cena();
}

function hid2(ktory)
{
	if(ktory==1)
	{	
		if($('participant').value!="")
		{
		var p=parseFloat($('participant').value)+1;
		if(($("symposium3").checked!=true)&&($("symposium4").checked!=true))
		{
		$("symposium"+$('participant').value).checked=true;
		}
		$("tutorial2").disabled=true;
		$("tutorial3").disabled=true;
			if($("tutorial").checked==true)
			{
				$("tutorial"+p).checked=true;
				$("tutorial"+p).disabled=false;
			}
		}		
		if(p==2)
		{
			$("symposium1").disabled=false;	
			$("symposium2").disabled=true;	
			$("symposium3").disabled=false;	
			$("symposium4").disabled=true;	
		}
		if(p==3)
		{
			$("symposium1").disabled=true;	
			$("symposium2").disabled=false;	
			$("symposium3").disabled=true;	
			$("symposium4").disabled=false;	

		}
	}
	else
	{	
			$("tutorial2").checked=false;
			$("tutorial3").checked=false;
			$("tutorial2").disabled=true;
			$("tutorial3").disabled=true;
			


	}
		
	if(($('participant').value!="")&&($("tutorial").checked==true))
	{
	var p=parseFloat($('participant').value)+1;
		if(($("symposium3").checked!=true)&&($("symposium4").checked!=true))
		{
		$("symposium"+$('participant').value).checked=true;
		}
	$("tutorial"+p).checked=true;
	}
	cena();
}

var color="#FFA73D"; //#FFA73D
var bg_n="none";

function clear_bg()
{
$("sname").style.background=bg_n;
$("fname").style.background=bg_n;
$("badge").style.background=bg_n;
$("badge2").style.background=bg_n;
$("mail").style.background=bg_n;
$("phone").style.background=bg_n;
$("nationality").style.background=bg_n;
$("addres_type").style.background=bg_n;
$("street").style.background=bg_n;
$("street_number").style.background=bg_n;
$("address_complement").style.background=bg_n;
$("city").style.background=bg_n;
$("state").style.background=bg_n;
$("zipcode").style.background=bg_n;
$("country").style.background=bg_n;
$("participant").style.background=bg_n;
$("address_complement").style.background=bg_n;
$("er1").style.background=bg_n;
$("er2").style.background=bg_n;
$("ac_bg").style.background=bg_n;
$("acc1").style.background=bg_n;
$("acc2").style.background=bg_n;
$("participant2").style.background=bg_n;
$("card_bg").style.background=bg_n;
$("symposium_bg1").style.background=bg_n;
$("symposium_bg2").style.background=bg_n;
$("symposium_bg3").style.background=bg_n;
$("symposium_bg4").style.background=bg_n;
$("hid1").style.background=bg_n;
$("hid2").style.background=bg_n;
$("hid3").style.background=bg_n;
$("hd_bg").style.background="#E2EBEE";
}

function sprawdzenie() {
	
	var h=true;
	clear_bg();
	
	var ma="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
	var erm=new RegExp(ma);
	var xxx=$("mail").value;
	
	if($("sname").value=="")
	{
		alert("You must fill in field 'Full Name'");h=false;
		$("sname").style.background=color;
	}	
	else if($("fname").value=="")
	{
		alert("You must fill in field 'Full Name'");h=false;
		$("fname").style.background=color;
	}	
	else if(($("badge").value=="")||($("badge2").value==""))
	{
		alert("You must fill in field 'Name on Badge'");h=false;
		$("badge").style.background=color;
		$("badge2").style.background=color;
	}
	
	else if($("mail").value=="")
	{
		alert("You must fill in field 'E-mail'");h=false;	
		$("mail").style.background=color;
	}	
	
	
	else if(!erm.test(xxx))
	{
		alert("You must enter a valid E-mail");h=false;	
		$("mail").style.background=color;
	}	
	
	else if($("phone").value=="")
	{
		alert("You must fill in field 'Phone'");h=false;
		$("phone").style.background=color;
	}		
	
	else if($("nationality").value=="")
	{
		alert("You must select in field 'Nationality'");h=false;
		$("nationality").style.background=color;
	}
	
	else if($("addres_type").value=="")
	{
		alert("You must select in field 'Address Type'");h=false;
		$("addres_type").style.background=color;
	}	
	else if($("street").value=="")
	{		
		alert("You must fill in field 'Name (street, avenue or other)'");h=false;
		$("street").style.background=color;
	}	
	
	else if($("street_number").value=="")
	{
		alert("You must fill in field 'Number'");h=false;
		$("street_number").style.background=color;
	}		
	
	else if($("address_complement").value=="")
	{
		alert("You must fill in field 'Address Complement'");h=false;
		$("address_complement").style.background=color;
	}	
	
	else if($("city").value=="")
	{
		alert("You must fill in field 'City/Town'");h=false;
		$("city").style.background=color;
	}	
	
	else if($("state").value=="")
	{
		alert("You must fill in field 'State/Province/Region'");h=false;
		$("state").style.background=color;
	}	
	
	
	else if($("zipcode").value=="")
	{
		alert("You must fill in field 'ZipCode'");h=false;
		$("zipcode").style.background=color;
	}
	else if($("country").value=="")
	{
		alert("You must fill in field 'Country'");h=false;
		$("country").style.background=color;
	}
	
	else if($("participant").value=="")
	{
		alert("You must select in field 'Participant'");h=false;
		$("participant").style.background=color;
	}
		
	
	else if($("address_complement").value=="")
	{
		alert("You must fill in field 'Affiliation'");h=false;
		$("address_complement").style.background=color;
	}	
	
	else if(($("be1").checked!=true)&&($("be2").checked!=true)&&($("be3").checked!=true)
	&&($("be4").checked!=true)&&($("be5").checked!=true)&&($("be6").checked!=true))
	{
		alert("You must select in field 'Business' or 'Education/Research'");h=false;	
		$("er1").style.background=color;
		$("er2").style.background=color;
	}
	
	else if(($("be6").checked==true)&&($("be7").value==""))
			{
				alert("You must select in field 'Business' or 'Education/Research'");h=false;	
				$("er1").style.background=color;
				$("er2").style.background=color;
			}
	
	else if(($("accompanying").checked!=true)&&($("accompanying2").checked!=true))
	{
		alert("You must select in field 'Accompanying person'");h=false;
		$("ac_bg").style.background=color;
	}
	else 
	
		if (($("accompanying").checked==true)&&($("acc1").checked!=true)&&($("acc2").checked!=true))
		{
			alert("You must select in field 'Accompanying persons'");h=false;
			$("hid1").style.background=color;			
		}
		
		else
		{
			if(($("accompanying").checked==true)&&($("participant2").value==""))
			{
				alert("You must fill in field 'Name and surname of accompanying person'");h=false;
				$("ac_bg").style.background=color;
			}
		}
	if(h)
	{
		if(($("card1").checked!=true)&&($("card2").checked!=true))
		{		
			alert("You must select in field 'Payment Form'");h=false;
			$("card_bg").style.background=color;
		}
		
		else if(($("symposium1").checked!=true)&&($("symposium2").checked!=true)&&($("symposium3").checked!=true)&&($("symposium4").checked!=true))
		{		
			alert("You must select in field 'Symposium Fees'");h=false;
			$("symposium_bg1").style.background=color;
			$("symposium_bg2").style.background=color;
			$("symposium_bg3").style.background=color;	
			$("symposium_bg4").style.background=color;
		}
		
		else if(($("tutorial").checked!=true)&&($("tutorial1").checked!=true))
		{		
			$("hd_bg").style.background=color;
			alert("You must select in field 'Tutorial Fees (optional - if no Tutorial) '");h=false;
		}
		
		else if(($("tutorial").checked==true)&&($("tutorial2").checked!=true)&&($("tutorial3").checked!=true)&&($("tutorial4").checked!=true))
		{	
			$("hid2").style.background=color;
			alert("You must select in field 'Tutorial Fees (optional - if no Tutorial) '");h=false;
		}else if( (($("individual11").checked!=true)&&($("individual12").checked!=true)) ||(($("individual21").checked!=true)&&($("individual22").checked!=true)) 
				|| (($("individual31").checked!=true)&&($("individual32").checked!=true))||(($("individual41").checked!=true)&&($("individual42").checked!=true))
				|| (($("individual51").checked!=true)&&($("individual52").checked!=true))) 
		{
			$("hid3").style.background=color;
			alert("You must select in field 'Individual prices for'");h=false;
			//hid3
		}	
	}
	
	return h;	
}
