// Author(s)   : Colin Stott.
// Copyright   : Congo Systemsİ 2009
// ----------------------------------------------------------------------


//----------------------------------------------------------------------------------



	 function Sniffer() 
	 {
		agent 		= navigator.userAgent.toLowerCase();
		this.major 	= parseInt(navigator.appVersion);
		this.minor 	= parseFloat(navigator.appVersion);
		this.ns 	= ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
		this.ns4 	= (this.ns && (this.major == 4));
		this.ns6 	= (this.ns && (this.major >= 5));
		this.ie 	= (agent.indexOf("msie") != -1);
		this.mac 	= (agent.indexOf("mac")!=-1); // Added by Colin M Stott 07-09-05
		this.ie3 	= (this.ie && (this.major < 4));
		this.ie4 	= (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
		this.ie5 	= (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
		this.ie55 	= (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
		this.ie6 	= (this.ie && (agent.indexOf("msie 6.0")!=-1) );
		
	}


 	var sniffer = new Sniffer();



//----------------------------------------------------------------------------------



/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Greg Burghardt | http://www.geocities.com/greg_burghardt/ */
	var _GET = {};
	
	function readURL() 
	{
	  var tLoc = "", tPairs = "";
	  var tGet = [];
	  var foundGet = -1;
	  tLoc = top.window.location + "";
	  foundGet = tLoc.indexOf('?');

	  if (foundGet > -1)
	  {
		tLoc = tLoc.substring(foundGet + 1, tLoc.length);
		tPairs = tLoc.split('&');
		for (var i = 0; i < tPairs.length; i++) 
		{
		  tGet = tPairs[i].split('=');
		  _GET[tGet[0]] = decodeURIComponent(tGet[1].replace(/\+/g,' '));
		}
	  }
	}



//----------------------------------------------------------------------------------



		function setmenu(victim)
		{

			seturl();

			button('over',victim);
			parent.document.getElementById('val2').innerHTML 	= '';

			parent.document.getElementById('welcome').src 		= "images/bx_welcome.gif";
			parent.document.getElementById('about').src 		= "images/bx_about.gif";
			parent.document.getElementById('process').src 		= "images/bx_process.gif";
			parent.document.getElementById('awards').src 		= "images/bx_awards.gif";
			parent.document.getElementById('gallery').src 		= "images/bx_gallery.gif";
			parent.document.getElementById('current').src 		= "images/bx_current.gif";
			parent.document.getElementById('contact').src 		= "images/bx_contact.gif";

			if(victim != "nil")
			parent.document.getElementById(victim).src 			= "images/bo_"+victim+".gif";

			setmenu2(victim);
		}



//----------------------------------------------------------------------------------



		function setmenu2(victim)
		{

			parent.document.getElementById("sub_gallery").style.display	= "none";
			parent.document.getElementById("sub_current").style.display	= "none";
			
			if(victim == "gallery" || victim == "current")
			{
				parent.document.getElementById("sub_"+victim).style.display	= "block";
				
				if(victim == "gallery")
				{
					setmenu3("gallery_extr");
					populate("thumbs","gallery_extr",0);
				}

				if(victim == "current")
				{
					setmenu3("current_pr01");	
					populate("thumbs","current_pr01",0);
				}

			}

		}



//----------------------------------------------------------------------------------



		function setmenu3(victim)
		{

			parent.document.getElementById("gallery_extr").className		= "link1_off";
			parent.document.getElementById("gallery_intr").className		= "link1_off";
			parent.document.getElementById("gallery_reno").className		= "link1_off";
			parent.document.getElementById("gallery_pool").className		= "link1_off";
			parent.document.getElementById("gallery_land").className		= "link1_off";

			parent.document.getElementById("current_pr01").className		= "link1_off";
			parent.document.getElementById("current_pr02").className		= "link1_off";
			parent.document.getElementById("current_pr03").className		= "link1_off";

			if(victim != "")
			{
				parent.document.getElementById(victim).className			= "link1_on";
			}

		}



//----------------------------------------------------------------------------------



		function seturl()
		{
			var r = ""+top.location+"";		// The pathname
			var s = r.lastIndexOf("/");		// The last / in the pathname
			var t = r.substring(s+1);		// The suffix filename. eg. default.htm
			var x = r.substring(0,4);		// The prefix url type. eg. file://
			var y = r.substring(0,s+1);		// The pathname up to the last /

			if(x != "file") // Need this in here for my local machine :)
			{
				if(r != "http://www.seidlerhomes.com.au/")
				{
					if(!top.document.getElementById("val1"))
					{
						plop = y+"index.htm"+"?page="+t;
						parent.location = plop;
					}
				}
			}
			else
			{
					if(!top.document.getElementById("val1"))
					{
						plop = y+"index.htm"+"?page="+t;
						parent.location = plop;
					}
			}
		}



//----------------------------------------------------------------------------------



		function button(state,victim)
		{
		if(victim != "nil")
		{
			var r = parent.document.getElementById(victim).src;
			var s = r.indexOf('images');
			var t = r.substring(s);

			if(state == 'over' && t == "images/bo_"+victim+".gif")
			{
				parent.document.getElementById('val2').innerHTML = 'already_on';
			}
			else if(state == 'over' && t == "images/bx_"+victim+".gif")
			{
				parent.document.getElementById(victim).src = "images/bo_"+victim+".gif";
				parent.document.getElementById('val2').innerHTML = 'turned_on';
			}
		
			if(state == 'out' && parent.document.getElementById('val2').innerHTML == 'already_on')
			{	
				parent.document.getElementById(victim).src = "images/bo_"+victim+".gif";
			}
			else if(state == 'out' && parent.document.getElementById('val2').innerHTML == 'turned_on')
			{
				parent.document.getElementById(victim).src = "images/bx_"+victim+".gif";
			}
		}
		}



//----------------------------------------------------------------------------------



		function thumbslide(diff)
		{

			area 	= parent.document.getElementById('thumb_area').innerHTML;
			victim 	= parent.document.getElementById('thumb_victim').innerHTML;
			
			populate(area,victim,diff);

		}
		


//----------------------------------------------------------------------------------



		function populate(area,victim,poz)
		{
		
			if(area == "thumbs")
			{
				
				var drill = top.window.mainiframe;

				// Find the number of images in the sub-category array. eg.(victim=gallery_extr) = 7
				numthumbs = eval(victim).length;
				
				var poz1 = parent.document.getElementById('thumb_spot0').innerHTML;
				
				if(poz == 0)
				{
	
					// Load 4 "Comingsoon" thumbnails into spots 0,1,2,3
					for(j=0; j<4; j++)
					{
						drill.document.getElementById("thumb"+j).src 		= "images/comingsoon1.jpg";
						drill.document.getElementById("thumb"+j).title 		= "Image Coming Soon...";
					}


					// Load either gallery1.jpg or current1.jpg
					
					var vicimage = victim.substr(0,7);

					drill.document.getElementById("zoomimage").src 			= "images/"+vicimage+"1.jpg";


					var i = poz*1;
	
					// Set the global variables
					parent.document.getElementById('thumb_spot0').innerHTML 	= 0;
					parent.document.getElementById('thumb_area').innerHTML 		= area;
					parent.document.getElementById('thumb_victim').innerHTML 	= victim;

					// Load the 4 thumbnails into spots 0,1,2,3
					for(j=0; j<4; j++)
					{
						drill.document.getElementById("thumb"+j).src 		= "images/"+eval(victim)[i+j];
						drill.document.getElementById("thumb"+j).title 		= "Click to View an enlarged image of ( "+eval(victim)[i+j]+" )";
					}
					
				}
				else if(poz == 1)
				{
					
					parent.document.getElementById('thumb_spot0').innerHTML 		= poz1*1+1;
					
					var i = poz1*1+1;
					
					// Load the 4 thumbnails into spots 0,1,2,3
					for(j=0; j<4; j++)
					{
						drill.document.getElementById("thumb"+j).src 		= "images/"+eval(victim)[i+j];
						drill.document.getElementById("thumb"+j).title 		= "Click to View an enlarged image of ( "+eval(victim)[i+j]+" )";
					}

				}
				else if(poz == -1)
				{
					
					parent.document.getElementById('thumb_spot0').innerHTML 		= poz1*1-1;
					
					thumbspot0 = parent.document.getElementById('thumb_spot0').innerHTML;

					var i = poz1*1-1;
					
					// Load the 4 thumbnails into spots 0,1,2,3
					for(j=0; j<4; j++)
					{
						drill.document.getElementById("thumb"+j).src 		= "images/"+eval(victim)[i+j];
						drill.document.getElementById("thumb"+j).title 		= "Click to View an enlarged image of ( "+eval(victim)[i+j]+" )";
					}

				}
				
				
				thumbspot0 = parent.document.getElementById('thumb_spot0').innerHTML;

				if(thumbspot0 > 0)
				{
					drill.document.getElementById('nav_left').innerHTML = '<img src="images/nav_left_white.png" width="50" height="70" border="0" class="image0" onClick="thumbslide(-1);" title="['+thumbspot0+'] Images this way">';
				}
				else
				{
					drill.document.getElementById('nav_left').innerHTML = '<img src="images/nav_left_black.png" width="50" height="70" border="0" class="image0" title="[0] Images this way">';
				}

				
				thumbspot0 = thumbspot0*1+4;
				remainder = numthumbs-thumbspot0;
				
				if(numthumbs > thumbspot0)
				{
					drill.document.getElementById('nav_right').innerHTML = '<img src="images/nav_right_white.png" width="50" height="70" border="0" class="image0" onClick="thumbslide(1);" title="['+remainder+'] Images this way">';
				}
				else
				{
					drill.document.getElementById('nav_right').innerHTML = '<img src="images/nav_right_black.png" width="50" height="70" border="0" class="image0" title="[0] Images this way">';
				}
				
				


			
			
			}
				
			setmenu3(victim);
		
		}



//----------------------------------------------------------------------------------



		function showport(victim)
		{
			parent.document.getElementById('portzoom').style.display 		= "block";
			parent.document.getElementById('portguts').style.display 		= "block";
			var v3 = victim;
			var v4 = new RegExp('.jpg','gi');
			var v5 = v3.replace(v4, '_z.jpg');

			parent.document.getElementById('portguts').src = v5;
		}



//----------------------------------------------------------------------------------



		function hideport()
		{
			parent.document.getElementById('portzoom').style.display 		= "none";
			parent.document.getElementById('portguts').style.display 		= "none";
			parent.document.getElementById('portguts').src 					= "images/trans.gif";
		}


//----------------------------------------------------------------------------------



		function showzoom(victim)
		{

			var v3 = victim;
			var v4 = new RegExp('.jpg','gi');
			var v5 = v3.replace(v4, '_z.jpg');

			//document.getElementById('zoomimage').src = v5;
			
			//swapfade(document.getElementById('zoomimage'), v5, '2', v5);
			crossfade(document.getElementById('zoomimage'), v5, '2', v5);
			//crosswipe(document.getElementById('zoomimage'), v5, '2', 'che', v5) 

		}



//----------------------------------------------------------------------------------



		function checkform(victim)
		{
			
			if(victim == "contact")
			{
						
				var name 		= document.forms.contact.Name.value;
				var email 		= document.forms.contact.Email.value;


				var emailreg 	= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	

				if (trim(name) == "") 
				{
					alert("Please enter Your Name.");
					document.forms.contact.Name.focus();
					return false;
				}


				if (trim(email) == "") 
				{
					alert("Please enter Your Contact Email.");
					document.forms.contact.Email.focus();
					return false;
				}
				else if(emailreg.test(email) == false)
				{
					alert("Please enter a Valid Contact Email Address.");
					document.forms.contact.Email.focus();
					return false;
				}

				return true;

			}

		
		}



//----------------------------------------------------------------------------------


		
		function trim(str)
		{
		   return str.replace(/^\s+|\s+$/g,'');
		}



//----------------------------------------------------------------------------------



/* This script and many more are available free online at
	The JavaScript Source!! http://javascript.internet.com
	Created by: Jeroen Haan | http://www.haan.net
	Explorer Plugin Starter - v.1.1
	Small mod [ if(typeof window[objects[i].outerHTML] != 'undefined') ] by CMS 12-09-07
  ------------------------------------------------ */

function fixPlugin() 
{

	// Objects
	var objects = document.getElementsByTagName('object');
 	
	for (var i = 0; i < objects.length; i++) 
	{
		var paramEl = '';
		var params = document.getElementsByTagName('param');
			
		for (var j = 0; j < params.length; j++) 
		{
			paramEl += params[j].outerHTML;
		}
			 
		if(typeof window[objects[i].outerHTML] != 'undefined')
		{
			objects[i].outerHTML = objects[i].outerHTML.replace('>', '>' + paramEl);
		}
	}
	
	// Embeds
 	var embeds = document.getElementsByTagName('embed');
 	
	for (var i = 0; i < embeds.length; i++) 
	{
 		 embeds[i].outerHTML = embeds[i].outerHTML;
 	}

	// Applets
 	var applets = document.getElementsByTagName('applet');

	for (var i = 0; i < applets.length; i++) 
	{
  		var paramEl = '';
  		var params = document.getElementsByTagName('param');
  		
		for (var j = 0; j < params.length; j++) 
		{
   			paramEl += params[j].outerHTML;
  		}
  		
		applets[i].outerHTML = applets[i].outerHTML.replace('>', '>' + paramEl);
 	}

}













//----------------------------------------------------------------------------------

// ISF1.11 :: Image swap-fade 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
//******************************************************


/*
The swapfade function takes four arguments:

Image object
    A reference to the image you want to change.
New SRC
    A string that specifies the src of the new image (which must be the same size as the original).
Duration
    A string that specifies the total length of the transition, an integer in seconds.
New ALT text
    An optional string that specifies the alt text of the new image; if this is not included then the alt text will stay the same. 

Usage:
swapfade(document.getElementById('test'), 'buttons/udm4-whitebutton88x31.gif', '2', 'Accessible Website Menu [white]');


*/


//global object
var isf = { 'clock' : null, 'fade' : true, 'count' : 1 }
/*******************************************************



/*****************************************************************************
 List the images that need to be cached
*****************************************************************************/

isf.imgs = [];


/*  or use isf.imgs = ['images/image1.jpg','images/image1.jpg']; to preload images */

/*****************************************************************************
*****************************************************************************/



//cache the images
isf.imgsLen = isf.imgs.length;
isf.cache = [];
for(var i=0; i<isf.imgsLen; i++)
{
	isf.cache[i] = new Image;
	isf.cache[i].src = isf.imgs[i];
}


//swapfade setup function
function swapfade()
{
	//if the timer is not already going
	if(isf.clock == null)
	{
		//copy the image object 
		isf.obj = arguments[0];
		
		//copy the image src argument 
		isf.src = arguments[1];
		
		//store the supported form of opacity
		if(typeof isf.obj.style.opacity != 'undefined')
		{
			isf.type = 'w3c';
		}
		else if(typeof isf.obj.style.MozOpacity != 'undefined')
		{
			isf.type = 'moz';
		}
		else if(typeof isf.obj.style.KhtmlOpacity != 'undefined')
		{
			isf.type = 'khtml';
		}
		else if(typeof isf.obj.filters == 'object')
		{
			//weed out win/ie5.0 by testing the length of the filters collection (where filters is an object with no data)
			//then weed out mac/ie5 by testing first the existence of the alpha object (to prevent errors in win/ie5.0)
			//then the returned value type, which should be a number, but in mac/ie5 is an empty string
			isf.type = (isf.obj.filters.length > 0 && typeof isf.obj.filters.alpha == 'object' && typeof isf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			isf.type = 'none';
		}
		
		//change the image alt text if defined
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			isf.obj.alt = arguments[3];
		}
		
		//if any kind of opacity is supported
		if(isf.type != 'none')
		{
			//copy and convert fade duration argument 
			//the duration specifies the whole transition
			//but the swapfade is two distinct transitions
			isf.length = parseInt(arguments[2], 10) * 500;
			
			//create fade resolution argument as 20 steps per transition
			//again, split for the two distrinct transitions
			isf.resolution = parseInt(arguments[2], 10) * 10;
			
			//start the timer
			isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);
		}
		
		//otherwise if opacity is not supported
		else
		{
			//just do the image swap
			isf.obj.src = isf.src;
		}
		
	}
};


//swapfade timer function
isf.swapfade = function()
{
	//increase or reduce the counter on an exponential scale
	isf.count = (isf.fade) ? isf.count * 0.9 : (isf.count * (1/0.9)); 
	
	//if the counter has reached the bottom
	if(isf.count < (1 / isf.resolution))
	{
		//clear the timer
		clearInterval(isf.clock);
		isf.clock = null;

		//do the image swap
		isf.obj.src = isf.src;

		//reverse the fade direction flag
		isf.fade = false;
		
		//restart the timer
		isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);

	}
	
	//if the counter has reached the top
	if(isf.count > (1 - (1 / isf.resolution)))
	{
		//clear the timer
		clearInterval(isf.clock);
		isf.clock = null;

		//reset the fade direction flag
		isf.fade = true;
		
		//reset the counter
		isf.count = 1;
	}

	//set new opacity value on element
	//using whatever method is supported
	switch(isf.type)
	{
		case 'ie' :
			isf.obj.filters.alpha.opacity = isf.count * 100;
			break;
			
		case 'khtml' :
			isf.obj.style.KhtmlOpacity = isf.count;
			break;
			
		case 'moz' : 
			//restrict max opacity to prevent a visual popping effect in firefox
			isf.obj.style.MozOpacity = (isf.count == 1 ? 0.9999999 : isf.count);
			break;
			
		default : 
			//restrict max opacity to prevent a visual popping effect in firefox
			isf.obj.style.opacity = (isf.count == 1 ? 0.9999999 : isf.count);
	}
};


//----------------------------------------------------------------------------------

// IXF1.11 :: Image cross-fade 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
//******************************************************


/*
 The crossfade function also takes four arguments, exactly the same as swapfade:

Image object
    A reference to the image you want to change.
New SRC
    A string that specifies the src of the new image (which must be the same size as the original).
Duration
    A string that specifies the total length of the transition, an integer in seconds.
New ALT text
    An optional string that specifies the alt text of the new image; if this is not included then the alt text will stay the same. 

Usage:
crossfade(document.getElementById('test'), 'buttons/udm4-whitebutton88x31.gif', '2', 'Accessible Website Menu [white]')


*/


//global object
var ixf = { 'clock' : null, 'count' : 1 }
/*******************************************************



/*****************************************************************************
 List the images that need to be cached
*****************************************************************************/

ixf.imgs = [];


/*  or use ixf.imgs = ['images/image1.jpg','images/image1.jpg']; to preload images */

/*****************************************************************************
*****************************************************************************/



//cache the images
ixf.imgsLen = ixf.imgs.length;
ixf.cache = [];
for(var i=0; i<ixf.imgsLen; i++)
{
	ixf.cache[i] = new Image;
	ixf.cache[i].src = ixf.imgs[i];
}


//crossfade setup function
function crossfade()
{
	//if the timer is not already going
	if(ixf.clock == null)
	{
		//copy the image object 
		ixf.obj = arguments[0];
		
		//copy the image src argument 
		ixf.src = arguments[1];
		
		//store the supported form of opacity
		if(typeof ixf.obj.style.opacity != 'undefined')
		{
			ixf.type = 'w3c';
		}
		else if(typeof ixf.obj.style.MozOpacity != 'undefined')
		{
			ixf.type = 'moz';
		}
		else if(typeof ixf.obj.style.KhtmlOpacity != 'undefined')
		{
			ixf.type = 'khtml';
		}
		else if(typeof ixf.obj.filters == 'object')
		{
			//weed out win/ie5.0 by testing the length of the filters collection (where filters is an object with no data)
			//then weed out mac/ie5 by testing first the existence of the alpha object (to prevent errors in win/ie5.0)
			//then the returned value type, which should be a number, but in mac/ie5 is an empty string
			ixf.type = (ixf.obj.filters.length > 0 && typeof ixf.obj.filters.alpha == 'object' && typeof ixf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			ixf.type = 'none';
		}
		
		//change the image alt text if defined
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			ixf.obj.alt = arguments[3];
		}
		
		//if any kind of opacity is supported
		if(ixf.type != 'none')
		{
			//create a new image object and append it to body
			//detecting support for namespaced element creation, in case we're in the XML DOM
			ixf.newimg = document.getElementsByTagName('body')[0].appendChild((typeof document.createElementNS != 'undefined') ? document.createElementNS('http://www.w3.org/1999/xhtml', 'img') : document.createElement('img'));

			//set positioning classname
			ixf.newimg.className = 'idupe';
			
			//set src to new image src
			ixf.newimg.src = ixf.src

			//move it to superimpose original image
			ixf.newimg.style.left = ixf.getRealPosition(ixf.obj, 'x') + 'px';
			ixf.newimg.style.top = ixf.getRealPosition(ixf.obj, 'y') + 'px';
			
			//copy and convert fade duration argument 
			ixf.length = parseInt(arguments[2], 10) * 1000;
			
			//create fade resolution argument as 20 steps per transition
			ixf.resolution = parseInt(arguments[2], 10) * 20;
			
			//start the timer
			ixf.clock = setInterval('ixf.crossfade()', ixf.length/ixf.resolution);
		}
		
		//otherwise if opacity is not supported
		else
		{
			//just do the image swap
			ixf.obj.src = ixf.src;
		}
		
	}
};


//crossfade timer function
ixf.crossfade = function()
{
	//decrease the counter on a linear scale
	ixf.count -= (1 / ixf.resolution);
	
	//if the counter has reached the bottom
	if(ixf.count < (1 / ixf.resolution))
	{
		//clear the timer
		clearInterval(ixf.clock);
		ixf.clock = null;
		
		//reset the counter
		ixf.count = 1;
		
		//set the original image to the src of the new image
		ixf.obj.src = ixf.src;
	}
	
	//set new opacity value on both elements
	//using whatever method is supported
	switch(ixf.type)
	{
		case 'ie' :
			ixf.obj.filters.alpha.opacity = ixf.count * 100;
			ixf.newimg.filters.alpha.opacity = (1 - ixf.count) * 100;
			break;
			
		case 'khtml' :
			ixf.obj.style.KhtmlOpacity = ixf.count;
			ixf.newimg.style.KhtmlOpacity = (1 - ixf.count);
			break;
			
		case 'moz' : 
			//restrict max opacity to prevent a visual popping effect in firefox
			ixf.obj.style.MozOpacity = (ixf.count == 1 ? 0.9999999 : ixf.count);
			ixf.newimg.style.MozOpacity = (1 - ixf.count);
			break;
			
		default : 
			//restrict max opacity to prevent a visual popping effect in firefox
			ixf.obj.style.opacity = (ixf.count == 1 ? 0.9999999 : ixf.count);
			ixf.newimg.style.opacity = (1 - ixf.count);
	}
	
	//now that we've gone through one fade iteration 
	//we can show the image that's fading in
	ixf.newimg.style.visibility = 'visible';
	
	//keep new image in position with original image
	//in case text size changes mid transition or something
	ixf.newimg.style.left = ixf.getRealPosition(ixf.obj, 'x') + 'px';
	ixf.newimg.style.top = ixf.getRealPosition(ixf.obj, 'y') + 'px';
	
	//if the counter is at the top, which is just after the timer has finished
	if(ixf.count == 1)
	{
		//remove the duplicate image
		ixf.newimg.parentNode.removeChild(ixf.newimg);
	}
};



//get real position method
ixf.getRealPosition = function()
{
	this.pos = (arguments[1] == 'x') ? arguments[0].offsetLeft : arguments[0].offsetTop;
	this.tmp = arguments[0].offsetParent;
	while(this.tmp != null)
	{
		this.pos += (arguments[1] == 'x') ? this.tmp.offsetLeft : this.tmp.offsetTop;
		this.tmp = this.tmp.offsetParent;
	}
	
	return this.pos;
};




//----------------------------------------------------------------------------------

// IXW1.0 :: Image cross-wipe 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
//******************************************************


/*
 The crosswipe function takes five arguments:

Image object
    A reference to the image you want to change.
New SRC
    A string that specifies the src of the new image (which must be the same size as the original).
Duration
    A string that specifies the total length of the transition, an integer in seconds.
Direction
    A string that specifies which animation to use, from the following choices: Left to Right ("lr"), 
	Right to Left ("rl"), Top to Bottom ("tb"), Bottom to Top ("bt"), Top Left to Bottom Right ("tlbr"), 
	Top Right to Bottom Left ("trbl"), Bottom Left to Top Right ("bltr"), Bottom Right to Top Left ("brtl"), 
	Center to Vertical Edges ("cve"), Center to Horizontal Edges ("che"), or Center to Corners ("cc"). 
New ALT text
    An optional string that specifies the alt text of the new image; if this is not included then the alt text will stay the same.

Usage:
crosswipe(document.getElementById('test'), 'buttons/udm4-greenbutton88x31.gif', '2', 'lr', 'Accessible Website Menu [green]')


*/


//global object
var ixw = { 'clock' : null, 'count' : 1 }
/*******************************************************



/*****************************************************************************
 List the images that need to be cached
*****************************************************************************/

ixw.imgs = [];

/*  or use ixw.imgs = ['images/image1.jpg','images/image1.jpg']; to preload images */

/*****************************************************************************
*****************************************************************************/



//cache the images
ixw.imgsLen = ixw.imgs.length;
ixw.cache = [];
for(var i=0; i<ixw.imgsLen; i++)
{
	ixw.cache[i] = new Image;
	ixw.cache[i].src = ixw.imgs[i];
}


//crosswipe setup function
function crosswipe()
{
	//if the timer is not already going
	if(ixw.clock == null)
	{
		//copy the image object 
		ixw.obj = arguments[0];
		
		//get its dimensions
		ixw.size = { 'w' : ixw.obj.width, 'h' : ixw.obj.height };
		
		//copy the image src argument 
		ixw.src = arguments[1];
		
		//change the image alt text if defined
		if(typeof arguments[4] != 'undefined' && arguments[4] != '')
		{
			ixw.obj.alt = arguments[4];
		}

		//if dynamic element creation is supported
		if(typeof document.createElementNS != 'undefined' || typeof document.createElement != 'undefined')
		{
			//create a new image object and append it to body
			//detecting support for namespaced element creation, in case we're in the XML DOM
			ixw.newimg = document.getElementsByTagName('body')[0].appendChild((typeof document.createElementNS != 'undefined') ? document.createElementNS('http://www.w3.org/1999/xhtml', 'img') : document.createElement('img'));

			//set positioning classname
			ixw.newimg.className = 'idupe';

			//set src to new image src
			ixw.newimg.src = ixw.src

			//move it to superimpose original image
			ixw.newimg.style.left = ixw.getRealPosition(ixw.obj, 'x') + 'px';
			ixw.newimg.style.top = ixw.getRealPosition(ixw.obj, 'y') + 'px';

			//set it to be completely hidden with clip
			ixw.newimg.style.clip = 'rect(0, 0, 0, 0)';

			//show the image 
			ixw.newimg.style.visibility = 'visible';

			//copy and convert fade duration argument 
			ixw.length = parseInt(arguments[2], 10) * 1000;

			//create fade resolution argument as 20 steps per transition
			ixw.resolution = parseInt(arguments[2], 10) * 20;

			//copy slide direction argument
			ixw.dir = arguments[3];

			//start the timer
			ixw.clock = setInterval('ixw.crosswipe()', ixw.length/ixw.resolution);
		}
		
		//otherwise if dynamic element creation is not supported
		else
		{
			//just do the image swap
			ixw.obj.src = ixw.src;
		}
		
	}
};


//crosswipe timer function
ixw.crosswipe = function()
{
	//decrease the counter on a linear scale
	ixw.count -= (1 / ixw.resolution);
	
	//if the counter has reached the bottom
	if(ixw.count < (1 / ixw.resolution))
	{
		//clear the timer
		clearInterval(ixw.clock);
		ixw.clock = null;
		
		//reset the counter
		ixw.count = 1;
		
		//set the original image to the src of the new image
		ixw.obj.src = ixw.src;
	}
	
	//animate the clip of the new image
	//using the width and height properties we saved earlier
	ixw.newimg.style.clip = 'rect('
		+ ( (/bt|bltr|brtl/.test(ixw.dir)) ? (ixw.size.h * ixw.count) : (/che|cc/.test(ixw.dir)) ? ((ixw.size.h * ixw.count) / 2) : (0) )
		+ 'px, '
		+ ( (/lr|tlbr|bltr/.test(ixw.dir)) ? (ixw.size.w - (ixw.size.w * ixw.count)) : (/cve|cc/.test(ixw.dir)) ? (ixw.size.w - ((ixw.size.w * ixw.count) / 2)) : (ixw.size.w) )
		+ 'px, '
		+ ( (/tb|tlbr|trbl/.test(ixw.dir)) ? (ixw.size.h - (ixw.size.h * ixw.count)) : (/che|cc/.test(ixw.dir)) ? (ixw.size.h - ((ixw.size.h * ixw.count) / 2)) : (ixw.size.h) )
		+ 'px, '
		+ ( (/lr|tlbr|bltr/.test(ixw.dir)) ? (0) : (/tb|bt|che/.test(ixw.dir)) ? (0) : (/cve|cc/.test(ixw.dir)) ? ((ixw.size.w * ixw.count) / 2) : (ixw.size.w * ixw.count) ) 
		+ 'px)';
			
	//keep new image in position with original image
	//in case text size changes mid transition or something
	ixw.newimg.style.left = ixw.getRealPosition(ixw.obj, 'x') + 'px';
	ixw.newimg.style.top = ixw.getRealPosition(ixw.obj, 'y') + 'px';
	
	//if the counter is at the top, which is just after the timer has finished
	if(ixw.count == 1)
	{
		//remove the duplicate image
		ixw.newimg.parentNode.removeChild(ixw.newimg);
	}
};



//get real position method
ixw.getRealPosition = function()
{
	this.pos = (arguments[1] == 'x') ? arguments[0].offsetLeft : arguments[0].offsetTop;
	this.tmp = arguments[0].offsetParent;
	while(this.tmp != null)
	{
		this.pos += (arguments[1] == 'x') ? this.tmp.offsetLeft : this.tmp.offsetTop;
		this.tmp = this.tmp.offsetParent;
	}
	
	return this.pos;
};



