/* Alter "basePath" to be the base path to your website (usually this would be "/" unless the site is under development). */
var basePath="/HCCWR/StaticAssets/";

/*
schedule("window", initTables);
schedule("window", externalLinks);
schedule("window", startList);
*/


/* Author: Rebecca Skeers rebecca@webmistress.com.au, www.webmistress.com.au 2006 */
function popUp(URL, width, height)
{
	eval("window.open('" + URL + "', 'Image', 'width=" + width + ", height=" + height + ", location=0, menubar=1, statusbar=1, toolbar=0, scrollbars=1, resizable=1');");
}



function initTables()
{
	var tables = document.getElementsByTagName("table");

	for (var i = 0; i < tables.length; i++)
	{
          var element= tables[i].parentNode;

           while (tables[i].parentNode != null) {
            try {
               if (element.id == "primary-content") {
		applyStyle(tables[i]);
    		    }
               element = element.parentNode;

               } catch (e) { break; }
           }
       }
};


function applyStyle(Obj){

	        if (Obj.className == "data"){
		var tbody = Obj.getElementsByTagName("tbody")[0];
		var trs = Obj.getElementsByTagName("tr");
/* reset tables */
		for (var j = 0; j < trs.length; j ++)
		{
			trs[j].className = "";
		}
		for (var j = 1; j < trs.length; j += 2)
		{
			if (trs[j].className == "")
			{
				trs[j].className = "alt";
			}
			else if(!trs[j].className.match("alt"))
			{
				trs[j].className += " alt";
			}
		}
	
}
}



/* //http://www.sitepoint.com/article/standards-compliant-world */
function externalLinks() 
{
 	if (!document.getElementsByTagName) 
 		return;
 
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) 
 	{
   		var anchor = anchors[i];
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
     		anchor.target = "_blank";
 	}
}




/* Author: Rebecca Skeers rebecca@webmistress.com.au, www.webmistress.com.au 2005 */
function printPage() 
{
  	if (window.print)
		window.print()
	else
		alert("Sorry, your browser doesn't support the print feature. Use the File menu on your browser to select Print.");
}

/* Author: Rebecca Skeers rebecca@webmistress.com.au, www.webmistress.com.au 2006 */
function writePageFunctionsMenu()
{
	document.write('<ul>');
	document.write('<li><a href="javascript:printPage();" title="Print this page">print page</a> <a href="javascript:printPage();" title="Print this page"><img src="'+basePath+'images/template/icon_print.gif" alt="Print this page" width="17" height="13" /></a></li>');
	document.write('<li><a href="mailto:?body=' + location + '" title="Email this page">email page</a> <a href="mailto:?body=' + location + '" title="Email this page"><img src="'+basePath+'images/template/icon_email.gif" alt="Email this page" width="17" height="13" /></a></li>');
	document.write('</ul>');
}

/* Author: Rebecca Skeers rebecca@webmistress.com.au, www.webmistress.com.au 2006 */
function homeImageRow(sectionNumber)
{
	numImages=23;
	rand1 = Math.ceil(Math.random() * numImages);
	rand2 = Math.ceil(Math.random() * numImages);
	if(rand2==rand1 && rand2==numImages)
		rand2=1;
	else if(rand2==rand1)
		rand2=rand1+1;

	document.write(
					'<img src="'+basePath+'images/template/home/banner1_f'+sectionNumber+'.gif" height="140" width="195" alt="Hobart, the way life should be" />' +				
					'<img src="'+basePath+'images/template/home/forRotation/homeImages_f'+rand1+'.jpg" height="140" width="195" alt="Hobart, the way life should be" />' +
					'<img src="'+basePath+'images/template/home/banner3_f'+sectionNumber+'.gif" height="140" width="195" alt="Hobart, the way life should be" />' +
					'<img src="'+basePath+'images/template/home/forRotation/homeImages_f'+rand2+'.jpg" height="140" width="195" alt="Hobart, the way life should be" />'
				);
	return;
}

/* Author: Rebecca Skeers rebecca@webmistress.com.au, www.webmistress.com.au 2006 */
function level2ImageRow(sectionNumber)
{
	numImages=23;
	rand1 = Math.ceil(Math.random() * numImages);
	rand2 = Math.ceil(Math.random() * numImages);
	if(rand2==rand1 && rand2==numImages)
		rand2=1;
	else if(rand2==rand1)
		rand2=rand1+1;

	document.write('<img src="'+basePath+'images/template/level2/banner1_f'+sectionNumber+'.gif" height="110" width="195" alt="Hobart, the way life should be" />');
	document.write('<img src="'+basePath+'images/template/level2/forRotation/level2Image_f'+rand1+'.jpg" height="110" width="195" alt="Hobart, the way life should be" />');
	document.write('<img src="'+basePath+'images/template/level2/banner3_f'+sectionNumber+'.gif" height="110" width="195" alt="Hobart, the way life should be" />');
	document.write('<img src="'+basePath+'images/template/level2/forRotation/level2Image_f'+rand2+'.jpg" height="110" width="195" alt="Hobart, the way life should be" />');
	return;
}

/* http://www.alistapart.com/articles/dropdowns */
function startList() 
{
	if (document.all&&document.getElementById) 
	{
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() 
				{
					this.className+=" hover";
  				}
  				node.onmouseout=function() 
  				{
  					this.className=this.className.replace(" hover", "");
   				}
   			}
  		}
 	}
}

/* Function to change between shown images on the North Hobart's Lightpoles page */
function ChangeThumbnails(num) {

	var ThumbnailsLocation = '/HCCWR/_assets/main/lib60149/';
	//var Number = num + '';

	ThumbnailsArea = document.getElementById('LightpoleThumbnails');

	ThumbnailsArea.innerHTML = '<a href="' + ThumbnailsLocation + num + 'a.jpg" target="new"><img alt="" src="' + ThumbnailsLocation + num + 'a-thumb.jpg" /></a>';
	ThumbnailsArea.innerHTML = ThumbnailsArea.innerHTML + '<br /><br /><br />';
	ThumbnailsArea.innerHTML = ThumbnailsArea.innerHTML + '<a href="' + ThumbnailsLocation + num + 'b.jpg" target="new"><img alt="" src="' + ThumbnailsLocation + num + 'b-thumb.jpg" /></a>';
	ThumbnailsArea.innerHTML = ThumbnailsArea.innerHTML + '<p>Click on a thumbnail to view a larger size image</p>';

}