		function CheckAlerteThenSubmit(){
				var dosubmit = false;
				//box1
				if($("from_1").value!='' && $("to_1").value!=''){			
					dosubmit = true; 
				}			
				//box2
				if($("from_2").value!='' &&  $("to_2").value!=''){			
					dosubmit = true; 
				}	
				//box3
				if($("from_3").value!='' && $("to_3").value!=''){			
					dosubmit = true; 
				}
				
				
				
				for(i=1;i<4;i++){
					if($('from_' + i).value!='' && $('to_' + i).value!=''){
						DidYouMean($('from_' + i).value,$('to_' + i).value,'from_' + i,'to_' + i,'ErrorSubmit');
						if($('ErrorSubmit').hasClassName('on')) return false;	
					}
				}
				//submit if
				if(dosubmit==false){
					alert('Va rugam sa completati cel putin o alerta de tarif Vola.ro!!!');	
					return false;		
				}
				//check email
				if(!isEmail(document.getElementById("alerte_email").value,false) ){	
					warnEmpty (document.getElementById("alerte_email"), "email","error_price");
					document.getElementById("alerte_email").focus();		
					return false;
				} 
				submitFormAlerte();				
		
		}
		
		function submitFormAlerte(){
			//var alerte_limit = ''; 
			//if($('alerte_limit').checked){
			//	alerte_limit  = '&alerte_limit=1'
			//}
			var radioGrp = document['forms']['alerte_fake_form']['frequency'];
			for(i=0; i < radioGrp.length; i++){
				if (radioGrp[i].checked == true) {
					var radioValue = radioGrp[i].value;
				}
			}
			
			new Ajax.Updater(
							"alerte_messages", 
							"/alerte_insert.php?from_1=" + $("from_1").value + '&to_1=' + $("to_1").value + '&price_1=' + $("price_1").value + '&from_2= ' + $("from_2").value + '&to_2=' + $("to_2").value + '&price_2=' + $("price_2").value + '&from_3= ' + $("from_3").value + '&to_3=' + $("to_3").value + '&price_3=' + $("price_3").value + '&alerte_email=' + $("alerte_email").value  + '&frequency=' + radioValue, 
							{	
								parameters: { text: 'loading'},
								method: 'get',
								onComplete:function(transport){ 
									var notice = $('alerte_messages');
									if (transport.responseText.match(/####OK####/)){
										 //new ajax call to change the display										
										 $("alerte_messages").innerHTML = '';
										
										//alert(transport.responseText.substr(10,transport.responseText.length));
										///get_alerte.php?t=" + transport.responseText.substr(10,transport.responseText.length) + '&tid=59'
										var test = new Ajax.Updater(
										"right", 
										"/show_text.php?tid=59", 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight('right');																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);
										
										
										
									}else{
										new Effect.Highlight('alerte_messages');																					
									}
								},							
								asynchronous:true, 
								evalScripts:true
							}
						);
		}
		function UpdateAlert(box,token){
									 new Ajax.Updater(
										"alerte_tarif_holder_" + box, 
										"/alerte_single_box.php?t=" + token + '&box=' + box, 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight("alerte_tarif_holder_" + box);																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);						
		}
		
		function CancelAlert(box,token){
									 new Ajax.Updater(
										"alerte_tarif_holder_" + box, 
										"/alerte_single_box.php?cancel=1&t=" + token + '&box=' + box, 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight("alerte_tarif_holder_" + box);																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);						
		}
		function CheckAlerteBoxes(token){
			
			//var alerte_limit = ''; 
			/*if($('alerte_limit').checked){
				alerte_limit  = '&alerte_limit=1'
			}*/
			
			var radioGrp = document['forms']['alerte_fake_form']['frequency'];
			for(i=0; i < radioGrp.length; i++){
				if (radioGrp[i].checked == true) {
					var radioValue = radioGrp[i].value;
				}
			}
			
			for(i=1;i<4;i++){
				if($('from_' + i)!=undefined){
									if($('from_' + i).value!='' && $('to_' + i).value!=''){
										DidYouMean($('from_' + i).value,$('to_' + i).value,'from_' + i,'to_' + i,'ErrorSubmit');
										if($('ErrorSubmit').hasClassName('on')) return false;
									}
									new Ajax.Request(
									    "/insert_single_box_alert.php?&t=" + token + '&box=' + i + '&from_' + i + '=' + $('from_' + i).value + '&to_' + i + '=' + $('to_' + i).value + '&price_' + i + '=' + $('price_' + i).value, 
												{	
													method: 'get',																	
													asynchronous:true, 
													evalScripts:true
												}
										);	
									
				} // end if			
			}// end for
			
			new Ajax.Request(
									    "/insert_single_box_alert.php?&t=" + token + '&frequency_options=' + radioValue, 
												{	
													method: 'get',																	
													asynchronous:true, 
													evalScripts:true
												}
										);	
			
			
			
							       new Ajax.Updater(
										"right", 
										"/get_alerte.php?t=" + token + '&tid=60', 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight('right');																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);
			
		}
		function CancelAlerte(token){
			/*
			for(i=1;i<4;i++){	
									new Ajax.Updater(
										"alerte_tarif_holder_" + i, 
										"/alerte_single_box.php?cancel=1&t=" + token + '&box=' + i, 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight("alerte_tarif_holder_" + i);																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);				
			}// end for
			*/
							new Ajax.Updater(
										"right", 
										"/alerte_delete.php?t=" + token, 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight("right");																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);		
		}
		function UpdateEmail(token,email){
								new Ajax.Updater(
										"email_alerte_holder", 
										"/alerte_email_edit.php?t=" + token + '&alerte_email=' + email, 
												{	
													method: 'get',
													onComplete:function(transport){ 
														new Effect.Highlight("email_alerte_holder");																														
													},							
													asynchronous:true, 
													evalScripts:true
												}
										);		
		}
		
		function SaveEmail(token){		
			new Ajax.Updater(
							"email_alerte_holder", 
							"/alerte_email_edit.php?save=1&t=" + token + "&alerte_email=" + $('alerte_email').value, 
							{	
								method: 'get',
								onComplete:function(transport){ 
									var notice = $('email_alerte_holder');
									if (transport.responseText.match(/####OK####/)){
										 //new ajax call to change the display										
										 $("alerte_messages").innerHTML = 'Email-ul dvs a fost salvat!!!';
										
										//alert(transport.responseText.substr(10,transport.responseText.length));
										
										var test = new Ajax.Updater(
											"right", 
											"/get_alerte.php?t=" + transport.responseText.substr(10,transport.responseText.length) + '&tid=59', 
													{	
														method: 'get',
														onComplete:function(transport){ 
															new Effect.Highlight('right');																														
														},							
														synchronous:true, 
														evalScripts:true
													}
											);
											
											
											
										}else{
											new Effect.Highlight('email_alerte_holder');																					
										}
								},							
								synchronous:true, 
								evalScripts:true
							}
					);
		}
		
		function DidYouMean(from,to,field1,field2,container){
			new Ajax.Updater(
							container, 
							"/alerte_check_destionation.php?from=" + from + "&to=" + to + "&field1=" + field1 + '&field2=' + field2 + '&container=' + container, 
							{	
								method: 'get',
								onComplete:function(transport){ 
									var notice = $(container);
										if (transport.responseText==''){								
										}else{
											StatusObiect(container,'on'); HideDDls();																							
										}
										
								},							
								asynchronous:false, 
								evalScripts:true
							}
					);
		}
		function UpdateValue(value,field){
			document.getElementById(field).value = value;			
		}
	
		
		
	
function apearAlerteHelp(evt){
	ShowBoxAlerte(evt);
}
function disapearPicture(){
	closeBoxAlerte();
}
function ShowBoxAlerte(e)
{
/*simple browser detection in order to choose between using pageX (does not work in IE) and clientX*/
	var IE=false;
	//alert(navigator.appName);
	if(navigator.appName == "Microsoft Internet Explorer")
	IE = true;

	
	if (!e) var e = window.event;
    if (e.pageX || e.pageY)     {
        x = e.pageX;
        y = e.pageY;
    }
    else if (e.clientX || e.clientY)     {
        x = e.clientX + document.body.scrollLeft
            + document.documentElement.scrollLeft;
        y = e.clientY + document.body.scrollTop
            + document.documentElement.scrollTop;
    }



/*display the box at 15px from the mouse pointer*/
	obj = document.getElementById("boxAlerteHelp");
	obj.style.left = (x + 5) + 'px';
	obj.style.top = (y+5) + 'px';
	obj.style.display = 'block';
}

function closeBoxAlerte()
{
/*Hide the box on close event*/
	obj = document.getElementById("boxAlerteHelp");
	obj.style.display = 'none';
}

     function CheckAlerteNewsletterThenSubmit(email,sending){
				var dosubmit = false;
				//box1
				if($("from_1").value!='' && $("to_1").value!=''){			
					dosubmit = true; 
				}			
				//box2
				if($("from_2").value!='' &&  $("to_2").value!=''){			
					dosubmit = true; 
				}	
				//box3
				if($("from_3").value!='' && $("to_3").value!=''){			
					dosubmit = true; 
				}
				
				
				var idofcontainer = 'nlalErrorSubmit';
				for(i=1;i<4;i++){
					if($('from_' + i).value!='' && $('to_' + i).value!=''){
						DidYouMean($('from_' + i).value,$('to_' + i).value,'from_' + i,'to_' + i, idofcontainer);
						if($(idofcontainer).hasClassName('on')) return false;	
					}
				}
				//submit if
				if(dosubmit==false){
					alert('Va rugam sa completati cel putin o alerta de tarif Vola.ro!!!');	
					return false;		
				}
				//check email
				if(email==''){
					if(!isEmail(document.getElementById("alerte_email").value,false) ){	
						warnEmpty (document.getElementById("alerte_email"), "email","error_price");
						document.getElementById("alerte_email").focus();		
						return false;
					} 
				}else{
					email = document.getElementById("alerte_email").value;		
				}
				
				submitFormAlerteNewsletter(email,sending);				
		
		}
		
		function submitFormAlerteNewsletter(email,sending){
			//var alerte_limit = ''; 
			//if($('alerte_limit').checked){
			//	alerte_limit  = '&alerte_limit=1'
			//}
			var radioGrp = document['forms']['alerte_fake_form']['frequency'];
			for(i=0; i < radioGrp.length; i++){
				if (radioGrp[i].checked == true) {
					var radioValue = radioGrp[i].value;
				}
			}
			var html = '';
			new Ajax.Updater(
							"alerte_messages", 
							"/alerte_newsletter_insert.php?from_1=" + $("from_1").value + '&to_1=' + $("to_1").value + '&price_1=' + $("price_1").value + '&from_2= ' + $("from_2").value + '&to_2=' + $("to_2").value + '&price_2=' + $("price_2").value + '&from_3= ' + $("from_3").value + '&to_3=' + $("to_3").value + '&price_3=' + $("price_3").value + '&alerte_email=' + email  + '&frequency=' + radioValue + '&sending=' + sending, 
							{	
								parameters: { text: 'loading'},
								method: 'get',
								onComplete:function(transport){ 
									var notice = $('alerte_messages');
									
									if (transport.responseText.match(/####OK####/)){
										 //new ajax call to change the display										
										 $("alerte_messages").innerHTML = '';
										
										
										    html =  '<table cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="position:relative;" width="580"><tr><td height="35" bgcolor="#006699" style="padding:5px"><span style="float:right"><a style="color:#FFFFFF" href="javascript:;" onclick="Control.Modal.close()">X close</a></span><h3 style="color:#FFFFFF">&nbsp;</h3></td></tr>'; 
									        html += '<tr><td style="padding:5px"><h3 style="color:#006699">Alertele tale au fost salvate cu succes, acum verifica-ti emailul!</h3></td></tr></table>';	
											$("alnewscontainer").innerHTML = html;
											setTimeout("Control.Modal.close()",4000);
											
									}else{
										new Effect.Highlight('alerte_messages');																					
									}
								},							
								asynchronous:true, 
								evalScripts:true
							}
						);
			
		}