function isEmail (email){
	return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
}
//------------------Login-------------------
function sendFormLogin(){
	if($('#login').val()=='')
		return alert('Please fill your login!');
	if($('#pass').val()=='')
		return alert('Please fill your password!');
	$('#form-customer-login').submit();
}
function sendFormPassword(){
	if($('#email').val()=='')
		return alert('Please fill your email!');
	if(!isEmail($('#email').val()))
		return alert('Please fill correct email!');
	$('#form-customer-password').submit();
}
//----------------Customer details---------------------
function sendFormDetails(){
	if($('#cus_fname').val()=='')
		return alert('Please fill your First Name!');
	if($('#cus_lname').val()=='')
		return alert('Please fill your Last Name!');
	if($('#cus_email').val()=='')
		return alert('Please fill your Email address!');
	if(!isEmail($('#cus_email').val()))
		return alert('Please fill correct Email address!');
	$('#form-customer-login').submit();
}
function sendFormPass(){
	if($('#new_login').val()=='')
		return alert('Please fill your login!');
	if($('#new_password').val()=='' || $('#new_password2').val()==''){
		$('#new_password').val('');
		$('#new_password2').val('');
		return alert('Please fill your password!');
	}
	if($('#new_password').val()!=$('#new_password2').val()){
		$('#new_password').val('');
		$('#new_password2').val('');
		return alert('Password and confirmation are not equal!');
	}
	$('#form-customer-pass').submit();
}
//-------------------------------------
function doSaveAdditional(){
	$('#customer-additional-form').submit();
}
function doSavePassenger(){
	$('#customer-passenger-form').submit();
}
//-------------------------------------
//-------------------view order------------------
function doViewSection(n){
	// off
	$('.bal').addClass('bpl').removeClass('bal');
	$('.bac').addClass('bpc').removeClass('bac');
	$('.bards').addClass('bpr').removeClass('bards');
	// on
	$('#il'+n).addClass('bal').removeClass('bpl');
	$('#im'+n).addClass('bac').removeClass('bpc');
	$('#ir'+n).addClass('bards').removeClass('bpr');
	
	switch(n){
		case 1: file='order_journey.php'; break;
		case 2: file='order_passengers.php'; break;
		case 3: file='order_invoices.php'; break;
		case 4: file='order_documents.php'; break;
		case 5: file='order_additional.php'; break;
		case 6: file='help.php'; break;
	}
	$('#order-container').html('<div align="center"><img src="/images/loading.gif"></div>');
	$('#order-container').load('/ajax/customer/'+file, {or_id:or_id}, function(data){
		if(data){
			$('#order-contener').html(data);
			buttonEvent();
		}
		else $('#order-contener').html('<div align="center">Error. Try again.</div>');
	});
}
//------------------Pay Now-------------------
function doPayNow(){
	var w=990;
	var h=screen.height-50;
	var l=Math.floor((screen.width-w)/2);
	var t=Math.floor((screen.height-h)/2);
	var payWin=window.open('','payWin','width='+w+',height='+h+',top='+t+',left='+l+',resizable=Yes,scrollbars=Yes');
	$('#pay-form')
		.attr('action','/en/booking/payment/details.html?mode=client')
		.attr('target','payWin')
		.submit();
}
//------------------View Account-------------------
function doViewOrder(id){
	location.href='/en/customer/view_details.html?or_id='+id;
}
//-------------------------------------
function tableRowEvent(){
	$('.customer-table-row').hover(
		function(){$(this).css('background-color', '#b5d266');},
		function(){$(this).css('background-color', '');}
	);
}
$(document).ready(function () {
	tableRowEvent();
	$('.link-pass').click(function(){
		$('#div-form-login').hide();
		$('#div-form-password').show();
	});
	
});

