var agt = navigator.userAgent.toLowerCase();
var ie = ( ( agt.indexOf( "msie" ) != -1 ) && ( agt.indexOf( "opera" ) == -1 ) );
var idTimeout = 0;
var baseDir = '';

function getAbsoluteLeft(objectId)
{
// Get an object left position from the upper left viewport corner
// Tested with relative and nested objects
o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}


function getAbsoluteTop(objectId)
{
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}


function hide_bar()
{
idTimeout = 0;
document.getElementById("idMarquee").style.left = "-200px";
if (page=='Learn') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgLearn")+document.getElementById("idImgLearn").offsetWidth/2-5)+'px';
	if (document.getElementById("idLearn") != null)
		document.getElementById("idLearn").style.display = "block";
	if (document.getElementById("idImgLearn") != null)
		document.getElementById("idImgLearn").src = baseDir+"/images/learn_g.gif";
} else {
	document.getElementById("idLearn").style.display = "none";
	if (document.getElementById("idImgLearn") != null)
		document.getElementById("idImgLearn").src = baseDir+"/images/learn.gif";
}
if (page=='Device') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgDevice")+document.getElementById("idImgDevice").offsetWidth/2-5)+'px';
	if (document.getElementById("idDevice") != null)
		document.getElementById("idDevice").style.display = "block";
	if (document.getElementById("idImgDevice") != null)
		document.getElementById("idImgDevice").src = baseDir+"/images/device_g.gif";
} else {
	if (document.getElementById("idDevice") != null)
		document.getElementById("idDevice").style.display = "none";
	if (document.getElementById("idImgDevice") != null)
		document.getElementById("idImgDevice").src = baseDir+"/images/device.gif";
}
if (page=='Plans') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgPlans")+document.getElementById("idImgPlans").offsetWidth/2-5)+'px';
	if (document.getElementById("idPlans") != null)
		document.getElementById("idPlans").style.display = "block";
	if (document.getElementById("idImgPlans") != null)
		document.getElementById("idImgPlans").src = baseDir+"/images/plans_g.gif";
} else {
	if (document.getElementById("idPlans") != null)
		document.getElementById("idPlans").style.display = "none";
	if (document.getElementById("idImgPlans") != null)
		document.getElementById("idImgPlans").src = baseDir+"/images/plans.gif";
}
if (page=='Experience') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgExperience")+document.getElementById("idImgExperience").offsetWidth/2-5)+'px';
	if (document.getElementById("idExperience") != null)
		document.getElementById("idExperience").style.display = "block";
	if (document.getElementById("idImgExperience") != null)
		document.getElementById("idImgExperience").src = baseDir+"/images/experience_g.gif";
} else {
	if (document.getElementById("idExperience") != null)
		document.getElementById("idExperience").style.display = "none";
	if (document.getElementById("idImgExperience") != null)
		document.getElementById("idImgExperience").src = baseDir+"/images/experience.gif";
}
if (page=='Shop') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgShop")+document.getElementById("idImgShop").offsetWidth/2-5)+'px';
	if (document.getElementById("idShop") != null)
		document.getElementById("idShop").style.display = "block";
	if (document.getElementById("idImgShop") != null)
		document.getElementById("idImgShop").src = baseDir+"/images/shop_g.gif";
} else {
	if (document.getElementById("idShop") != null)
		document.getElementById("idShop").style.display = "none";
	if (document.getElementById("idImgShop") != null)
		document.getElementById("idImgShop").src = baseDir+"/images/shop.gif";
}
if (page=='Support') {
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImgSupport")+document.getElementById("idImgSupport").offsetWidth/2-5)+'px';
	if (document.getElementById("idSupport") != null)
		document.getElementById("idSupport").style.display = "block";
	if (document.getElementById("idImgSupport") != null)
		document.getElementById("idImgSupport").src = baseDir+"/images/support_g.gif";
} else {
	if (document.getElementById("idSupport") != null)
		document.getElementById("idSupport").style.display = "none";
	if (document.getElementById("idImgSupport") != null)
		document.getElementById("idImgSupport").src = baseDir+"/images/support.gif";
}
}

function show_bar(id)
{
if (idTimeout != 0)
{
	clearTimeout(idTimeout);
	idTimeout = 0;
}
if (id == "")
	return;
hide_bar();
if (1==1) {
	if (document.getElementById("id"+page)!=null)
		document.getElementById("id"+page).style.display = "none";
	if (document.getElementById("id"+id)!=null)
		document.getElementById("id"+id).style.display = "block";
}
if (page!=id)
	document.getElementById("idImg"+id).src = baseDir+"/images/" + id.toLowerCase() + "_s.gif";
	document.getElementById("idMarquee").style.left = (getAbsoluteLeft("idImg"+id)+document.getElementById("idImg"+id).offsetWidth/2-5)+'px';
}


function unshow_bar()
{
idTimeout = setTimeout('hide_bar();',1000);
}

function startUp() {
	document.getElementById("idMarquee").style.top = (getAbsoluteTop("idLineUp") - 5)+'px';
	hide_bar();
}

var pi_width;
var pi_height;
var pi_top;
var pi_left;
var pi_bar;
function popup_size() {
	if((screen.width > 1024) && (screen.height > 768)) {
		pi_width = 1024+20;
		pi_height = 768+20;
		pi_bar= 'no';
	} else {
		pi_width = 800+16+(ie?20:0);
		pi_height = 600+16+(ie?20:0);
		pi_bar= 'yes';
	}
	pi_top = (screen.width - pi_width) /2;
	pi_left = (screen.height - pi_height) /2;
}

function popup_image(name) {
	var imgFile;
	popup_size();
	imgFile = baseDir+'/images/'+name ;
	window.open(imgFile, 'image', 'location=no,menubar=no,resizable='+pi_bar+',scrollbars='+pi_bar+',status=no,toolbar=no,height='+pi_height+',width='+pi_width+',left='+pi_left+',top='+pi_top);
}
