// === Get/Hide/Show/Toggle ===  src="suggest/base.js"

function ge()
{
  var ea;
  for( var i = 0; i < arguments.length; i++ ) {
    var e = arguments[i];
    if( typeof e == 'string' )
      e = document.getElementById(e);
    if( arguments.length == 1 )
      return e;
    if( !ea )
      ea = new Array();
    ea[ea.length] = e;
  }
  return ea;
}
function emailcheck2(mailValue) {
		var chk = false;
		for(i=0; i<mailValue.length; i++) {
			if(mailValue.charAt(i)=='@') {
				chk = true;
				break;
			}
		}
		return chk;
	}
function jquery_contactadv() {

	var url = "contact_adv.php";
	var advertisingID = $('#advertisingID').val();
	var fullname = $('#fullname').val();
	var company = $('#company').val();
	var phone = $('#phone').val();
	var email = $('#email').val();
	
	var message = $('#message').val();
	
	if (fullname=='' || company=='' || phone=='' || email=='' || message=='')
	{
		alert("Please fill all fields !");
		return false;
	}
	var check = emailcheck2(email)
	if (!check) {
		alert("Wrong type E-mail !");
		return false;
	}
	var data_post = "advertisingID=" + advertisingID + "&fullname=" + fullname + "&company=" + company
	 + "&phone=" + phone
	 + "&email=" + email
	 + "&message=" + message;
	
	
		$.ajax({
		   beforeSend: function(){
		    $('#loading-layer').show();
		   	$('#content_div').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
		   	$('#loading-layer').hide();
	   	 	$('#content_div').children().remove();
	     	$('#content_div').html(msg);
	     	$('#content_div').fadeTo("slow",1,function(){
				//changeBorder('.moi_nhat_border');
				//alert('Cache thanh cong !');
	     	});
		   }
		});
}
function jquery_send_post(valuekey,type) {

	var url = "js_post.php";
	var data_post = "valuekey=" + valuekey + "&type=" + type;
	
	//var url = $('.moi_nhat_path').val();
	//var total = $('.moi_nhat_total_page').val();
		$.ajax({
		   beforeSend: function(){
		   //$('#loading-layer').show();
		   //$('#content_div').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
	   	 	//$('#temp_div').children().remove();
	     	//$('#temp_div').html(msg);
		   }
		});
}

function jquery_updateBook() {

	var url = "js_bookhotel.php";
	var hotel_cityID = $('#hotel_cityID').val();
	var hotel_level = $('#hotel_level').val();
	var hotel_price = $('#hotel_price').val();
	if (hotel_cityID=='')
	{
		alert("Please choose city !");
		return false;
	}
	if (hotel_level=='')
	{
		alert("Please choose star !");
		return false;
	}
	var data_post = "hotel_cityID=" + hotel_cityID + "&hotel_level=" + hotel_level + "&hotel_price=" + hotel_price;
	
	
	//var total = $('.moi_nhat_total_page').val();
		$.ajax({
		   beforeSend: function(){
		    $('#loading-layer').show();
		   	$('#content_div').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
		   	$('#loading-layer').hide();
	   	 	$('#content_div').children().remove();
	     	$('#content_div').html(msg);
	     	$('#content_div').fadeTo("slow",1,function(){
				//changeBorder('.moi_nhat_border');
				//alert('Cache thanh cong !');
	     	});
		   }
		});
}