	
	var ustawiono=false;
	
	function setPayment(id,name)
	{
		document.getElementById('bankName').innerHTML=name; 
	   	document.getElementById('paymenttype'+id).checked=true;
		document.getElementById('bankNameBox').style.visibility='visible';
		
		ustawiono=true;
	}

	function what2validate(id)
	{
		if(id == 1 || id == 2) {
			validateUser();
		} else {
			validateFirm();
		}
	}

	function validatePayment()
	{
		if(ustawiono==true) {
			return true;
		} else {
			alert("Proszę wybrać rodzaj przelewu elektronicznego");
			return false;	
		}
	}

	function checkCardNumberLength(number)
	{
		if (number.length != 10){
			alert("Podany numer jest za krótki.\nNumer karty składa się z 10 cyfr.");
			return false;
		} else {
			return true;
		}
	}
	
	function setCardPrice(cardType,cardPrice,selectedCardType,setValueID) // jako parametry przekazywane sa Array'e
	{
		var val;
		for(var i=0;i<cardType.length;i++)
			if(cardType[i]==selectedCardType)
				val=cardPrice[i];
		
		if (selectedCardType == 'prywatna')
		{
			document.getElementById('nameInCard_firstName').style.display = "inline";
			document.getElementById('nameInCard_lastName').style.display = "inline";
			document.getElementById('nameInCard_firmName').style.display = "none";
			
			document.getElementById('invoiceTable_header').style.display = "none";
			document.getElementById('invoiceTable_content').style.display = "none";
			
			var inv=document.getElementById('invoice');
			for(var i=0;i<inv.length;i++)
				if(inv.options[i].value == '1')
					inv.options[i].selected=true;
		}
		
		if (selectedCardType == 'firmowa')
		{
			document.getElementById('nameInCard_firstName').style.display = "none";
			document.getElementById('nameInCard_lastName').style.display = "none";
			document.getElementById('nameInCard_firmName').style.display = "inline";
			
			document.getElementById('invoiceTable_header').style.display = "block";
			document.getElementById('invoiceTable_content').style.display = "block";
			
			var inv=document.getElementById('invoice');
			for(var i=0;i<inv.length;i++)
				if(inv.options[i].value == '3')
					inv.options[i].selected=true;
		}
			
		document.getElementById(setValueID).innerHTML=val;
		document.getElementById('priceName_after').style.display='block';
	}
	
	function invoiceOption(layer)
	{
		if ( layer == '1' || layer == '2' )
		{
			document.getElementById('invoiceTable_header').style.display = "none";
			document.getElementById('invoiceTable_content').style.display = "none";
		}
	
		if ( layer == '3' )
		{
			document.getElementById('invoiceTable_header').style.display = "block";
			document.getElementById('invoiceTable_content').style.display = "block";
		}
	}

	function showPromotion(id)
	{
		var moje = document.getElementById(id).style;
		moje.display = (moje.display == "block" ? "none" : "block");
	}



	function isArray ( arr )
	{
		if( "undefined" == typeof arr[0] )
			return '0';
		else
			return '1';
	}

	function MoreOptions ( openLayer, radioOption )
	{
		if ( isArray ( openLayer ) == '0' ) {
			var showMeOption = document.getElementById(openLayer).style;
			showMeOption.display = radioOption;
		} else {
			for ( var j = 0; j < openLayer.length; j++ ) {
				var showMeOption = document.getElementById(openLayer[j]).style;
				showMeOption.display = radioOption;
			}
		}
	}

	function ColorText ( id, openLayer )
	{
		getOption = document.getElementById(id).style;
		getOption.color = '#FF0000';

		if ( isArray ( openLayer ) == '0' ) {
			document.getElementById(openLayer).style.color = '#000000';
		} else {
			for ( var j = 0; j < openLayer.length; j++ ) {
				var showMeOption = document.getElementById(openLayer[j]).style;
				showMeOption.color = '#000000';
			}
		}
	}

	function checkNumeric(objName,minval, maxval,comma,period,hyphen)
	{
		var numberfield = objName;
		if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
		{
			numberfield.select();
			numberfield.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function chkNumeric(objName,minval,maxval,comma,period,hyphen)
	{
	
		var checkOK = "0123456789" + comma + period + hyphen;
		var checkStr = objName;
		var allValid = true;
		var decPoints = 0;
		var allNum = "";
		
		for (i = 0;  i < checkStr.value.length;  i++)
		{
			ch = checkStr.value.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
					
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		
		if (ch != ",")
			allNum += ch;
		}
		
		if (!allValid)
		{
			alertsay = "Prosimy wpisywac tylko cyfry \""
			alertsay = alertsay + checkOK + "\" w polu \"" + checkStr.name + "\""
			alert(alertsay);
			return (false);
		}
	
		// set the minimum and maximum
		var chkVal = allNum;
		var prsVal = parseInt(allNum);
		if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
		{
			alertsay = "Podana cyfra musi byc wieksza badz "
			alertsay = alertsay + "równa \"" + minval + "\" i mniejsza badz "
			alertsay = alertsay + "równa \"" + maxval + "\" w polu \"" + checkStr.name + "\""
			alert(alertsay);
			return (false);
		}
	}


	function clicked ( checkThis )
	{
		if ( checkThis == 'noclegi_rabat' ) {
			for (i=0;i<document.poll.noclegi_rabat.length;i++)
			{
				 if ( document.poll.noclegi_rabat[i].value = "other" ) {
					  document.poll.noclegi_rabat[i].checked = true;
				 }
			}
		} else if ( checkThis == 'restauracja_rabat' ) {
			for (i=0;i<document.poll.restauracja_rabat.length;i++)
			{
				 if ( document.poll.restauracja_rabat[i].value = "other" ) {
					  document.poll.restauracja_rabat[i].checked = true;
				 }
			}
		} else if ( checkThis == 'restauracja_rabat_calkowity' ) {
			for (i=0;i<document.poll.restauracja_rabat_calkowity.length;i++)
			{
				 if ( document.poll.restauracja_rabat_calkowity[i].value = "other" ) {
					  document.poll.restauracja_rabat_calkowity[i].checked = true;
				 }
			}
		}
	}


	function ShowGallery ( hotelID, HotelName, PhotoID )
	{
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open('gallery.html?hotel_id=" + hotelID + "&hotel_name=" + HotelName + "&photoID=" + PhotoID + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=670,height=560,left=65,top=100');");
	}
	
	
	function clicked ( checkThis )
	{
		if ( checkThis == 'noclegi_rabat' ) {
			for (i=0;i<document.poll.noclegi_rabat.length;i++)
			{
				 if ( document.poll.noclegi_rabat[i].value = "other" ) {
					  document.poll.noclegi_rabat[i].checked = true;
				 }
			}
		} else if ( checkThis == 'restauracja_rabat' ) {
			for (i=0;i<document.poll.restauracja_rabat.length;i++)
			{
				 if ( document.poll.restauracja_rabat[i].value = "other" ) {
					  document.poll.restauracja_rabat[i].checked = true;
				 }
			}
		} else if ( checkThis == 'restauracja_rabat_calkowity' ) {
			for (i=0;i<document.poll.restauracja_rabat_calkowity.length;i++)
			{
				 if ( document.poll.restauracja_rabat_calkowity[i].value = "other" ) {
					  document.poll.restauracja_rabat_calkowity[i].checked = true;
				 }
			}
		}
	}

	function valbutton(thisform) {
	
		myOption2 = -1;
			for (i=thisform.restauracja_rabat_calkowity.length-1; i > -1; i--) {
					if (thisform.restauracja_rabat_calkowity[i].checked) {
					myOption2 = i;
				}
			}
		if (myOption2 == -1) {
			alert("Prosze okreslic wysokosc rabatu");
			return false;
		}
	
		myOption = -1;
			for (i=thisform.przystapienie_do_RC.length-1; i > -1; i--) {
					if (thisform.przystapienie_do_RC[i].checked) {
					myOption = i;
				}
			}
		if (myOption == -1) {
			alert("Prosze odpowiedziec czy chca Panstwo przystapic do programu Royal Club");
			return false;
		}
	
		thisform.submit();
	}
