function uiblockmessage()
{
	return '<div style="background-color:#FFF; color:#FF0000;padding-top:20px;"><img src="'+base_url+'images/loadingAnimation.gif"><br /><h2> Please wait...</h2></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 logout()
{
	var logoutlink=base_url+"account/signout";
	window.location=logoutlink;
}

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 
    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()
{
  $("#number_of_bottom_link").val(parseInt($("#number_of_bottom_link").val())+1);
  var content =$("#bottom_link").html();
  var temp_content=$("#temp_content").html();
  $("#bottom_link").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 );
		$("#content_div").show(1000);
	  }
	  else
	  {
		 element = ev.target || ev.srcElement;
		 if ( element.nodeName.toLowerCase() == 'div')
		 {
			cdivid=element.id;
			$("#"+cdivid).hide(1000);
			$("#"+cdivid+"_div").show(1000);
		  }
			 
		}
	}	
	
}

var editor;

function replaceDiv( div )
{
	if ( editor )
		editor.destroy();

	editor = CKEDITOR.replace( div );
}

function getvalueandremoveeditor()
{
	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();
	 $("#content_div").hide(1000);
	field='definition';
	

	
	postcontentdata(field,value,contentid); 
	
	
	
	editor.destroy();
	editor = null;
}

function savedata(field)
{
  	contentid=$("#contentid").val();
	if(field)
	  value=$("#"+field+"_text").val();
   postcontentdata(field,value,contentid); 
}

function postcontentdata(field,value,contentid)
{
	if((field) && (value) && (contentid))
	 {
		// $.facebox('<div style="text-align:center" ><img src="'+base_url+'images/loading.gif"><br>Data Saving.....</div>');
		 $.blockUI({ message:  uiblockmessage() }); 
		 $.post(base_url+'admin/contentupdate', { field:field,value:value,contentid:contentid },
		 function(data){
		   $.unblockUI();
		    if(data=="1")
		    {
		     $("#"+field).html(value);
			 $("#"+field).show(1000);
			 $("#"+field+"_div").hide(1000);
			 
			 
			 return true;
			}
		 else
		   return false;
		 });
		
	 }	
}


function savebottomlink(field,text,linkid)
{
  	//linkid=$("#contentid").val();
	value=$("#"+linkid+"_bottom_"+text+"_text").val();
	if((field) && (value) && (linkid))
	 {
		// $.facebox('<div style="text-align:center" ><img src="'+base_url+'images/loading.gif"><br>Data Saving.....</div>');
		 $.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 savegloballink(field,text,linkid)
{
  	//linkid=$("#contentid").val();
	value=$("#"+linkid+"_"+field+"_text").val();
	if((field) && (value) && (linkid))
	 {
		// $.facebox('<div style="text-align:center" ><img src="'+base_url+'images/loading.gif"><br>Data Saving.....</div>');
		 $.blockUI({ message:  uiblockmessage() }); 
		 $.post(base_url+'global_links/linkupdate', { field:field,value:value,linkid:linkid },
		 function(data){
		   $.unblockUI();
		    if(data=="1")
		    {
		     $("#"+linkid+"_"+field).html(value);
			 $("#"+linkid+"_"+field).show(1000);
			 $("#"+linkid+"_"+field+"_div").hide(1000);
			 
			 
			 return true;
			}
		 else
		   return false;
		 });
		
	 }	
}
function manage_global_link(op,id)
{
	
	if(id)
	{
		if(op=='ins')
		{
			url=base_url+'global_links/insertlinks';
		}
		else
		{
			url=base_url+'global_links/deletelink';
	    }
	     $.blockUI({ message:  uiblockmessage() }); 
		 $.post(url, { content:id },
		 function(data){
		    if(data=="1")
		    {
			   window.location.reload( true );	 
		       return true;
			}
		 else
		 {
		   $.unblockUI();
		   return false;
		 }
		 });
	}
}

function managelink(op,id)
{
	if(id)
	{
		if(op=='ins')
		{
			url=base_url+'admin/insertlinks';
		}
		else
		{
			url=base_url+'admin/deletelink';
	    }
	     $.blockUI({ message:  uiblockmessage() }); 
		 $.post(url, { content:id },
		 function(data){
		    if(data=="1")
		    {
			   window.location.reload( true );	 
		       return true;
			}
		 else
		 {
		   $.unblockUI();
		   return false;
		 }
		 });
	}
}
