       
    function setroom(id, cam) {
    	room = document.getElementById(id);
    	i = "h"+id;
    	val = document.getElementById(i).value;
    	room.options.length = 0;    	
    	for (var j = 0; j<=cam; j++) {    		
    		room.options[j] = new Option(j, j, false);
    		if (val == j) {
    			room.options[j].selected=true;
    		}
    	}
    }
    
    function setroom2(arr) {   
    	t = arr["twin"];
    	d = arr["double"];
    	s = arr["single"];
		setroom("room_twin", t);	
		setroom("room_double", d);
		setroom("room_single", s);    
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function changedate(id) {
   		obj = document.getElementById(id);
   		ind = obj.selectedIndex;
   		document.getElementById("dep_day").selectedIndex = ind;
   		document.getElementById("dep_month").selectedIndex = ind;
   		document.getElementById("dep_year").selectedIndex = ind;
   		obj = document.getElementById("dep_day");
   		d = obj.options[obj.selectedIndex].value;
   		obj = document.getElementById("dep_month");
   		m = obj.options[obj.selectedIndex].value;
   		obj = document.getElementById("dep_year");
   		y = obj.options[obj.selectedIndex].value;
   		dt = y+"-"+m+"-"+d;
   		obj = document.getElementById("tur_tur");
   		tr = obj.options[obj.selectedIndex].value;
   		x_GetRoom2(dt, tr, setroom2);
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////      
    function turoptions(arr) {
        turobj = document.getElementById("tur_tur");
        turobj.options.length = 0;
        
        tid = document.getElementById("hidtid").value;
        j = 0;
        if (!arr) {
        	turobj.options[0] = new Option("-", "-",true);
        } else        
        for (var i in arr) {
        	opt = arr[i];
        	//alert(opt);
        	a = opt.split("*~");
        	id = a[0];
        	nume = a[1];
        	t = a[2];
        	d = a[3];
        	s = a[4];
        	
        	if (tid == id) {
        		turobj.options[j] = new Option(nume, id,true);	
        		turobj.options[j].selected=true;	
        	} else
        		turobj.options[j] = new Option(nume, id,false);	
        	j++;
        	//alert("t:"+t+"d:"+d+"s:"+s);
        	setroom("room_twin", t);	
        	setroom("room_double", d);
        	setroom("room_single", s);
        	
        	/*opt = arr[i][0];
        	total_len = opt.length;
        	len = opt.substring(0,1);
        	len++;
        	val = opt.substring(1, len);
        	txt = opt.substring(len, total_len);
        	
        	if (tid == val) {
        		turobj.options[j] = new Option(txt, val,true);	
        		turobj.options[j].selected=true;	
        	} else
        		turobj.options[j] = new Option(txt, val,false);	
        	j++;
        	
        	cam = arr[i][1][0];
        	setroom("room_twin", cam);	
        	cam = arr[i][1][1];
        	setroom("room_double", cam);
        	cam = arr[i][1][2];
        	setroom("room_single", cam);*/
        }
        changetur();       
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function dateoptions(arr) {    		
        dayobj = document.getElementById("dep_day");
        dayobj.options.length = 0;
        monobj = document.getElementById("dep_month");
        monobj.options.length = 0;
        yearobj = document.getElementById("dep_year");
        yearobj.options.length = 0;
        
		hday = document.getElementById("hdep_day").value;
        hmon = document.getElementById("hdep_month").value;
        hyear = document.getElementById("hdep_year").value;
        /*for (var i in arr) {
        	d = arr[i];
        	a = d.split("-");
        	y = a[0];
        	m = a[1];
        	dd = a[2];
        	dayobj.options[i] = new Option(dd, dd, false);
        	monobj.options[i] = new Option(m, m, false);
        	yearobj.options[i] = new Option(y, y, false);
        	if (hday==dd && hmon==m && hyear==y) {
	        	dayobj.options[i].selected=true;
	        	monobj.options[i].selected=true;
	        	yearobj.options[i].selected=true;	
        	}
        }*/
        a = arr.split("*~");
        j = 0;
        enable_date();
        for (var i in a) {
        	dt = a[i];
        	if(dt) {
        		ar = dt.split("-");
        		y = ar[0];
	        	m = ar[1];
	        	dd = ar[2];
	        	if (y == "0000") {
	        		disable_date();
	        		break;
	        	} else {
		        	dayobj.options[j] = new Option(dd, dd, false);
		        	monobj.options[j] = new Option(m, m, false);
		        	yearobj.options[j] = new Option(y, y, false);
		        	if (hday==dd && hmon==m && hyear==y) {
			        	dayobj.options[j].selected=true;
			        	monobj.options[j].selected=true;
			        	yearobj.options[j].selected=true;	
		        	}
		        	j++;
	        	}
        	}
        }
        changedate('dep_month');
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function disableall() {
    	disablefeat("tur_tur");        	
    	disablefeat("dep_day");
        disablefeat("dep_month");
        disablefeat("dep_year");
        disablefeat("room_twin");
        disablefeat("room_double");
        disablefeat("room_single");
        disablefeat("nefumatori");
        disablefeat("vegetarieni");
        disablefeat("dieta");
        disablefeat("medical");
        disablefeat("share");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function disableall1() {
    	disablefeat("dep_day");
        disablefeat("dep_month");
        disablefeat("dep_year");
        disablefeat("room_twin");
        disablefeat("room_double");
        disablefeat("room_single");
        disablefeat("nefumatori");
        disablefeat("vegetarieni");
        disablefeat("dieta");
        disablefeat("medical");
        disablefeat("share");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function disable_date() {
    	disablefeat("dep_day");
        disablefeat("dep_month");
        disablefeat("dep_year");            
        document.getElementById("special_date").style.display="block";
        document.getElementById("special_dep").style.display="block";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function disablefeat(id) {
    	tur = document.getElementById(id);
        tur.disabled = true;
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enableall() {
    	enablefeat("tur_tur");
    	enablefeat("dep_day");
        enablefeat("dep_month");
        enablefeat("dep_year");
        enablefeat("room_twin");
        enablefeat("room_double");
        enablefeat("room_single");
        enablefeat("nefumatori");
        enablefeat("vegetarieni");
        enablefeat("dieta");
        enablefeat("medical");
        enablefeat("share");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enableall2() {
    	enablefeat("tur_tur");
        enablefeat("room_twin");
        enablefeat("room_double");
        enablefeat("room_single");
        enablefeat("nefumatori");
        enablefeat("vegetarieni");
        enablefeat("dieta");
        enablefeat("medical");
        enablefeat("share");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enable_date() {
    	enablefeat("dep_day");
        enablefeat("dep_month");
        enablefeat("dep_year");
        document.getElementById("special_date").style.display="none";
        document.getElementById("special_dep").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enableall1() {
    	enablefeat("dep_day");
        enablefeat("dep_month");
        enablefeat("dep_year");
        enablefeat("room_twin");
        enablefeat("room_double");
        enablefeat("room_single");
        enablefeat("nefumatori");
        enablefeat("vegetarieni");
        enablefeat("dieta");
        enablefeat("medical");
        enablefeat("share");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function disable_room() {
    	disablefeat("room_twin");
        disablefeat("room_double");
        disablefeat("room_single");
        document.getElementById("special_room").style.display="block";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enable_room() {
    	enablefeat("room_twin");
        enablefeat("room_double");
        enablefeat("room_single");
        document.getElementById("special_room").style.display="none";
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function enablefeat(id) {
    	tur = document.getElementById(id);
    	tur.disabled = false;
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function setshort(a) {
		j = 1;
		s = document.getElementById("city_break");
		s.options[0] = new Option("--", "--", true);
		for (var i in a) {
        	dt = a[i];
        	arr = dt.split("%%");
        	s.options[j] = new Option(arr[1], arr[0], false);
        	j++;
        }
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function enable_short() {
		//document.getElementById("txt_short").style.display="block";
		//document.getElementById("short_dep").style.display="block";
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function disble_short() {
		//document.getElementById("txt_short").style.display="none";
		//document.getElementById("short_dep").style.display="none";
	}	

/////////////////////////////////////////////////////////////////////////////////////////////////////    

    function changeholl() {
        holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].value;
        txt = holl.options[holl.selectedIndex].text;
        if (txt == "Short Break" || txt == "City Break") {
        	enable_date();                      	
        	disableall();  
        	enable_short();
        	x_GetPret(holl_id, SetPret);
        	x_GetShortBreak(setshort);
        } else {
        	//disble_short();
        	if (txt == "Danube Delta") {
        		enableall2();	            
            	holl_id = holl.options[holl.selectedIndex].value;
            	x_GetTururi(holl_id, turoptions);
            	x_GetShortBreak(setshort);  
        		disable_date();
        		alert(Calendar);
        	} else {
            	enableall();	
            	holl_id = holl.options[holl.selectedIndex].value;
            	x_GetTururi(holl_id, turoptions);
            	x_GetShortBreak(setshort);
            	enable_date();
          
        	}
        }
        //changebreak();                
        //x_GetShortBreak(setshort);
    }
    
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function changecod(cod) {
		document.getElementById("cod_tur").value=cod;
	}    
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function changetur() {
    	holl = document.getElementById("tur_tur");
        holl_id = holl.options[holl.selectedIndex].value;
        x_GetCode(holl_id, changecod);
        txt = holl.options[holl.selectedIndex].text;
        x_GetPret(holl_id, SetPret);
        if (txt=="Rent-a-hely") {
        	enable_room();   		
        	disableall1();            	
        } else {
        	if (txt=="Conquer Transylvanian's Alps") {
        		//disable_room();
        		x_GetDepartureDate(holl_id, dateoptions);
        	} else {    
        		holl = document.getElementById("vacanta");
	            txt = holl.options[holl.selectedIndex].text;  
	            if (txt == "Danube Delta") {
	            	enableall2();	            
        			disable_date();
	            } else {
            		enableall1();
            		x_GetDepartureDate(holl_id, dateoptions);
	            }
        	}
        }
    }

/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function members(mem) {
    	if (mem == "") {
    		global_nr--;
    	} else {
        	n = global_nr-1;
        	d = "hiddiv"+n;
        	document.getElementById(d).innerHTML = mem;	
    	}
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function addmembers() {    
    	holl = document.getElementById("tur_tur");
        holl_id = holl.options[holl.selectedIndex].value; 

       // alert(global_nr);
    	x_membersss(global_nr, holl_id, members);
    	global_nr++;
    }
        
/////////////////////////////////////////////////////////////////////////////////////////////////////			

	function Validate_String(string, return_invalid_chars)
         {
         valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         invalid_chars = '';
         
         if(string == null || string == '')
            return(true);
         
         //For every character on the string.   
         for(index = 0; index < string.length; index++)
            {
            char = string.substr(index, 1);                        
            
            //Is it a valid character?
            if(valid_chars.indexOf(char) == -1)
              {
              //If not, is it already on the list of invalid characters?
              if(invalid_chars.indexOf(char) == -1)
                {
                //If it's not, add it.
                if(invalid_chars == '')
                   invalid_chars += char;
                else
                   invalid_chars += ', ' + char;
                }
              }
            }                     
            
         //If the string does not contain invalid characters, the function will return true.
         //If it does, it will either return false or a list of the invalid characters used
         //in the string, depending on the value of the second parameter.
         if(return_invalid_chars == true && invalid_chars != '')
           {
           last_comma = invalid_chars.lastIndexOf(',');
           
           if(last_comma != -1)
              invalid_chars = invalid_chars.substr(0, $last_comma) + 
              ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
                      
           return(invalid_chars);
           }
         else
           return(invalid_chars == ''); 
         }

/////////////////////////////////////////////////////////////////////////////////////////////////////		         

	function Validate_Email_Address(email_address) {
         //Assumes that valid email addresses consist of user_name@domain.tld
         at = email_address.indexOf('@');
         dot = email_address.lastIndexOf('.');
         
         if(at == -1 || 
            dot == -1 || 
            dot <= at + 1 ||
            dot == 0 || 
            dot == email_address.length - 1)
            return(false);
            
         user_name = email_address.substr(0, at);
         domain_name = email_address.substr(at + 1, email_address.length);                  
         
         if(Validate_String(user_name) === false || 
            Validate_String(domain_name) === false)
            return(false);                     
         
         return(true);
    }

/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function submitform() {
    	confirmamount();
		val = document.getElementById("nume_lider").value;
    	if (!val) {
    		alert("Please fill in lider's first name");
    		return;
    	}
    	val = document.getElementById("prenume_lider").value;
    	if (!val) {
    		alert("Please fill in lider's surname");
    		return;
    	}
    	val = document.getElementById("pass_lider").value;
    	if (!val) {
    		alert("Please fill in lider's passport serial number");
    		return;
    	}
    	val = document.getElementById("oras_lider").value;
    	if (!val) {
    		alert("Please fill in lider's city/village");
    		return;
    	}
    	val = document.getElementById("cod_postal_lider").value;
    	if (!val) {
    		alert("Please fill in lider's post code/zip");
    		return;
    	}
    	val = document.getElementById("nr_lider").value;
    	if (!val) {
    		alert("Please fill in lider's house number");
    		return;
    	}
    	val = document.getElementById("strada_lider").value;
    	if (!val) {
    		alert("Please fill in lider's street");
    		return;
    	}
    	val = document.getElementById("email_lider_home").value;
    	val1 = document.getElementById("email_lider_work").value;
    	if (!val&&!val1) {
    		alert("Please fill in at least one of lider's email adress (home or work)");
    		return;
    	}
    	if (val && !Validate_Email_Address(val)) {
    		alert("Please fill in a valid email adress");
    		return;
    	}  
    	val2 = document.getElementById("email_lider_home1").value;
    	if(val!=val2) {
    		alert("Verify lider's home e-mail");
    		return;
    	}
    	if (val1 && !Validate_Email_Address(val1)) {
    		alert("Please fill in a valid email adress");
    		return;
    	}   		
    	val2 = document.getElementById("email_lider_work1").value;
    	if(val1!=val2) {
    		alert("Verify lider's work e-mail");
    		return;
    	}
    	
    	val = document.getElementById("nume_urgenta").value;
    	if (!val) {
    		alert("Please fill in the emergency contact name");
    		return;
    	}
    	val = document.getElementById("telefon_urgenta").value;
    	if (!val) {
    		alert("Please fill in the emergency contact telephone");
    		return;
    	}
    	val = document.getElementById("conditions").checked;
    	if (!val) {
    		alert("Please read and understand the booking conditions");
    		return;
    	}
    	holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].text;
    	if (holl_id=="--") {
    		holl = document.getElementById("city_break");
        	holl_id = holl.options[holl.selectedIndex].text;
        	if (holl_id=="--") {
    			alert("Please select a holliday");
    			return;
        	}
    	}
    	
    	/*if (holl_id!="Short Break"&&holl_id!="City Break") {
    		obj = document.getElementById("room_twin");
			rt = obj.options[obj.selectedIndex].value;
			obj = document.getElementById("room_double");
			rd = obj.options[obj.selectedIndex].value;
			obj = document.getElementById("room_single");
			rs = obj.options[obj.selectedIndex].value;
			rooms = 2*parseInt(rt)+2*parseInt(rd)+parseInt(rs);
			if (rooms==0) {
				alert("Please select a room");
				return;
			}
   			/*pers = total_turisti;   			
			tur = document.getElementById("tur_tur");
    		tur_id = tur.options[tur.selectedIndex].value;
    		if (holl_id!="Walking Tours"&&tur_id!="Conquer Transylvanian's Alps") {
    			if (rooms>pers) {
    				alert("You selected more rooms than tourists");
    				return;
    			}
    			if (rooms<pers) {
    				alert("You selected less rooms than tourists");
    				return;
    			}
    		}*/
    	//}
    	
    	val = document.getElementById("contact_lider1").checked;
    	str = "";
    	if (val)
    		str += "Daytime telephone<br>";
    	val = document.getElementById("contact_lider2").checked;
    	if (val)
    		str += "Alternative telephone<br>";	
    	val = document.getElementById("contact_lider3").checked;
    	if (val)
    		str += "Home e-mail<br>";	
    		val = document.getElementById("contact_lider4").checked;
    	if (val)
    		str += "Work e-mail<br>";	
    	if (!str)
    		str = "E-mail";
    	set_disc=0;
    	val = document.getElementById("suma_platita").value;
    	if (!val) {
    		alert("Please calculate the amount to be taken");
    		return;
    	}
    	val = document.getElementById("captcha").value;
    	if (!val) {
    		alert("Please fill in the securoty code");
    		return;
    	}
    	///discount();
    	//alert(document.getElementById("suma_platita").value);
    	document.getElementById("contact_lider").value = str;
    	document.getElementById("total_other").value = global_nr;
    	document.forms[0].submit();
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////

	function SetPret(pret) {
		obj = document.getElementById("suma_platita");
		holl = document.getElementById("vacanta");
        txt = holl.options[holl.selectedIndex].text;
        if (txt == "Short Break" || txt == "City Break") {
        	countr = document.getElementById("city_break");
	        count_id = countr.options[countr.selectedIndex].value;	        
       		pret = 121;
	        if (count_id=="Budapest sightseeing on the bus") 
        		pret = 29;
        }
        nr = 1;
        for (i = 2; i<global_nr; i++) {
        	s = "fmembri"+i;
        	if (document.getElementById(s).value)
        		nr++;
        }
        	
		s = pret*nr;
		
		obj = document.getElementById("moneda");
        moneda = obj.options[obj.selectedIndex].text;
		obj = document.getElementById("hid_suma");
		obj.value=s;
        //changemoneda();
		total_turisti=nr;
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function stateus(str) {
		stat = document.getElementById("stat_lider");
        stat.options.length = 0;
        sel = document.getElementById("hstat_lider").value;
        
        arr = str.split("@");
        j = 0;
        for (var i=0; i<50; i++) {
        	o = arr[i];
        	stat.options[i] = new Option(o, o, false);
        	if (sel == i) {
	        	stat.options[i].selected=true;	        	
        	}
        }
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function stateuk(str) {
		stat = document.getElementById("stat_lider");
        stat.options.length = 0;
        sel = document.getElementById("hstat_lider").value;
        
        arr = str.split("@");
        j = 0;
        for (var i=0; i<98; i++) {
        	o = arr[i];
        	stat.options[i] = new Option(o, o, false);
        	if (sel == i) {
	        	stat.options[i].selected=true;	        	
        	}
        }
	}	

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function changecountry() {
		countr = document.getElementById("tara_lider");
        count_id = countr.options[countr.selectedIndex].value;
        if (count_id=="United States") {
        	stat = document.getElementById("stat_lider");
        	stat.disabled=false;
        	stat = document.getElementById("hdivstat");
        	stat.style.display="none";
        	x_GetUS(stateus);
        } else
        if (count_id == "United Kingdom") {
        	stat = document.getElementById("stat_lider");
        	stat.disabled=false;
        	stat = document.getElementById("hdivstat");
        	stat.style.display="none";
        	x_GetUK(stateuk);
        } else {
        	stat = document.getElementById("stat_lider");
        	stat.options.length = 0;
        	stat.disabled=true;
        	stat = document.getElementById("hdivstat");
        	stat.style.display="block";
        }
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////   

	function disablebreak() {
		disablefeat("pers_break");
		disablefeat("city_break");
		disablefeat("hotel_break");
		disablefeat("twin_break");
		disablefeat("double_break");
		disablefeat("single_break");
		disablefeat("guide_break");
		disablefeat("share_break");
		disablefeat("nefumatori_break");
		disablefeat("vegetarieni_break");
		disablefeat("dieta_break");
		disablefeat("medical_break");
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////   

	function enablebreak() {
		enablefeat("pers_break");
		enablefeat("city_break");
		enablefeat("hotel_break");
		enablefeat("twin_break");
		enablefeat("double_break");
		enablefeat("single_break");
		enablefeat("guide_break");
		enablefeat("share_break");
		enablefeat("nefumatori_break");
		enablefeat("vegetarieni_break");
		enablefeat("dieta_break");
		enablefeat("medical_break");
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////   

	function invalidatebr() {
		disablefeat("hotel_break");
		disablefeat("twin_break");
		disablefeat("double_break");
		disablefeat("single_break");
		disablefeat("guide_break");
		disablefeat("share_break");
		disablefeat("nefumatori_break");
		disablefeat("vegetarieni_break");
		disablefeat("dieta_break");
		disablefeat("medical_break");
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////   

	function validatebr() {
		enablefeat("hotel_break");
		enablefeat("twin_break");
		enablefeat("double_break");
		enablefeat("single_break");
		enablefeat("guide_break");
		enablefeat("share_break");
		enablefeat("nefumatori_break");
		enablefeat("vegetarieni_break");
		enablefeat("dieta_break");
		enablefeat("medical_break");
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////   

	function changebreak(){
		/*countr = document.getElementById("city_break");
        count_id = countr.options[countr.selectedIndex].value;
        if (count_id=="Budapest sightseeing on the bus") {
        	invalidatebr();
        	SetPret(24);
        } else {
        	validatebr();
        	SetPret(100);
       		stat = document.getElementById("hotel_break");
       		hot = document.getElementById("hhotel").value;
        	if (count_id=="Medieval weekend in Transylvania") {
        		stat.options.length = 0;
        		stat.options[0] = new Option("Wagner House", "Wagner House", false);
        		if (hot == "Wagner House")
        			stat.options[0].selected=true;
        		stat.options[1] = new Option("House with Stag", "House with Stag", false);
        		if (hot == "House with Stag")
        			stat.options[1].selected=true;
        		stat.options[2] = new Option("Hotel Sighisoara", "Hotel Sighisoara", false);
        		if (hot == "Hotel Sighisoara")
        			stat.options[2].selected=true;
        		stat.options[3] = new Option("The Legend House", "The Legend House", false);
        		if (hot == "The Legend House")
        			stat.options[3].selected=true;
        	} else 
    		if (count_id=="--"){
    			stat.options.length = 0;
        		stat.options[0] = new Option("--", "--", false);
    		} else {
        		stat.options.length = 0;
        		stat.options[0] = new Option("Atlas Hotel", "Atlas Hotel", false);
        		if (hot == "Atlas Hotel")
        			stat.options[0].selected=true;
        		stat.options[1] = new Option("Matyas Hotel", "Matyas Hotel", false);
        		if (hot == "Matyas Hotel")
        			stat.options[1].selected=true;
        		stat.options[2] = new Option("Ring Hotel", "Ring Hotel", false);
        		if (hot == "Ring Hotel")
        			stat.options[2].selected=true;
        	}
        }*/
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function setsuma(variatie) {
		eur = parseFloat(document.getElementById("hid_suma").value);
		suma = Math.round(parseFloat(eur*parseFloat(variatie)));
		document.getElementById("suma_platita").value=suma;
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function changemoneda() {
		/*countr = document.getElementById("moneda");
        mon = countr.options[countr.selectedIndex].value;        
        if (mon=="USD") {
			x_GetEurUsd(setsuma);      	
        } else
        if (mon=="GBP") {
			x_GetEurGbp(setsuma);      	
        } else {*/
        	eur = parseFloat(document.getElementById("hid_suma").value);
			document.getElementById("suma_platita").value=eur;
        //}
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function OpenRes() {
		wwidth=800;
		wheight=600;
		left=(screen.width-wwidth)/2;	
		ftop=(screen.height-wheight)/2;
		features ="height="+wheight+",width="+wwidth+",left="+left+",top="+ftop+",scrollbars=1,status=1,toolbar=1,menubar=1,location=1";
		window.open("http://www.visit-transylvania.us/reservations.php","Reservations",features);
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function computedisc(dis) {
		eur = parseFloat(document.getElementById("hid_suma").value);
		eur = eur-parseInt(dis);
		document.getElementById("hid_suma").value=eur;
		//changemoneda();
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function discount() {
		if (set_disc==0) {
			cod = document.getElementById("promotion").value;
			set_disc = 1;
			x_GetDiscount(cod, computedisc);			
		}
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function setamount(pret) {
		obj = document.getElementById("suma_platita");
		holl = document.getElementById("vacanta");
        txt = holl.options[holl.selectedIndex].text;
        
        nr = 1;
        for (i = 2; i<global_nr; i++) {
        	s = "fmembri"+i;
        	s1 = "smembri"+i;
        	s2 = "dmembri"+i;
        	if (document.getElementById(s).value||document.getElementById(s1).value||document.getElementById(s2).value)
        		nr++;
        }
        	
		s = pret*nr;
		
		obj = document.getElementById("moneda");
		obj.selectedIndex=0;
		document.getElementById("suma_platita").value=s;
        //changemoneda();
		obj = document.getElementById("hid_suma");
		obj.value=s;
		total_turisti=nr;
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    
	
	function confirmamount() {
        holl = document.getElementById("tur_tur");
        tid = holl.options[holl.selectedIndex].value;
        holl1 = document.getElementById("vacanta");
        tid1 = holl1.options[holl1.selectedIndex].text;
        if (tid1=="Short Break") {
        	holl = document.getElementById("city_break");
        	tid = holl.options[holl.selectedIndex].value;        	
        }
        x_GetDeposit(tid, setamount);
        /*pret = 182;
        if (txt == "Short Break" || txt == "City Break") {
        	countr = document.getElementById("city_break");
	        count_id = countr.options[countr.selectedIndex].value;	        
       		pret = 121;
	        if (count_id=="Budapest sightseeing on the bus") 
        		pret = 29;
        }*/        
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function tdover(id) {
		a = "crt"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "cod"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		/*a = "intref"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "rrn"+id;
		document.getElementById(a).bgColor="#F1CB9E";*/
		a = "title"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "suma"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "promo"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "moneda"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "rest"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "titlu"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "locatie"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "tel"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "email"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "membri"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "vacanta"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "tur"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "data"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "nr"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "city"+id;
		document.getElementById(a).bgColor="#F1CB9E";
		a = "info"+id;
		document.getElementById(a).bgColor="#F1CB9E";		
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    

	function tdout(id) {
		a = "crt"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "cod"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		/*a = "intref"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "rrn"+id;
		document.getElementById(a).bgColor="#E4DCBD";*/a
		a = "title"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "suma"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "promo"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "moneda"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "rest"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "titlu"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "locatie"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "tel"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "email"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "membri"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "vacanta"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "tur"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "data"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "nr"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "city"+id;
		document.getElementById(a).bgColor="#E4DCBD";
		a = "info"+id;
		document.getElementById(a).bgColor="#E4DCBD";
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function action(link) {
		if (link.search("del")==-1) {
			document.location=link;
		} else {
			if(window.confirm("Are you sure you want to delete the reservation?"))
				document.location=link;			
		}
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////    
    
    function clearform() {
    	document.getElementById("nume_lider").value = "";
    	document.getElementById("prenume_lider").value = "";
    	document.getElementById("pass_lider").value = "";
    	document.getElementById("oras_lider").value = "";
    	document.getElementById("cod_postal_lider").value = "";
    	document.getElementById("nr_lider").value = "";
    	document.getElementById("strada_lider").value = "";
    	document.getElementById("email_lider_home").value = "";
    	document.getElementById("email_lider_work").value = "";
    	document.getElementById("nume_urgenta").value = "";
    	document.getElementById("telefon_urgenta").value = "";
    	document.getElementById("conditions").checked = false;
    	document.getElementById("vacanta").selectedIndex = 0;
    	document.getElementById("room_twin").selectedIndex = 0;		
		document.getElementById("room_double").selectedIndex = 0;
		document.getElementById("room_single").selectedIndex = 0;
		
		t = document.getElementById("htot").value;
		//if (t>0)
		//global_nr+=parseInt(t);
		for (i = 2; i<global_nr; i++) {
        	s = "fmembri"+i;
        	document.getElementById(s).value = "";
        	s = "tmembri"+i;
        	document.getElementById(s).selectedIndex = 0;
        	s = "smembri"+i;
        	document.getElementById(s).value = "";
        	s = "dmembri"+i;
        	document.getElementById(s).value = "";
        }
		
   		global_nr = 7;
		total_turisti = 1;
		set_disc = 0;
		confirm_amount = 0;
		
		document.getElementById("tur_tur").selectedIndex = 0 ;
    	document.getElementById("contact_lider1").checked = false;
    	document.getElementById("contact_lider2").checked = false;
    	document.getElementById("contact_lider3").checked = false;
    	document.getElementById("contact_lider4").checked = false;
    	document.getElementById("contact_lider").value = "";
    	
    	document.getElementById("tel_lider_day").value = "";
    	document.getElementById("pref_lider_day").value = "";
    	document.getElementById("tel_lider_alt").value = "";
    	document.getElementById("pref_lider_alt").value = "";
    	document.getElementById("fax_lider").value = "";
    	
    	document.getElementById("special_dep").value = "";
    	document.getElementById("special_dep").style.display = "none";
    	
    	document.getElementById("share").checked = false;
    	document.getElementById("nefumatori").selectedIndex = 0;
    	document.getElementById("vegetarieni").selectedIndex = 0;
    	document.getElementById("dieta").value = "";    	
    	document.getElementById("medical").value = "";
    	document.getElementById("obs").value = "";
    	
    	document.getElementById("pers_break").selectedIndex = 0;
    	document.getElementById("city_break").selectedIndex = 0;
    	changebreak();
    	document.getElementById("twin_break").selectedIndex = 0;
    	document.getElementById("double_break").selectedIndex = 0;
    	document.getElementById("single_break").selectedIndex = 0;
    	document.getElementById("guide_break").selectedIndex = 0;
    	document.getElementById("nefumatori_break").selectedIndex = 0;
    	document.getElementById("vegetarieni_break").selectedIndex = 0;
    	document.getElementById("dieta_break").value = "";    	
    	document.getElementById("medical_break").value = "";
    	document.getElementById("share_break").checked = false;
    	
    	document.getElementById("nume_urgenta").value = "";
    	document.getElementById("relatie_urgenta").value = "";
    	document.getElementById("telefon_urgenta").value = "";
    	
    	document.getElementById("billing").value = "";    	
    	document.getElementById("suma_platita").value = "";
    	document.getElementById("hid_suma").value = "";
    	document.getElementById("moneda").selectedIndex = 0;
    	document.getElementById("promotion").value = "";
    	document.getElementById("conditions").checked = false;
    	    	
    	changeholl();
    }	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function turoptionscp(arr) {
		turobj = document.getElementById("tur");
        turobj.options.length = 0;
        j = 0;
        if (!arr) {
        	turobj.options[0] = new Option("-", "-",true);
        } else        
        for (var i in arr) {
        	opt = arr[i];
        	a = opt.split("*~");
        	id = a[0];
        	nume = a[1];        	
        	
        	/*opt = arr[i][0];
        	total_len = opt.length;
        	len = opt.substring(0,1);
        	len++;
        	val = opt.substring(1, len);
        	txt = opt.substring(len, total_len);*/
        	
       		turobj.options[j] = new Option(nume, id,false);	
       		j++;
        }
        changeturcp();
	}
		
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function changevacanta() {
		holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].value;
        x_GetTururi(holl_id, turoptionscp);
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function addtur() {
		holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].value;
        document.getElementById("hidhol").value=holl_id;
        document.getElementById("formtur").submit();
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function changeturcp() {
		holl = document.getElementById("tur");
        holl_id = holl.options[holl.selectedIndex].value;
        x_GetTurInfo(holl_id, setinfo);
        x_GetDepartureDate1(holl_id, setdepdate);
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function setdepdate(arr) {
		turobj = document.getElementById("depdate");
        turobj.options.length = 0;
        
        if (!arr) {
        	turobj.options[0] = new Option("-", "-",true);
        } else 
		for (var i in arr) {
        	opt = arr[i];
        	a = opt.split("*");
        	val = a[0];
        	txt = a[1];
        	turobj.options[i] = new Option(txt, val,false);	
        }
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function adddate() {
		holl = document.getElementById("tur");
        holl_id = holl.options[holl.selectedIndex].value;
        document.getElementById("hidtur").value=holl_id;
        document.getElementById("formdate").submit();
	}	

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cphol() {
		turobj = document.getElementById("divhol");
		st = turobj.style.display;
		if (st == "none")
			st = "block";
		else
			st = "none";
		turobj.style.display=st;
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cptour() {
		turobj = document.getElementById("divtur");
		st = turobj.style.display;
		if (st == "none")
			st = "block";
		else
			st = "none";
		turobj.style.display=st;
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cpdate() {
		turobj = document.getElementById("divdate");
		st = turobj.style.display;
		if (st == "none")
			st = "block";
		else
			st = "none";
		turobj.style.display=st;
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cpholmod() {
		turobj = document.getElementById("divholmod");
		st = turobj.style.display;
		if (st == "none")
			st = "block";
		else
			st = "none";
		turobj.style.display=st;
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function setinfo(arr) {
		val = arr[0];
		document.getElementById("codmod").value=val;
		val = arr[1];
		document.getElementById("tur_namemod").value=val;		
		val = arr[2];
		document.getElementById("membrimod").value=val;
		val = arr[3];
		document.getElementById("avansmod").value=val;
		//val = arr[7];
		//document.getElementById("pretmod").value=val;
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cptourmod() {
		turobj = document.getElementById("divturmod");
		st = turobj.style.display;
		if (st == "none") {
			st = "block";
			turobj.style.display=st;
			turobj = document.getElementById("tur");			
			id = turobj.options[turobj.selectedIndex].value;
			x_GetTurInfo(id, setinfo);
		} else {
			st = "none";
			turobj.style.display=st;
		}
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function setdatemod(arr) {
		str = arr[0];
		document.getElementById("pretmod").value=str;	
		val = arr[1];
		document.getElementById("twinmod").value=val;
		val = arr[2];
		document.getElementById("doublemod").value=val;
		val = arr[3];
		document.getElementById("singlemod").value=val;		
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function cpdatemod() {
		turobj = document.getElementById("divdatemod");
		st = turobj.style.display;
		if (st == "none") {
			st = "block";
			turobj.style.display=st;
			turobj = document.getElementById("tur");			
			id = turobj.options[turobj.selectedIndex].value;
			turobj = document.getElementById("depdate");			
			dt = turobj.options[turobj.selectedIndex].text;
			x_GetPretDate(id, dt, setdatemod);
		} else {
			st = "none";
			turobj.style.display=st;
		}
	}		

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function moddate() {
		holl = document.getElementById("depdate");
        holl_id = holl.options[holl.selectedIndex].value;
        document.getElementById("hiddatemod").value=holl_id;
        document.getElementById("formdatemod").submit();
	}		
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function modtur() {
		holl = document.getElementById("tur");
        holl_id = holl.options[holl.selectedIndex].value;
        document.getElementById("hidturmod").value=holl_id;
        document.getElementById("formturmod").submit();
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function modhol () {
		holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].value;
        document.getElementById("holidmod").value=holl_id;
        document.getElementById("formholmod").submit();
	}	

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function deldate() {
		holl = document.getElementById("depdate");
        holl_id = holl.options[holl.selectedIndex].value;
        if (window.confirm("Are you sure you want to delete this date?"))
        	document.location="cp.php?action=deldate&id="+holl_id;
	}	
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function deltur() {
		holl = document.getElementById("tur");
        holl_id = holl.options[holl.selectedIndex].value;
        if (window.confirm("Are you sure you want to delete this tour?"))
        	document.location="cp.php?action=deltour&id="+holl_id;
	}		

///////////////////////////////////////////////////////////////////////////////////////////////////// 

	function delhol() {
		holl = document.getElementById("vacanta");
        holl_id = holl.options[holl.selectedIndex].value;
        if (window.confirm("Are you sure you want to delete this holiday?"))
        	document.location="cp.php?action=delhol&id="+holl_id;
	}		
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function submitpay() {
		val = document.getElementById("nume_lider").value;
    	if (!val) {
			alert("Please fill in lider's name");
    		return;
    	}
    	val = document.getElementById("orderid").value;
    	ui = document.getElementById("uitat").value;
	    if (!val&&!ui) {
			alert("Please fill in the holiday booking reference or give the address of the group leader and the data of your holiday");
    		return;
    	}
		val = document.getElementById("conditions").checked;
    	if (!val) {
    		alert("Please read and understand the booking conditions");
    		return;
    	}
		document.forms[0].submit();
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function submitpay1() {
    	val = document.getElementById("orderid").value;
	    if (!val) {
			alert("Please fill in the holiday booking reference");
    		return;
    	}
		val = document.getElementById("conditions").checked;
    	if (!val) {
    		alert("Please read and understand the booking conditions");
    		return;
    	}
		document.forms[0].submit();
	}	

///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function OpenPay() {
		wwidth=800;
		wheight=600;
		left=(screen.width-wwidth)/2;	
		ftop=(screen.height-wheight)/2;
		features ="height="+wheight+",width="+wwidth+",left="+left+",top="+ftop+",scrollbars=1,status=1,toolbar=1,menubar=1,location=1";
		window.open("http://www.visit-transylvania.us/payments.php","Payments",features);
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function promotion(link) {
		if (link=="@") {
			alert("No promotional code");
		} else
		if (link=="#") {
			alert("Discount applyed");
		} else
			document.location=link;
			
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function cancelpromo(id, cod) {
		link = "cp.php?action=cancelpromo&id="+id+"&cod="+cod;
		document.location=link;
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function denypromo(cod) {
		link = "cp.php?action=denypromo&cod="+cod;
		document.location=link;
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function aaa111(msg) {
		
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 	

	function submitcgiii(orderid) {
		x_submitcgi(orderid, aaa111);		
		document.forms[0].submit();
	}

///////////////////////////////////////////////////////////////////////////////////////////////////// 	