// JavaScript Document

$(document).ready(	function() 	{
	initAccent() ;	
});

function initAccent()
{
	var i = 0 ;
	var id ;
	var obj ;

/*
	// non jQuery code
	for (i = 0 ; i < 3 ; i++)
	{
		switch(i)
		{
			case 0:  id = "leftsection" ; break ;
			case 1:  id = "centersection" ; break ;
			case 2:  id = "rightsection" ; break ;
		}
		obj = document.getElementById(id) ;
		obj.onclick = function() { SelectPage(this.id) ; } ;
		obj.onmouseover = function() { HoverSection(this.id) ; } ;
		obj.onmouseout = function() { UnhoverSection(this.id) ; } ;
	}
*/

	$('#leftsection').bind('click', function() 	   { SelectPage(this.id) ; } );
	$('#leftsection').bind('mouseover', function() { HoverSection(this.id) ; } );
	$('#leftsection').bind('mouseout', function()  { UnhoverSection(this.id) ; } );

	$('#centersection').bind('click', function() 	   { SelectPage(this.id) ; } );
	$('#centersection').bind('mouseover', function() { HoverSection(this.id) ; } );
	$('#centersection').bind('mouseout', function()  { UnhoverSection(this.id) ; } );

	$('#rightsection').bind('click', function() 	   { SelectPage(this.id) ; } );
	$('#rightsection').bind('mouseover', function() { HoverSection(this.id) ; } );
	$('#rightsection').bind('mouseout', function()  { UnhoverSection(this.id) ; } );
/*
	var an = navigator.appName ;
	if (an == "Microsoft Internet Explorer")
	{
		an = navigator.appVersion ;
		var x = an.indexOf("MSIE 9", 0) ;
		
		if (x > -1)
		{
			an = "IE 9 users: Accent Travel's web site will viiew correctly if you switch to compatibiltiy mode. " ;
			an += "Press \"Alt\" key to view the IE menu. Go to \"Tools\" and select \"Compatibility View\"" ;
			alert(an) ;
		}
	}
*/	
	init() ; // call for footer menu
	
}


// the following eliminates the IE6 image flicker...
try {
 document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

var HLSection = '' ;

function SelectPage(id)
{
	var newloc = "" ;
	switch (id)
	{
		case "rightsectionimage" :
		case "rightsection" :
		case "rightsection_hover" :
			newloc = location.href + "business";
			break ;
	
		case "centersectionimage" :
		case "centersection" :
		case "centersection_hover" :
			newloc = location.href + "groups";
			break ;

		case "leftsectionimage" :
		case "leftsection" :
		case "leftsection_hover" :
			newloc = location.href + "leisure";
			break ;
			
		default:
			return ;
	}

	location.href = newloc ;
}

function HoverSection(id)
{
	if (id + "_hover" == HLSection)
		return ;

//	var obj = document.getElementById(id) ;
//	if (obj == null)
//		return ;

	HLSection = id + "_hover" ;

	switch(id)
	{
		case "leftsection" : 	$('#leftsection').attr("id", "leftsection_hover") ; break ;
		case "rightsection" : 	$('#rightsection').attr("id", "rightsection_hover") ; break ;
		case "centersection" : 	$('#centersection').attr("id", "centersection_hover") ; break ;
	}

/*	
	if (id == "leftsection" )
	{
		obj.id = "leftsection_hover" ;
	}
	else if (id == "rightsection")
	{
		obj.id = "rightsection_hover" ;

	}
	else if (id == "centersection") 
	{
		obj.id = "centersection_hover" ;
	}
*/	
}

function UnhoverSection(id)
{
	if (id != HLSection)
		return ;
/*
//	non jQuery
	var obj = document.getElementById(id) ;
	if (obj == null)
		return ;
*/
	// jQuery
	switch(id)
	{
		case "leftsection_hover" : 		$('#leftsection_hover').attr("id", "leftsection") ; break ;
		case "rightsection_hover" : 	$('#rightsection_hover').attr("id", "rightsection") ; break ;
		case "centersection_hover" : 	$('#centersection_hover').attr("id", "centersection") ; break ;
	}
/*
//	non jQuery
    if (id == "leftsection_hover")
	{
		obj.id = "leftsection" ;
	}
	else if (id == "rightsection_hover")
	{
		obj.id = "rightsection" ;		
	}
	else if (id == "centersection_hover")
	{
		obj.id = "centersection" ;		
	}
*/
	HLSection = "" ;		
}

function findPos(obj) 
{
	var curleft = curtop = 0 ;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft ;
		curtop = obj.offsetTop ;
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft ;
			curtop += obj.offsetTop ;
		}
	}
	alert(curleft + ", " + curtop) ;
//	return [curleft,curtop] ;
}


