

<!--

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function OpenBlock() { //v6.0
  var i,p,v,obj,args=OpenBlock.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function clearInputText(input){
if (input.defaultValue==input.value)
input.value = ""
} 




//----------------------------------------------------------------------
// email validation
//----------------------------------------------------------------------
function isValidEmail(email, required) {
	

    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    }
	
    return true;
}

//----------------------------------------------------------------------
// Generic terms validation
// Venkat on July15, 2009
//----------------------------------------------------------------------
function isStartedWithGenericTerms(email, required)
{
	if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
	//match() is a case sensitive and returns null if its not matched else returns string that matched.
	email = email.toLowerCase();
	if (email.match(/^(info@|sales@|help@|security@|support@|webmaster@|admin@)/) != null)
	{
		if (required) {
			return false;
		}
	} else{	return true; }
	return true;
}
//----------------------------------------------------------------------
// Generic terms validation ends.
//----------------------------------------------------------------------

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
//-->

//----------------------------------------------------------------------
// Minimum Characters in a field
//----------------------------------------------------------------------

function isValidLength(string, lenght) {
   return (trimWhitespace(string).length > lenght)
}

//----------------------------------------------------------------------
// Maximum Characters in a field (textarea)
// Validates onchange()
//----------------------------------------------------------------------

function SetTextAreaLimit(ControlToValidate, max, CharCountLabel)
{
	if (ControlToValidate.value.length > max)
	{	
		ControlToValidate.value = ControlToValidate.value.substring(0,max);
	}
	if (CharCountLabel)
	{
		// Optional
		if (ControlToValidate.value.length == max)
		{
			CharCountLabel.value = "<span class='Error'>" + ControlToValidate.value.length + "</span>";				
		}
		else
		{
			CharCountLabel.value = ControlToValidate.value.length;				
		}
	}
}


//----------------------------------------------------------------------
// Remove leading and trailing whitespace from a string
//----------------------------------------------------------------------

function trimWhitespace(string) {
   var newString  = '';
   var substring  = '';
   beginningFound = false;
   
   // copy characters over to a new string
   // retain whitespace characters if they are between other characters
   for (var i = 0; i < string.length; i++) {
      
      // copy non-whitespace characters
      if (string.charAt(i) != ' ' && string.charCodeAt(i) != 9) {
         
         // if the temporary string contains some whitespace characters, copy them first
         if (substring != '') {
            newString += substring;
            substring = '';
         }
         newString += string.charAt(i);
         if (beginningFound == false) beginningFound = true;
      }
      
      // hold whitespace characters in a temporary string if they follow a non-whitespace character
      else if (beginningFound == true) substring += string.charAt(i);
   }
   return newString;
}

//----------------------------------------------------------------------
// Function to set the visibility of a Div Section (Divname)
// Base on a Specific Value selected in a ListBox
//----------------------------------------------------------------------
	function ShowHideDivFromList(divname,ListName,valueToSeach)
	{
		document.getElementById(divname).style.display = "none";

		var ddl = document.getElementById(ListName);
		for (i=0;i<ddl.options.length;i++){
			if (ddl.options[i].selected==true && ddl.options[i].value == eval(valueToSeach)){
				document.getElementById(divname).style.display = "block";
			}
		}
	}	
//----------------------------------------------------------------------
// Function to set the visibility of a Div Section (Divname)
// Base on a Specific Value selected in a DropDownList
//----------------------------------------------------------------------
	function ShowHideDivFromDDL(divname,DropDownListToSearch,valueToSeach)
	{
		document.getElementById(divname).style.display = "none";

		var ddl = document.getElementById(DropDownListToSearch);
		if (ddl.options[ddl.selectedIndex].value == eval(valueToSeach)){
			document.getElementById(divname).style.display = "block";
		}		
	}	
	
	
//----------------------------------------------------------------------
// Function for Bookmarks 
// Used in the APP templates
//----------------------------------------------------------------------


  function bookmark() 
  {
	var bookmarkurl="http://www.iata.org"
	var bookmarktitle="International Air Transport Association"

	window.external.AddFavorite(bookmarkurl,bookmarktitle);
  }

//----------------------------------------------------------------------
//Check and return an Element
//----------------------------------------------------------------------
  function getElement(id) {
    var getElem, elem;
    
    if (document.getElementById) {        
        if (elem = document.getElementById(id)) {
          return elem; 
        }
    }
    return null; 
  }

//----------------------------------------------------------------------
//ShowHides Section If Exist
//----------------------------------------------------------------------
  function ShowHidesDiv(divName){

	//--------------------------------------
	// Check if Div Section Exist
	//--------------------------------------
	var divSection;
	if(divSection = getElement(divName)){

		//--------------------------------------
		// Check if Section is visible or not
		//--------------------------------------
		if(divSection.style.display == "none"){
			//--------------------------------------
			// Set the oposite value (true)
			//--------------------------------------
			divSection.style.display = "";
		}
		else{
			//--------------------------------------
			// Set the oposite value (false)
			//--------------------------------------
			divSection.style.display = "none";

		}
	}
  }

//-------------------------------------------------
// No Trim function in Javascript ! 
// Wow what a language !
//-------------------------------------------------
String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};
