function uiblockmessage()
{
	return '<div style="background-color:#FFF; color:#000;padding-top:20px;"><img src="'+base_url+'images/loadingAnimation.gif"><br /><h2> Please wait...</h2></div>';
}
function faceboxmessage()
{
  return '<div align="center" ><img src="'+base_url+'images/loading.gif"></div>';	
}

function IsNumeric(strString)
   //  check for valid numeric strings	
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) blnResult=false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function printthis() {
    if (document.all) {
		if (navigator.appVersion.indexOf("5.0") == -1) {
            /*var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
           // WebBrowser1.outerHTML = "";	*/
		 self.print();
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}

function resetForm(id) {
	$('#'+id).each(function(){
	        this.reset();
	});
}


function toggle()
{
 /* $('input:checkbox').each(function() {
	   var el = $(this);
	   el.attr('checked', el.is(':checked') ? '' : 'checked');
   })*/
  if($("#checkall").val()=='Check All')
  {
	   $('input:checkbox').each(function() {
	     var el = $(this);
	     el.attr('checked', 'checked');
       })
	  $("#checkall").val('Uncheck All');
  }
  else
  {
	  $('input:checkbox').each(function() {
	   var el = $(this);
	   el.attr('checked', '');
      })
	 $("#checkall").val('Check All');
  }

}



function disableEnterKey(e,field,value)
{ 
    
	 var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
	 {
	    addarrayelement(field,value);
	    postairportcodes();
	    return false;
	 }
     else
          return true;
}

function daysInMonth(iMonth, iYear)
{
	return 32 - new Date(iYear, iMonth, 32).getDate();
}
function setOptions(month,year)
{
 var daysinmonth = daysInMonth(month, year);
 selbox = $('#seldays');
 if(month >=0 && month <=11)
 {
   selbox.children().remove();
   for(i=1;i<=daysinmonth;i++)
   {
	 selbox.append('<option value="'+i+'">'+i+'</option>');
   }
 }
 else
  selbox.children().remove();
}


function findValueCallback(event, data, formatted)
{
   var a = data[0].split(",");
   var field=this.id;
   $("#"+field).val(a[0]);
}

function trim(strText)
{ 
    // this will get rid of leading spaces 
   if(strText)
   {
    while (strText.substring(0,1) == '') 
        strText = strText.substring(1, strText.length);
    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == '')
        strText = strText.substring(0, strText.length-1);
   }
    return strText;
} 
<!--
function ontop() 
{
  if (document.layers) 
  {
        document.layers['ontop'].pageX = window.pageXOffset + 725;
        document.layers['ontop'].pageY = window.pageYOffset + 100;
  }
  else if (document.all)
  {
        document.all['ontop'].style.position = 'absolute';
        document.all['ontop'].style.posLeft = document.body.scrollLeft + 725;
        document.all['ontop'].style.posTop = document.body.scrollTop + 100;
  }
  setTimeout('ontop()',100);
} 

function hideloading()
{
	$("#loadingtable").hide();
	$("#maintable").show(1000);
}
function makehome()
{
  var addHomePage='http://www.abc.com/';
  theobj = document.anchors[0];
  theobj.style.behavior='url(#default#homepage)';
  theobj.setHomePage(addHomePage);
} 
function addmore(type)
{
  $("#number_of_menulink_"+type).val(parseInt($("#number_of_menulink_"+type).val())+1);
  var content =$("#div_menulink_"+type).html();
  var temp_content=$("#temp_content_"+type).html();
  $("#div_menulink_"+type).html(temp_content+content);
  
}


function onDoubleClick( ev )
{
	// Get the element which fired the event. This is not necessarily the
	// element to which the event has been attached.
	var element = ev.target || ev.srcElement;
	// Find out the div that holds this element.
	//element = element.parentNode;
	if ( element.nodeName.toLowerCase() == 'div')
	{
	  if( element.className.indexOf( 'editable' ) != -1 )
	  {
		replaceDiv( element );
		//alert();
		if(element.id.indexOf('email')!= -1)  
		  $("#email_content_div").show(1000);
		else if(element.id.indexOf('right')!= -1)  
		  $("#right_content_div").show(1000);
		else
		  $("#page_content_div").show(1000);
	  }
	  else
	  {
		  
		 element = ev.target || ev.srcElement;
		 if ( element.nodeName.toLowerCase() == 'div')
		 {
			 cdivid=element.id;
			if( element.className.indexOf( 'edit' ) != -1 )
			 {
				$("#"+cdivid).hide(1000);
				$("#"+cdivid+"_div").show(1000);
			 }
		  }
			 
		}
	}	
	
}

var editor;
function replaceDiv( div )
{
  if(editor)
    editor.destroy();
  editor=CKEDITOR.replace(div);
}

function getvalueandremoveeditor(table,field)
{
	if ( !editor )
		return;
	// Retrieve the editor contents. In an Ajax application, this data would be
	// sent to the server or used in any other way.
	document.getElementById( 'p_content' ).innerHTML = editor.getData();
	//document.getElementById( 'contents' ).style.display = '';
	// Destroy the editor.
	contentid=$("#contentid").val();
	value=$("#p_content").html();
	 $("#page_content_div").hide(1000);
	field= (field && field!='undefined') ? field : 'page_content';
	postcontentdata(field,value,contentid,false,table); 
	editor.destroy();
	editor = null;
}

function getemailcontentandremoveeditor()
{
	if ( !editor )
		return;
	document.getElementById( 'e_content' ).innerHTML = editor.getData();
	contentid=$("#contentid").val();
	value=$("#e_content").html();
	 $("#email_content_div").hide(1000);
	field='email_content';
	postcontentdata(field,value,contentid); 
	editor.destroy();
	editor = null;
}
function getrightcontentandremoveeditor(table)
{
	if ( !editor )
		return;
	document.getElementById( 'r_content' ).innerHTML = editor.getData();
	contentid=$("#contentid").val();
	value=$("#r_content").html();
	 $("#right_content_div").hide(1000);
	field='right_content';
	postcontentdata(field,value,contentid,false,table); 
	editor.destroy();
	editor = null;
}


function savedata(field,table)
{
  	contentid=$("#contentid").val();
	if(field)
	  value=$("#"+field+"_text").val();
   postcontentdata(field,value,contentid,false,table); 
}

function postcontentdata(field,value,contentid,isbool,table)
{
	if((field) && (value || value==0) && (contentid))
	 {
		// alert(value);
		// $.facebox('<div style="text-align:center" ><img src="'+base_url+'images/loading.gif"><br>Data Saving.....</div>');
		 if(table=="right_content")
		  var url=base_url+'right_content/contentupdate';
		 else if(table=="faq")
		  var url=base_url+'faq/faqupdate'; 
		 else if(table=="article")
		   var url=base_url+'article/articleupdate';
		   
		 else
		   var url=base_url+'admin/contentupdate';
		 $.blockUI({ message:  uiblockmessage() }); 
		 $.post(url, { field:field,value:value,contentid:contentid },
		 function(data){
		  $.unblockUI();
		    if(data=="1")
		    {
			 if(isbool)
			 {
				value=(value==1) ? 'Yes' : 'No'; 
			  }
		     $("#"+field).html(value);
			 $("#"+field).show(1000);
			 $("#"+field+"_div").hide(1000);
			 
			 
			 return true;
			}
		 else
		   return false;
		 });
		
	 }	
}


function savebottomlink(field,text,linkid)
{
	value=$("#"+linkid+"_bottom_"+text+"_text").val();
	if((field) && (value) && (linkid))
	 {
		 $.blockUI({ message:  uiblockmessage() }); 
		 $.post(base_url+'admin/bottomlinkupdate', { field:field,value:value,linkid:linkid },
		 function(data){
		   $.unblockUI();
		    if(data=="1")
		    {
		     $("#"+linkid+"_bottom_"+text).html(value);
			 $("#"+linkid+"_bottom_"+text).show(1000);
			 $("#"+linkid+"_bottom_"+text+"_div").hide(1000);
			 
			 
			 return true;
			}
		 else
		   return false;
		 });
		
	 }	
}

function savetopmenu(field,text,menu_id,type)
{
	value=$("#"+menu_id+"_"+field+"_text").val();
	if((field) && (value) && (menu_id))
	 {
		 $.blockUI({ message:  uiblockmessage() }); 
		 $.post(base_url+'menu/topmenuupdate', { field:field,value:value,menu_id:menu_id,type:type },
		 function(data){
		    if(data=="1")
		    {
		      $("#"+menu_id+"_"+field).html(value);
			  $("#"+menu_id+"_"+field).show(1000);
			  $("#"+menu_id+"_"+field+"_div").hide(500);
			  $.unblockUI();
			  return true;
			}
		 else
		 {
		   $.unblockUI();
		   return false;
		 }
		 });
	 }	
}


function managelink(op,id,type,link_of)
{
	if(id)
	{
		if(op=='ins')
		{
			if(link_of=='top')
		      url=base_url+'menu/insertlinks';
			else
			  url=base_url+'admin/insertlinks';
			
		}
		else
		{
			if(link_of=='top')
		      url=base_url+'menu/deletelink';
			else
			  url=base_url+'admin/deletelink';
			
	    }
	     $.blockUI({ message:  uiblockmessage() }); 
		 $.post(url, { content:id,type:type },
		 function(data){
		  if(data=="1")
		    {
			   window.location.reload( true );	 
		       return true;
			}
		 else
		 {
		   $.unblockUI();
		   return false;
		 }
		 });
	}
}
function setdisplayvalue(field,value,contentid)
{
 	postcontentdata(field,value,contentid,true)
}
function logout()
{
	var logoutlink=base_url+"account/signout";
	window.location=logoutlink;
}


function expandtellfriend() {
    /*$('html, body').animate({ scrollTop: 0 }, 400);
   */
     $("#tell_a_friend_link").animate({ height: 'hide', opacity: 'hide' }, 'slow');
     $('#tell_a_friend_form').animate({ height: 'show', opacity: 'show' }, 'slow', 'linear', function() { 
     if ($.browser.msie) 
       this.style.removeAttribute('filter'); 
      });  
}
function expandtellfriend_popup() 
{
  $.facebox(faceboxmessage());
  val="";
  url=base_url+"home/refer_friend_content";
  $.post(url,{val:val},function(data){
		   $.facebox(data);
	});
 }
function submit_tell()
{ 
  var err_type="Tell a friend error";
  sender=$("#senderemail").val();
  sendto=$("#sendto").val();
  comments=$("#comments").val();
  if(!sender)
  {
	jAlert("Please enter sender email",err_type);
	return;
  }
  if(!checkEmail(sender))
  {
	jAlert("Sorry! enter a valid sender email",err_type);
	return;
  }
  if(!sendto)
  {
	jAlert("Please enter email address to send",err_type);
	return;
  }
  if(!comments)
  {
	jAlert("Please enter comment",err_type);
	return;
  }
   $("#tell_friend_form").block({ message: '<img width="200" src="'+base_url+'images/loadingAnimation.gif">' }); 
   url=base_url+"account/tellafriend";
  
   return_val = $.ajax({
			  url: url,
			  global: false,
			  type: "POST",
			  data: ({sender:sender,sendto:sendto,comments:comments}),
			  dataType: "html",
			  async:false,
			  success: function(data){
	          			jAlert(data,err_type);
			  },
			  error:function(data){
				 jAlert(data,err_type);
	  		 },
			  complete:function(data){
				//  $("#tell_friend_form").unblock();
			  }
	     }).responseText;
  return true;
}	

function cancelall()
 {
     $("#tell_a_friend_link").animate({ height: 'show', opacity: 'show' }, 'slow');
     $("#tell_a_friend_form").animate({ height: 'hide', opacity: 'hide' }, 'slow');
	 $(".formError").remove();
	  


}

function tellfriendsubmit(){
          $("#tell_friend_form").validate().form();
         if($("#tell_friend_form").valid())
         {
	
         }
    }
function Success()
{
   
	$("#tell_friend_form").attr('style','');
	$("#tell_friend_form").hide();
   setTimeout('hidesucessmsg()', 3000);
}
function hidesucessmsg()
{
	$("#tell_a_friend_link").animate({ height: 'show', opacity: 'show' }, 'slow');
	//$(".ajaxSubmit").animate({ height: 'hide', opacity: 'hide' }, 'slow');
	$("#tell_a_friend_form").animate({ height: 'hide', opacity: 'hide' }, 'slow');
	$("#tell_friend_form").animate({ height: 'show', opacity: 'show' }, 'slow');
	$(".ajaxSubmit").remove();
}

function is_del($id,$isemail)
{
	 jConfirm('Do you really want to delete ?', 'Data Delete Confirmation', function(r)
	  {	
	   if(r)
	   {
		 window.location=base_url+"admin/delete_content/"+$id+"/"+$isemail;  
		 return true;
	   }
	   else
	   {
		 return false; 
	   }
	  });
}
function addmore_link(type)
{
  $("#number_of_menulink_"+type).val(parseInt($("#number_of_menulink_"+type).val())+1);
 // var content =$("#div_menulink_"+type).html();
  var temp_content=htmlcontent($("#number_of_menulink_"+type).val());
  $("#div_menulink_"+type).append(temp_content);
//  $("#div_menulink_"+type).html(temp_content+content);
}

function htmlcontent(id)
{
  var htcon='<div id="link_table_'+id+'"> <br><table width="600" align="left"><tr><td width="200"><input type="text" name="menu_link_1_text[]" value=""  /> </td><td width="200"><input type="text" name="menu_link_1_url[]" value=""  /></td><td width="200"><select name="menu_link_1_target[]" ><option value="_blank">_blank</option><option value="_parent">_parent</option><option value="_top">_top</option><option value="_self">_self</option></select></td><td width="100"><input name="" type="button" value="Remove" onclick="remove_link_table('+ id +')" /></td></tr></table></div>';
return htcon;
}


function remove_link_table(id)
{
 $("#link_table_"+id).remove();	
 $("#number_of_menulink_1").val(parseInt($("#number_of_menulink_1").val())-1);
}


function addmore_menu_item(type)
{
  $("#number_of_menu_item").val(parseInt($("#number_of_menu_item").val())+1);
  var temp_content=html_menu_content($("#number_of_menu_item").val());
  $("#div_menu_item").append(temp_content);
}

function html_menu_content(id)
{
  var htcon='<div id="menu_item_table_'+id+'"> <br><table width="700" align="left"><tr><td width="200"><input type="text" name="menu_item_text[]" value=""  /> </td><td width="200"><input type="text" name="menu_item_url[]" value=""  /></td><td width="200"><select name="menu_item_target[]" ><option value="_blank">_blank</option><option value="_parent">_parent</option><option value="_top">_top</option><option value="_self">_self</option></select></td><td width="200"><select name="menu_item_back_color[]" ><option value="blue">Blue</option><option value="orange">Orange</option><option value="red">Red</option></select></td><td width="100"><input name="" type="button" value="Remove" onclick="remove_menu_item('+ id +')" /></td></tr></table></div>';
return htcon;
}

function remove_menu_item(id)
{
 $("#menu_item_table_"+id).remove();	
 $("#number_of_menu_item").val(parseInt($("#number_of_menu_item").val())-1);
}

function Success()
{
  window.location = perdiem_url+"perdiem/ajaxreferenceload/1000/false"; 
}

function send_test_emai(content_id)
{
	var emails=$("#emails_to_send").val();
	if(content_id)
	{
		if(emails)
		{
		   $.blockUI({ message:  uiblockmessage() }); 	 
		   url=perdiem_url+"newsletter/send_test_email";
		   $.post(url, { content:content_id,emails:emails },function(data){
		    if(data=="1")
		     {
			   jAlert("Email Sent","Test Email Send");	 
			   $.unblockUI();
			 }
			 else
			 {
				 jAlert("Error Occured","Test Email Send");	 
				 $.unblockUI();
			 }
		   });
	    }
		else
		{
			jAlert("Pleaes Enter Email","Test Email Send");
		}
	}
	else
	{
	  jAlert("Sorry! Invalid Email Content","Test Email Send");
	}
}
function passforget_email()
{
  	  $.facebox(faceboxmessage());
	 $.post(perdiem_url+'account/loademailbox',{},
	 function(data){
		  $.facebox("<div id='forgetpassdiv'>"+data+"</div>");
	   });  
}
function validateemail()
{
  email=$("#email_text").val();
  $.blockUI({ message:  uiblockmessage() }); 	 
  $.post(perdiem_url+'account/validateemail',{email:email},
  function(data){
		  if(data==0)
		  {
		    $("#result_pan").html("<font color='red'><strong>Invalid Email Format</strong></font>");
		  }
		  else
		  {
			$.facebox("<div id='forgetpassdiv'>"+data+"</div>");   
		  }
		 $.unblockUI(); 
	   });
  
}
function checkanswer()
{
  email=$("#email").val();
  answer= $("#securityanswer").val();
  answer_2= $("#securityanswer_2").val();
  if(!answer){jAlert("Please answer security question 1"); return; }
  question2=$("#securityquestion_2").val();
  if(question2)
  {
   if(!answer_2){jAlert("Please answer security question 2"); return; }
  }
  $.blockUI({ message:  uiblockmessage() }); 	 
	 $.post(perdiem_url+'account/checksecurityanswer',{email:email,answer:answer,answer_2:answer_2,question2:question2},
	 function(data){
		  $.unblockUI();
		  if(data.error)
		  {
		  	$("#result_pan").html(data.msg);
			$("#question_table_container").hide();
		  }	
		  else	
		   $.facebox("<div id='forgetpassdiv'>"+data.msg+"</div>");
	   },'json');  
}
function checkEmail(email) 
{ 
 // var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
  var filter = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
  if (!filter.test(email)) 
  {
    return false;
  }
  else
   return true;
}
function file_upload()
{
	    var btnUpload=$('#upload');
		var status=$('#status');
		var contentid=$("#contentid").val();
		var filename=trim($('#link_url_text').val());
	     new AjaxUpload(btnUpload, {
			action: base_url+"admin/uploadheaderimage/"+filename+'/'+contentid,
			name: 'headerimage',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif|bmp)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Only JPG,JPEG, PNG or GIF files are allowed');
					return false;
				}
				status.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');
				//Add uploaded file to list
				if(response==="error"){
					$('<li></li>').appendTo('#files').text(file).addClass('error');
				} else{
					//$('#photo').html('');
					$("#header_photo").attr("src",base_url+'uploadedimage/loading.gif');
					d = new Date();
					$("#header_photo").attr("src",base_url+'uploadedimage/'+response+"?lastmod="+d.getTime());

					//$('#photo').html('<img src="'+base_url+'uploadedimage/'+response+'" alt="" /><br />'+file);
					$('#photo').show();
					$('#photo_div').hide();
					//$('<li></li>').appendTo('#files').html('<img src="'+base_url+'uploadedimage/'+response+'" alt="" /><br />'+file).addClass('success');
		
				}
			}
		});
	}
function refer_friend_file_upload()
{
	    var btnUpload=$('#upload');
		var status=$('#status');
		var filename='testimonial_img_small';
		   new AjaxUpload(btnUpload, {
			action: base_url+"admin/testimonial_image/"+filename,
			name: 'testimonial_img_small',
			onSubmit: function(file, ext){
				 if (! (ext && /^(png)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Only PNG files are allowed');
					return false;
				}
				status.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
			    status.text('');
				//Add uploaded file to list
				if(response==="error"){
					$('<li></li>').appendTo('#files').text(file).addClass('error');
				} else{
					//$('#photo').html('');
					//$("#header_photo").attr("src",base_url+'uploadedimage/loading.gif');
				    //d = new Date();
					//$("#header_photo").attr("src",base_url+'uploadedimage/'+response+"?lastmod="+d.getTime());

					//$('#photo').html('<img src="'+base_url+'uploadedimage/'+response+'" alt="" /><br />'+file);
					$('#photo').show();
					$('#photo_div').hide();
					//$('<li></li>').appendTo('#files').html('<img src="'+base_url+'uploadedimage/'+response+'" alt="" /><br />'+file).addClass('success');
		
				}
			}
		});
	}
function savepass(isloggedin)
{
  user= $("#uid").val();
  pass=$("#pass_text").val();
  conpass=$("#conpass_text").val();
  if(user)
  {
	  if(pass)
	  {
		  if(pass.length<4)
		  {
			  jAlert("Password Length Must Be Atleast 4 Characters","Password Change Confirmation");
			  return;
		  }
		  if(conpass)
		  {
			if(pass==conpass)
			{
			     $.blockUI({ message: uiblockmessage()}); 
				 $.post(perdiem_url+'account/updatepass',{user:user,pass:pass,islogin:isloggedin},
				 function(data){
					  $.unblockUI();
					  if(data==1)
					  {
						if(isloggedin==1)
						{
							 window.location =perdiem_url+"perdiem/ajaxreferenceload/5000/false"; 
						}
						else
						{
							$("#passdiv").hide();  
							$("#passdiv").html("<font color='green'><b>Password Changed Successfully</b></font>");
							$("#passdiv").show(2000);
							
						}
						// $.facebox.close();
					  }
					  else
					    jAlert("Error Occured","Password Change Confirmation");
					   //$.facebox(data);
				   });  
			}
			else
			{
			  jAlert("Sorry! Password does not match","Password Change Confirmation"); 
			}
		  }
		  else
		  {
			  jAlert("Please Confirm Password","Password Change Confirmation"); 
		  }
	  }
	  else
      {
		 jAlert("Please Enter Password","Password Change Confirmation"); 
	  }
  }
  else
  {
	  jAlert("Sorry! Invalid User","Password Change Confirmation");
  }
}

function send_pass_request(is_forget_email)
{
	title="Password Reset Request";
	first_name=$("#first_name").val();
	last_name=$("#last_name").val();
	company=$("#company").val();
	position=$("#position").val();
	email=$("#email").val();
	wrong_email=$("#wrong_email").val();
	phone=$("#phone").val();
	note=$("#note").val();
	if(!first_name){jAlert("Please enter first name",title); return; }
	if(!last_name){jAlert("Please enter last name",title); return; }
	if(!company){jAlert("Please enter company name",title); return; }
	if(!position){jAlert("Please enter your position",title); return; }
	if(!email){jAlert("Please enter your email to send new pass",title); return; }
	if(!phone){jAlert("Please enter your phone number",title); return; }
	security_answer_1='';security_answer_2='';
	if(!is_forget_email){security_answer_1=$('#securityanswer').val();security_answer_2=$('#securityanswer_2').val();}
	 $.blockUI({ message: uiblockmessage()}); 
	$.post(perdiem_url+'account/pass_request_to_admin',{first_name:first_name,last_name:last_name,company:company,position:position,email:email,wrong_email:wrong_email,phone:phone,is_forget_email:is_forget_email,security_answer_1:security_answer_1,security_answer_2:security_answer_2,note:note},
	 function(data){
		  $.unblockUI();
		  if(data.error)
		    jAlert(data.message,title);
		  else
		  {
			 $.facebox.close(); 
			 jAlert(data.message,title);
		  }
	   },'json');  
}

function load_affiliate_vacancy(type,company,position,airport)
{
	if(!company) return;
	company=(company) ? company : '';
	position=(position) ? position : '';
	airport=(airport) ? airport : '';
	if(company=='other')
	{
		type='code';
	}
	
	$.blockUI({ message: uiblockmessage()}); 
	$.post(base_url+'home/load_occupation',{type:type,company:company,position:position,airport:airport},
	 function(data){
		  $("#"+type+"_tr").html(data);
		  $.unblockUI();
	   });  
}
function promo_post()
{
	title="Get Promo Code Error";
	if(!$("#company").val())
	{
	 jAlert("Please select your company",title);
	 return false;
	}
	if(!$("#position").val())
	{
	 jAlert("Please select your position",title);
	 return false;
	}
	if(!$("#aiport").val())
	{
	 jAlert("Please select your base",title);
	 return false;
	}
	if(!$("#email").val())
	{
	 jAlert("Please enter email address for this promo code",title);
	 return false;
	}
	if(!checkEmail($("#email").val()))
    {
 	  jAlert("Please enter a valid email",title);
	  return false;
    }
	return true;
	//$("#promo_form").submit();
}

function add_promo_alias(promocode)
{
  alert_title="Promo alias entry";	 
  alias_name=$("#promo_alias_text").val();
  if(alias_name.length<4 || alias_name.length>10)
  {
	  jAlert("Please enter a name (4-10 characters)",alert_title);
	  return;
  }
   url=base_url+"my_affiliate/add_promocode_alias";
   $.blockUI({ message: uiblockmessage()}); 
   $.post(url,{promocode:promocode,promo_alias:alias_name},function(data)
   {
	 if(!data.error)
	 {
	   	 reload_promo_code(promocode);
	 }
	 else
	   $("#promo_msg_div").html(data.msg);
	 $.unblockUI();  
   },'json');
}
function reload_promo_code(promocode)
{
  $.blockUI({ message: uiblockmessage()});
  url=base_url+"my_affiliate/promocode_alias_format/"+promocode+"/"+1;
  $.post(url,{},function(data)
  {
	 $.unblockUI();  
	 $("#promo_alias").html(data);
  });
}
function erasedata(type,date,promocode)
{
	urllink="";
	date=(date)?date:'';
	if(type)
	{
		switch(type)
		{
		  case 'promocode':
		    urllink=perdiem_url+'promocode/delete_promo_alias/'+date;
		  break;
		}
		if(urllink)
		{
			jConfirm('Do you really want to delete ?', 'Perdiem Data Delete Confirmation', function(r)																		        					            {	
			   if(r)
			   {
				  $.blockUI({ message: uiblockmessage() });  
				  $.post(urllink,{},function (datac){
					$.unblockUI();	
					//alert(datac);
					 if(!datac)
					 {
						jAlert("Error Occured","Data Deletion");
					 }
					 else
					 {
						switch(type)
						{
						  case 'promocode':
						    reload_promo_code(promocode);
						  break;
						  default:
						  break;
						}
					 }
				  });
			   }
			   else
			   {
				   return false;
			   }
		   });
		}
	}
}



