// AirSquare.ca Web Site

// Browser Check
var agt=navigator.userAgent.toLowerCase();
var is_ie    = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_opera = (agt.indexOf('opera')!=-1);
var is_nav   = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_opera = (agt.indexOf('opera')!=-1);

// Global variables
var curElem = null;
var formError = false;

// Image swapping
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_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_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;		
	x.oSrc=x.src; x.src=a[i+2];

	//Track current menu - Start
	imgSrc = x;
	imgOver = x.src;	
	imgOut = x.oSrc;
	//Track current menu - End
   }
}

// Positioning functions
function reposition() {
	menuDiv = document.getElementById("menu" + curMenu);
	menupos = document.getElementById("menuImg");
	
	if(is_nav) {
		menuDiv.style.left = findPosX(menupos) + 11 + "px";
		menuDiv.style.top = findPosY(menupos) + 7 + "px";
	}
	if(is_ie) {
		menuDiv.style.left = findPosX(menupos) + 22;
		menuDiv.style.top =  findPosY(menupos) + 22;
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// Show Content Area

function showContent(title, source) {
	resetContent();
	var maindiv = document.getElementById("contentLayer");
	var contentTitle = document.getElementById("contentTitle");
	var contentFrame = document.getElementById("contentFrame");
	contentTitle.innerHTML = title;
	contentFrame.src = source;
	maindiv.style.display = "inline";
	maindiv.style.visibility = "visible";
}

function dispCustomContent(content) {

	if (content == "microlife") {
		showCustomContent('New Releases:', 'microlife.html', '275px', '-378px', '140px', '750px', 0.9);
	}
	
	if (content == "microlifefr") {
		showCustomContent('Communiqu&eacute;s:', 'microlife.html', '275px', '-378px', '140px', '750px', 0.9);
	}
	
	if (content == "alvesco") {
		showCustomContent('New Releases:', 'alvesco.html', '275px', '-378px', '140px', '750px', 0.9);
	}
	
	if (content == "alvescofr") {
		showCustomContent('Communiqu&eacute;s:', 'alvesco.html', '275px', '-378px', '140px', '750px', 0.9);
	}
	
	if (content == "forum") {
		showContent('Air Square Discussion Forum:', 'reset.html');	
		showCustomContent('Air Square Discussion Forum:', 'forum/index.php', '118px', '-378px', '650px', '750px', 1);	
	}
	
	if (content == "forumfr") {
		showContent('Foire alimentaire:', 'reset.html');	
		showCustomContent('Foire alimentaire:', '/forum/index.php', '118px', '-378px', '650px', '750px', 1);	
	}
	
	if (content == "athletes") {
		showCustomContent('If they can do it, you can do it!:', 'sportsb.html', '118px', '-338px', '300px', '400px', 0.9);
	}
	
	if (content == "athletesfr") {
		showCustomContent('Athl&egrave;tes avec l&rsquo;asthme:', 'sportsb.html', '118px', '-338px', '300px', '400px', 0.9);
	}
	
	if (content == "monitor") {
		showCustomContent('Asthma Resources:', 'resource.html', '305px', '-378px', '110px', '500px', 0.9);
	}
	
	if (content == "monitorfr") {
		showCustomContent('Des ressources sur l&rsquo;asthme:', 'resource.html', '305px', '-378px', '110px', '500px', 0.9);
	}
	
	if (content == "news") {
		showCustomContent('Breaking News:', 'news.html', '175px', '-378px', '240px', '750px', 0.9);
	}
	
	if (content == "newsfr") {
		showCustomContent("Derni&egrave;re heure:", 'news.html', '275px', '-378px', '140px', '750px', 0.9);
	}
	
	if (content == "skate") {
		showCustomContent('Hockey Tips:', 'hockeytips.html', '175px', '-378px', '140px', '400px', 0.9);
	}
}

function showCustomContent(title, source, top, left, height, width, opacity) {
	resetContent();
	
	var maindiv = document.getElementById("contentLayer");
	var contentTitle = document.getElementById("contentTitle");
	var contentFrame = document.getElementById("contentFrame");
	contentTitle.innerHTML = title;
	contentFrame.src = source;
	contentFrame.height = height;
	
	maindiv.style.top = top;
	maindiv.style.marginLeft = left;
	maindiv.style.width = width;
	maindiv.style.MozOpacity = opacity;
	maindiv.style.filter ="alpha(opacity="+ (opacity * 100) +")";
	
	maindiv.style.display = "inline";
	maindiv.style.visibility = "visible";
}

function resetContent() {
	var maindiv = parent.document.getElementById("contentLayer");
	var contentTitle = parent.document.getElementById("contentTitle");
	var contentFrame = parent.document.getElementById("contentFrame");
	contentTitle.innerHTML = "";
	contentFrame.src = "reset.html";
	contentFrame.height = 300;
	
	maindiv.style.top = "118px";
	maindiv.style.marginLeft = "-375px";
	maindiv.style.width = "750px";
	maindiv.style.MozOpacity = 0.9;
	maindiv.style.filter ="alpha(opacity="+ (0.9 * 100) +")";
}

function showLink(title, source) {
	resetContent();
	var maindiv = parent.document.getElementById("contentLayer");
	var contentTitle = parent.document.getElementById("contentTitle");
	var contentFrame = parent.document.getElementById("contentFrame");
	contentTitle.innerHTML = title;
	contentFrame.src = source;
	maindiv.style.display = "inline";
	maindiv.style.visibility = "visible";
}

function printContent() { 

	if(is_ie) {
		document.contentFrame.focus(); 
		document.contentFrame.print(); 
	} 
	else { 
		window.frames['contentFrame'].focus(); 
		window.frames['contentFrame'].print(); 
	}
} 

function hideContent() {
	resetContent();
	var maindiv = document.getElementById("contentLayer");
	maindiv.style.visibility = "hidden";
	maindiv.style.display = "none";
}

