var txthomeon= new Image()
txthomeon.src = "images/txt_home_on.gif"
var txthomeoff= new Image()
txthomeoff.src = "images/txt_home_off.gif"

// The following 4 lines were added on July 6, 2009 to link to the french site
// Brian Devet
var txtlangon= new Image()
txtlangon.src = "images/txt_lang_on.gif"
var txtlangoff= new Image()
txtlangoff.src = "images/txt_lang_off.gif"

var txtgenworthon= new Image()
txtgenworthon.src = "images/txt_genworth_on.gif"
var txtgenworthoff= new Image()
txtgenworthoff.src = "images/txt_genworth_off.gif"

var txthabitaton= new Image()
txthabitaton.src = "images/txt_habitat_on.gif"
var txthabitatoff= new Image()
txthabitatoff.src = "images/txt_habitat_off.gif"

var txtcontacton= new Image()
txtcontacton.src = "images/txt_contact_on.gif"
var txtcontactoff= new Image()
txtcontactoff.src = "images/txt_contact_off.gif"

var tabstudenton= new Image()
tabstudenton.src = "images/nav_student_on.gif"
var tabstudentoff= new Image()
tabstudentoff.src = "images/nav_student_off.gif"

var tabparenton= new Image()
tabparenton.src = "images/nav_parent_on.gif"
var tabparentoff= new Image()
tabparentoff.src = "images/nav_parent_off.gif"

var tabteacheron= new Image()
tabteacheron.src = "images/nav_teacher_on.gif"
var tabteacheroff= new Image()
tabteacheroff.src = "images/nav_teacher_off.gif"

var tabconteston= new Image()
tabconteston.src = "images/nav_contest_on.gif"
var tabcontestoff= new Image()
tabcontestoff.src = "images/nav_contest_off.gif"

var tabcommunityon= new Image()
tabcommunityon.src = "images/nav_community_on.gif"
var tabcommunityoff= new Image()
tabcommunityoff.src = "images/nav_community_off.gif"

var butmoreinfoon= new Image()
butmoreinfoon.src = "images/but_moreinfo_on.gif"
var butmoreinfooff= new Image()
butmoreinfooff.src = "images/but_moreinfo_off.gif"

var butenteron= new Image()
butenteron.src = "images/but_enter_on.gif"
var butenteroff= new Image()
butenteroff.src = "images/but_enter_off.gif"

var butsubmiton= new Image()
butsubmiton.src = "images/but_submit_on.gif"
var butsubmitoff= new Image()
butsubmitoff.src = "images/but_submit_off.gif"

var butcancelon= new Image()
butcancelon.src = "images/but_cancel_on.gif"
var butcanceloff= new Image()
butcanceloff.src = "images/but_cancel_off.gif"

var tabreferon= new Image()
tabreferon.src = "images/nav_refer_on.gif"
var tabreferoff= new Image()
tabreferoff.src = "images/nav_refer_off.gif"

var tabmediaon= new Image()
tabmediaon.src = "images/nav_media_on.gif"
var tabmediaoff= new Image()
tabmediaoff.src = "images/nav_media_off.gif"

var tabwinnerson= new Image()
tabwinnerson.src = "images/nav_winners_on.gif"
var tabwinnersoff= new Image()
tabwinnersoff.src = "images/nav_winners_off.gif"


var tabwinnerson= new Image()
tabwinnerson.src = "images/nav_winners_on.gif"
var tabwinnersoff= new Image()
tabwinnersoff.src = "images/nav_winners_off.gif"


var contentBoxPreload= new Image()
contentBoxPreload.src = "images/ContentBox_ContestRules.png"

var contentBoxPreload= new Image()
contentBoxPreload.src = "images/ContentBox_ContestDates.png"

var contentBoxPreload= new Image()
contentBoxPreload.src = "images/ContentBox_Prizes.png"

var contentBoxPreload= new Image()
contentBoxPreload.src = "images/ContentBox_HowToSubmit.png"

//Vithushan N
//June 17, 2011
//
//selected shows which of the four tabs is selected
var selected = "submit";

submit = new Image();
submit.src = 'images/btn_HowToSubmit.png'
submit_RO = new Image();
submit_RO.src = 'images/btn_HowToSubmit_over.png'
submit_ON = new Image();
submit_ON.src = 'images/btn_HowToSubmit_on.png'

rules = new Image();
rules.src = 'images/btn_ContestRules.png'
rules_RO = new Image();
rules_RO.src = 'images/btn_ContestRules_over.png'
rules_ON = new Image();
rules_ON.src = 'images/btn_ContestRules_on.png'

dates = new Image();
dates.src = 'images/btn_ContestDates.png'
dates_RO = new Image();
dates_RO.src = 'images/btn_ContestDates_over.png'
dates_ON = new Image();
dates_ON.src = 'images/btn_ContestDates_on.png'

prizes = new Image();
prizes.src = 'images/btn_Prizes.png'
prizes_RO = new Image();
prizes_RO.src = 'images/btn_Prizes_over.png'
prizes_ON = new Image();
prizes_ON.src = 'images/btn_Prizes_on.png'

function showImage(fname) {
iname=eval(fname + "on.src");
document[fname].src = iname;}

function hideImage(fname) {
iname=eval(fname + "off.src");
document[fname].src = iname;}


function OpenForm(link)
  {
window.open(link,'Screen','menubar=no,scrollbars=no,toolbars=no,resizable=no,location=no,width=700,height=600')
  }
  
function OpenGame(link)
  {
window.open(link,'Game','menubar=no,scrollbars=no,toolbars=no,resizable=no,location=no,width=800,height=600')
  }



//Rollovers and onclick images are image sprites. Three images into one. Show the top 43px for the off state, the middle 43xp for rollover state
//and show the last 43px for the on state. 
function onMouseOverHandler(id)
{
	if (selected != id) {
		if (id == 'submit') document.getElementById(id).src = submit_RO.src;
		else if (id == 'rules') document.getElementById(id).src = rules_RO.src;
		else if (id == 'dates') document.getElementById(id).src = dates_RO.src;		
		else if (id == 'prizes') document.getElementById(id).src = prizes_RO.src;
	}
		
}

function onClickHandler(id)
{

		
	selected = id;
	onMouseOutHandler('submit');
	onMouseOutHandler('rules');
	onMouseOutHandler('dates');
	onMouseOutHandler('prizes');
	
    //depending on which tab is selected change the colour of the content box and the text to match the selected tab
	if (selected == 'submit') {
		document.getElementById(id).src = submit_ON.src;
	    document.getElementById('contentBox').style.background = "url(images/ContentBox_HowToSubmit.png) no-repeat";
	    document.getElementById('contentText').innerHTML = "<tr><td ><p class='subText'><font color='FF931E'><b>Online:</b></font> Click 'Enter Now'</p><p class='subText'><font color='FF931E'><b>Mail:</b> </font>Mail your submission with your name, address and phone number to: </p><p class='subText'>The Meaning of Home Writing Contest<br />P.O. Box 4446, STN. Industrial Park<br />Markham, Ontario L3R 6G9<br><br /> Entries must be submitted between<br />October 3 and November 14, 2011  </p> </td></tr>  ";

	}	

	if (selected == 'rules') {
		document.getElementById(id).src = rules_ON.src;
	    document.getElementById('contentBox').style.background = "url(images/ContentBox_ContestRules.png) no-repeat";
		document.getElementById('contentText').innerHTML =  "<tr><td><p class='subText'> You must be a Canadian student in grades 4, 5, or 6 who is living in Canada at the time of the contest.</p><p class='subText'>Write a composition, essay or poem (between 50 and 300 words) telling us what home means to you and complete the entry form online, or mail us your entry in an envelope. Entries must be submitted between October 3 and November 14, 2011.</p><p class='subText'> <a  href='entry.html'><b><u><font color='7AC943'>Learn More...</font></u></b></a></p></td></tr>"; 

	}	 

	if (selected == 'dates') {
		document.getElementById(id).src = dates_ON.src;
	    document.getElementById('contentBox').style.background = "url(images/ContentBox_ContestDates.png) no-repeat";
	    document.getElementById('contentText').innerHTML = "<tr><td><p class='subText'>Contest starts at 12:01 AM ET on October 3, 2011 and continues until 11:59 PM ET on November 14, 2011.</p><p class='subText'>Starting the week of November 28, 2011, a panel of judges will select 24 Semi-Finalists from all eligible entries received during the Contest Period.</p><p class='subText'>Starting December 12, 2011 at 12:01 AM ET, 24 Semi-Finalist entries will be posted here for viewing. </p><p class='subText'><a  href='entry.html'><b><u><font color='2461AA'>Learn More...</font></u></b></a></p></td></tr>";
	}	
	if (selected == 'prizes') {
		document.getElementById(id).src = prizes_ON.src;
		document.getElementById('contentBox').style.background = "url(images/ContentBox_Prizes.png) no-repeat";
		document.getElementById('contentText').innerHTML = "<tr><td ><ul style='margin:0px;padding-left:15px;height:13px'><a class='prizeLinkOn' href='javascript://null' onClick='grandprize()'>Grand Prize</a> | <a class='prizeLink' href='javascript://null' onClick='secondprize()'>2nd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='thirdprize()'>3rd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='allprize()'>All</a><br /><br /><li>An Apple iPad 2 64GB with Wi-Fi</li><li>An Apple Wireless Keyboard</li><li>An Incase Origami Workstation</li><li>A pizza party for the winner's entire school</li><br />We will also donate $60,000 towards the building of a new Habitat for Humanity home in a community of your choice!<br /><a class='prizeLink'  href='entry.html'><b><u><font color='3FA9F5'>Learn More...</font></u></b></a></ul>";
	}	 


}

	function grandprize() {
		document.getElementById('contentText').innerHTML = "<tr><td ><ul style='margin:0px;padding-left:15px;height:13px'><a class='prizeLinkOn' href='javascript://null' onClick='grandprize()'>Grand Prize</a> | <a class='prizeLink' href='javascript://null' onClick='secondprize()'>2nd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='thirdprize()'>3rd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='allprize()'>All</a><br /><br /><li>An Apple iPad 2 64GB with Wi-Fi</li><li>An Apple Wireless Keyboard</li><li>An Incase Origami Workstation</li><li>A pizza party for the winner's entire school</li><br />We will also donate $60,000 towards the building of a new Habitat for Humanity home in a community of your choice!<br /><a class='prizeLink'  href='entry.html'><b><u><font color='3FA9F5'>Learn More...</font></u></b></a></ul>";
	}	
	
	function secondprize() {
		document.getElementById('contentText').innerHTML = "<tr><td ><ul style='margin:0px;padding-left:15px;height:13px'><a class='prizeLink' href='javascript://null' onClick='grandprize()'>Grand Prize</a> | <a class='prizeLinkOn' href='javascript://null' onClick='secondprize()'>2nd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='thirdprize()'>3rd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='allprize()'>All</a><br /><br /><li>An Apple iPod Touch 8GB</li><li>A pizza party for your class</li><br />We will also donate a $5,000 grant to a Habitat for Humanity affiliate of your choice, which will support the building of a new home in that community.<br /><br /><a class='prizeLink'  href='entry.html'><b><u><font color='3FA9F5'>Learn More...</font></u></b></a>";
	}
	
	function thirdprize() {
		document.getElementById('contentText').innerHTML = "<tr><td ><ul style='margin:0px;padding-left:15px;height:13px'><a class='prizeLink' href='javascript://null' onClick='grandprize()'>Grand Prize</a> | <a class='prizeLink' href='javascript://null' onClick='secondprize()'>2nd Prize</a> | <a class='prizeLinkOn' href='javascript://null' onClick='thirdprize()'>3rd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='allprize()'>All</a><br /><br />There are eighteen Third Prizes available to be won, each consisting of one (1) Inukshuk.<br /><br /><a class='prizeLink'  href='entry.html'><b><u><font color='3FA9F5'>Learn More...</font></u></b></a>";
	}
	function allprize() {
		document.getElementById('contentText').innerHTML = "<tr><td ><ul style='margin:0px;padding-left:15px;height:13px'><a class='prizeLink' href='javascript://null' onClick='grandprize()'>Grand Prize</a> | <a class='prizeLink' href='javascript://null' onClick='secondprize()'>2nd Prize</a> | <a class='prizeLink' href='javascript://null' onClick='thirdprize()'>3rd Prize</a> | <a class='prizeLinkOn' href='javascript://null' onClick='allprize()'>All</a><br /><br />Each eligible entry received in the Contest will have $5.00 CAD donated to Habitat For Humanity location closest to their postal code or city of residence on each entrant’s behalf. 6,000 (six-thousand) eligible entries (a total of $30,000 CAD!) will be eligible for the Habitat For Humanity donation.<br /><br /><a  href='entry.html'><b><u><font color='3FA9F5'>Learn More...</font></u></b></a>";
	}	
	
	
function onMouseOutHandler(id)
{
	if (selected != id) {
		if (id == 'submit') document.getElementById(id).src = submit.src;
		else if (id == 'rules') document.getElementById(id).src = rules.src;
		else if (id == 'dates') document.getElementById(id).src = dates.src;		
		else if (id == 'prizes') document.getElementById(id).src = prizes.src;
	}
}


//added by Long

if (document.images){

  order = new Image();
  order.src = "images/order popup/btn_order_eng.png";
  
  order_on = new Image();
  order_on.src = "images/order popup/btn_order_eng_on.png";
  
  close_btn = new Image();
  close_btn.src = "images/close.png";
  
  close_btn_on = new Image();
  close_btn_on.src = "images/close_OVER.png";

}

function onMouseOverHandler_lightbox(id) {
	if(id == "order"){
		document.getElementById(id).src = order_on.src;
	}
	else if(id == "close"){
		document.getElementById(id).src = close_btn_on.src;
	}
}

function onMouseOutHandler_lightbox(id) {
	if(id == "order"){
		document.getElementById(id).src = order.src
	}else if(id == "close"){
		document.getElementById(id).src = close_btn.src;
	}
}



//-->





function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 350) + 10);
		level += 0.01;
	}
}


// Open the lightbox


function openbox(formtitle, fadin)
{
  var box = document.getElementById('box'); 
 // document.getElementById('shadowing').style.display='block';

 // var btitle = document.getElementById('boxtitle');
 // btitle.innerHTML = formtitle;
  
  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  	
}


// Close the lightbox

function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('shadowing').style.display='none';
}


