function displaySection(display, displayId)
{
	var objDisplay = document.getElementById(displayId);
	
	if (display) {
            objDisplay.style.visibility = "visible"
            objDisplay.style.display    = ""            
    } else {
            objDisplay.style.visibility = "hidden"
            objDisplay.style.display    = "none"
    }
}
function displaySectionPosition(displayId)
{
	var objDisplay = document.getElementById(displayId);
	objDisplay.style.left    = (getWindowWidth()/2 + 30) + 'px'; 
	objDisplay.style.top    =  '385px';    
 }

function displayNoFlight(display, e)
{
	var objDisplay = document.getElementById('divNoFlight');
	
	if (display)
        {
            	objDisplay.style.visibility = "visible"
            	var posx = 0;
		var posy = 0;
					
		if (e.pageX || e.pageY) 	
		{
			posx = e.pageX; 						
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	
		{						
			posx = e.clientX;							
			posy = e.clientY; 
		}

		objDisplay.style.top = posy				
         	objDisplay.style.left = posx
    	} 
	else 
	{
            objDisplay.style.visibility = "hidden"
            objDisplay.style.display    = "none"
    	}
}

var newwin;
function launchwint(winurl,winfeatures)
{
	newwin = window.open(winurl,'newwindow',winfeatures);
	//if(javascript_version > 1.0)
	//{
 		setTimeout('newwin.focus();',250);
	//}
}
function dateDiff(form)
{	
	var date1 = eval('document.' + form + '.date1');	
	var date2 = eval('document.' + form + '.date2');	
	var tmp;
	
	tmp = date1.value.split('/');
	myDate1 = new Date('20' + tmp[2], tmp[1]-1, tmp[0]);
	tmp = date2.value.split('/');
	myDate2 = new Date('20' + tmp[2], tmp[1]-1, tmp[0]);
	tmp = 1000*60*60*24;	
	
	//return Math.ceil(((myDate2.getTime()-myDate1.getTime())/tmp));


	var timeDiff = myDate2.getTime() - myDate1.getTime(); 
	var timezoneOffset = (myDate2.getTimezoneOffset() - myDate1.getTimezoneOffset())  * 1000 * 60; 

    	return(Math.ceil((timeDiff - timezoneOffset) / tmp)); 

}



function validateDate(str){
  var dateVar = new Date(convertDate(str));

  if(isNaN(dateVar.valueOf()) || (dateVar.valueOf() ==0))
	 return false;
  else
	 return true;
}

function setENewsAction(selection)
{
	document.frmEnewsLetters.selection.value = selection;
}
function submit_enews()
{
	if (document.frmEnewsLetters.txtEmail.value == "")
	{
		alert("Please enter your email");
		return false;	
	}
	
		
	if (document.frmEnewsLetters.checkExist.value == 0)
	{
		document.frmEnewsLetters.target = 'IfProcess';
		document.frmEnewsLetters.action = "/ENewsLetters/checkExist.asp";
		
	}
	document.frmEnewsLetters.submit();
}

var mapImages=new Array()
function preloadMaps()
{	
	for (var index=0; index < 11; index++)
		mapImages[index] = new Image();
		
	mapImages[0].src = "/images/maps/map-default.gif"
	mapImages[1].src = "/images/maps/map-africa.gif"
	mapImages[2].src = "/images/maps/map-asia.gif"	
	mapImages[3].src = "/images/maps/map-australia.gif"
	mapImages[4].src = "/images/maps/map-europe.gif"
	mapImages[5].src = "/images/maps/map-india.gif"
	mapImages[6].src = "/images/maps/map-meast.gif"
	mapImages[7].src = "/images/maps/map-canada.gif"
	mapImages[8].src = "/images/maps/map-pacific.gif"
	mapImages[9].src = "/images/maps/map-usa.gif"
	mapImages[10].src = "/images/maps/map-uk.gif"	
}
function setMapImage(id)
{
	document.getElementById('WorldMap').src = mapImages[id].src;	
	displayMapAreas(id);	
}
function displayMapAreas(id)
{
	for (var index=1; index <= 10; index++)
		displaySection(false, 'GlobalArea_' + index);
	
	if (id !=0)
		//displaySection(false, 'GlobalArea_' + id);
	//else
		displaySection(true, 'GlobalArea_' + id);
}
function getWindowHeight()
{
	if(navigator.appName == 'Microsoft Internet Explorer')	
		return document.body.clientHeight;
	else	
		return window.innerHeight;	
}
function getWindowWidth()
{
	if(navigator.appName == 'Microsoft Internet Explorer')	
		return document.body.clientWidth;
	else	
		return window.innerWidth;	
}
function setMapDetailListPosition()
{
	for (var index=1; index <= 10; index++)
		displaySectionPosition('GlobalArea_' + index);
}

//temp
function showChildren(name)
{
    var i = 0;
    numChildren = document.forms[name].dynamic_children.options[document.forms[name].dynamic_children.selectedIndex].value;
    if (numChildren == 0) 
	    displaySection(false, 'divChildAges');
     else 
	    displaySection(true, 'divChildAges');

    for (i=numChildren; i<=4; i++) 
	    if (i > 0)
		    displaySection(false, 'childId'+i);

    // show children
    for (i=1; i<=numChildren; i++) 					
	    displaySection(true, 'childId'+i);	
}	


function convertDate(inDate)
{
    var day   = inDate.substr(0, 2);
    var month = inDate.substr(3, 2);
    var year  = inDate.substr(6, 2);

 
    var date = month + '/' + day + '/20' + year;

    return(date);
}



