			/* skiclub.js: javascript for Glasgow Ski Centre 18.03.07 */
	
	// Prevent being framed
	if (top.frames.length!=0)
	{
		top.location=self.document.location;
	}

	// Open resizable popUp window (width w, height h) in centre of existing window
	function openDetail(url, name, w, h) 
	{ 
	   var args = 'width=' + w + ','
	   + 'height=' + h + ','
	   + 'toolbar=0,'
	   + 'location=0,'
	   + 'directories=0,'
	   + 'status=yes,'
	   + 'menubar=0,'
	   + 'scrollbars=0,'
	   + 'resizable=yes';
	 
	   if (parseInt(navigator.appVersion) >= 4)
	   {
	      xposition = (screen.width - w)/2;
	      yposition = (screen.height - h)/2;
	  
	     args += ','
	              + 'screenx=' + xposition + ',' //NN
	              +  'screeny=' + yposition + ',' //NN
	              +  'left=' + xposition + ',' //IE
	              +  'top=' + yposition; //IE
	    }
	
		window.open(url, name, args);
	}
	
	
	// Close popUp window
	function closeIt() 
	{
  		parent.close();
	}


//  Equalizes div heights. id1, id2 - div ids, pad - div padding int value

	function equalize(id1, id2, pad) 
	{
		var div1 = document.getElementById(id1);
		var div2 = document.getElementById(id2);
		
		var h1 = parseInt(div1.offsetHeight);
		var h2 = parseInt(div2.offsetHeight);
		
		var p = pad;
		
		if(h1>h2)
		{
			h1 -= (2*p);
			div2.style.height = (h1 + 'px');
		}
		else
		{      
			h2 -= (2*p);
			div1.style.height = (h2 + 'px');
		}
	} 
	
	/*----------- simple id-based image swap ------------------*/	
	function imgSwap(imgID, imgSrc) 
	{
		 document.getElementById(imgID).src = imgSrc;
	}

// preloads images for menu
	function preLoader()
	{
		menuArray = new Array('hire', 'home', 'instruction', 'kids', 'membership', 'parties', 'racing', 'school'); 
		picArray = new Array(); 
		for (i = 0 ; i<menuArray.length ; i++) 
		{ 
				var temp = menuArray[i] + '_off'; 
				picArray[temp] = new Image(95,74); 
				picArray[temp].src = menuArray[i] + '_off.gif'; 
				
				var temp = menuArray[i] + '_on'; 
				picArray[temp] = new Image(95,74); 
				picArray[temp].src = menuArray[i] + '_on.gif'; 
				
				var temp = menuArray[i] + '_over'; 
				picArray[temp] = new Image(95,74); 
				picArray[temp].src = menuArray[i] + '_over.gif'; 
		} 
	}
	
	// (http://www.alistapart.com/articles/zebratables/)
// This version ignores the tbody complication and requires colour arguments

  	// Workaround for an IE bug related to element attributes
	function hasClass(obj) 
	{
		 var result = false;
		 if (obj.getAttributeNode("class") != null) 
		 {
		     result = obj.getAttributeNode("class").value;
		 }
		 return result;
	}   

	// 'stripeTable' function taking table id as argument and even and odd hex colours
	function stripeTable(id, evenColor, oddColor) 
	{
		// flag to keep track of whether the current row is odd or even
		var even = false;
		
		// obtain a reference to the desired table 
		var table = document.getElementById(id);
		if (! table) 							// if no table of this id, abort
		{ 
			return; 
		}					
		
		var trs = table.getElementsByTagName("tr");		// find all <tr>s in table...
		for (var i = 0; i < trs.length; i++)	      	// ... and iterate through them
		{
			// avoid rows that have a class attribute or backgroundColor style
			if (! hasClass(trs[i]) && ! trs[i].style.backgroundColor) 
			{     
				var tds = trs[i].getElementsByTagName("td");	 // get all cells in this row...
				for (var j = 0; j < tds.length; j++)  			 // and iterate through them...
				{
					var mytd = tds[j];
					// set appropriate colour, avoiding cells with a class attribute or backgroundColor
					if (! hasClass(mytd) && ! mytd.style.backgroundColor) 
					{
						if(even)
						{
							mytd.style.backgroundColor = evenColor;
						}
						else
						{
							mytd.style.backgroundColor = oddColor;							
						}
					}
				}
			}
			// flip from odd to even, or vice-versa
		    even =  ! even;
		}
	}
	
	// url stuff - uncommented
	
function makeurl(id, visText)
{
	var crypto = new String("");		
	if(id == "99")
	{
		crypto = "m/index.phpnewforu7";
	}
    unveil(crypto, visText);
}

function unveil(inString, visText)
{
	var coded = new String("");
	coded  = inString;
	var decoded = new String("");
	var offset = coded.substring(coded.length-1, coded.length);
	coded = coded.substring(0, coded.length-1);
	
	for(i = 0; i < coded.length; i++)
	{
		var j = i - offset;
		if(j < 0)
		{
			j = i - offset +  coded.length;
		}
		decoded += coded.charAt(j);
	}
	writeIt(decoded, visText); 
}

function writeIt(decoded, visText)
{
	var first = '<a href="http://www.ski-glasgow.co.uk/';
	var second = decoded;
	var third = '">';
	var fourth = visText;
	var fifth = '</a>';
	
	var outString = first + second + third + fourth + fifth;	
	document.write(outString);
}
	