///////////////
// Global Utilities
///////////////
function Browser() {
	var ua = navigator.userAgent.toLowerCase();

	// initialize
	this.OS = 'Not Determined';
	this.isWin = false;
	this.isMac = false;
	// set
	if (navigator.appVersion.indexOf("Win") > 0) this.OS = "Win";	
	if (navigator.appVersion.indexOf("Mac") > 0) this.OS = "Mac";
	if (navigator.appVersion.indexOf("Win") > 0) this.isWin = true;	
	if (navigator.appVersion.indexOf("Mac") > 0) this.isMac = true;	
	
	this.isID = (document.getElementById) ? true : false;

	this.isIE = (ua.indexOf("msie") > 0 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1 && ua.indexOf("konqueror") == -1);// 
    this.isNN = (ua.indexOf('netscape') >= 0 || ua.indexOf('gecko') >= 0);
    this.isAOL = ua.indexOf('aol') >= 0; 
    this.isFireFox = ua.indexOf('firefox') >= 0;

	//look for the version number 
	var iVersion = null ;
	if (this.isIE) {
	  var sInfo = navigator.appVersion.toLowerCase().indexOf('msie') + 5;
	  iVersion = parseFloat(navigator.appVersion.substring(sInfo));	 
	} else if (this.isFireFox){
	  var sInfo = ua.lastIndexOf('/') + 1;
	  iVersion = parseFloat(ua.substring(sInfo,ua.length));
	} else if (this.isNN){
	  var sInfo = ua.lastIndexOf('/') + 1;
	  iVersion = parseFloat(ua.substring(sInfo,ua.length));
	}

	this.version = iVersion;

}
var browser = new Browser();


function browserMaxX() {
	var maxX;
	if (self.innerHeight) // all except Explorer
	{
		maxX = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		maxX = document.documentElement.clientWidth;
	}
	else if (document.body) // other Explorers
	{
		maxX = document.body.clientWidth;
	}
	return maxX
}

function browserMaxY() {
	var maxY;
	if (self.innerHeight) // all except Explorer
	{
		maxY = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		maxY = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		maxY = document.body.clientHeight;
	}
	return maxY
}


var imageSwapSource;
var imageSwapDestination;
function swapImage(sourceObj,swapWith,destinationObj){
	//if (!document.getElementById && !image)return;
	if(!destinationObj){
		destinationObj = sourceObj;
	}else{
		destinationObj = document.getElementById(destinationObj);
	}	
	imageSwapDestination = destinationObj;
	imageSwapDestination.origSrc = destinationObj.src;
	destinationObj.src = swapWith;
	sourceObj.onmouseout = swapImageRestore;
}

function swapImageRestore(){
		imageSwapDestination.src = imageSwapDestination.origSrc;
		imageSwapDestination=null;
}


// openWindow options ----------
//titlebar=yes,menubar=no,directories=no,toolbar=no,
//location=no,status=no,scrollbars=no,resizable=yes
function openWindow(url, title, w, h, o, position,namedAnchor) {
	if (position == 'center') {
		windowLeft = (screen.availWidth / 2) - (w / 2);
		windowTop = (screen.availHeight / 2) - (h / 2);	
		o +=',left='+windowLeft+',top='+windowTop;
	}else if (position == 'topLeft'){
		o +=',top=0,left=0';
	}
	
	
	if (h.toString().indexOf('%') != -1)
		h = Math.floor(screen.availHeight * (parseInt(h) / 100));
		
	if (w.toString().indexOf('%') != -1)
		w = Math.floor(screen.availWidth * (parseInt(w) / 100));
		
		
	if (url.indexOf("?") != -1){//send the window size to popup
		var urlModifyer = '&';
	}else{
		var urlModifyer = '?';
	}
	url = url + urlModifyer + 'popupWidth=' + w + '&popupHeight=' + h;
	if (namedAnchor != null)
		url += namedAnchor;
		
	windowprops = "width=" + w + ",height=" + h + o;
	popup = window.open(url,title,windowprops);
	popup.focus();
}



//show select box when menu is hidden
function showSelect(activeLayer){
	if(browser.isIE && browser.version < 7 && document.getElementsById){
		var obj;
		for(var i = 0; i < document.getElementsByTagName("select").length; i++){
			obj = document.getElementsByTagName("select")[i];
			obj.style.visibility = 'visible';
		}	
	}
}
//hide select box when menu is visible
function hideSelect(activeLayer){
	if(browser.isIE && browser.version < 7 && document.getElementsById){		
		var obj;	
		for(var i = 0; i < document.getElementsByTagName("select").length; i++){
			obj = document.getElementsByTagName("select")[i];
			obj.style.visibility = 'hidden';
		}
	}
}


// n=length in time, x and y = 1 when true to shake on that axis
function shakeWindow(n,x,y) {
	//if(browser.isIE && (browser.isWin) && (!browser.isAOL)){
		if (parent.moveBy) {
			for (i = n; i > 0; i--) {
				for (j = (n/2); j > 0; j--) {
					if (y==1) {parent.moveBy(0,i)};y
					if (x==1) {parent.moveBy(i,0)};x
					if (y==1) {parent.moveBy(0,-i)};y
					if (x==1) {parent.moveBy(-i,0)};x
         			}
     			}
     		browserMaxX();
     		browserMaxY();
  		}
	//}
}

function inputswap(el,compTo,setTo) {
	if(el.value==compTo) {
		el.value=setTo;
	}
}

function toggleDisplay(objectID) {
if (!document.getElementById){return;}
	objectID = document.getElementById(objectID);
	if (objectID.style.display =='block')objectID.style.display='none';
	else objectID.style.display='block';
}


// Call TestSwfPlayer from any page that has a SWF file in it, to test for the existence and version of the player.
// Use this in the body tag:   onload="javascript:TestSwfPlayer();"
function TestSwfPlayer(){
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	var msg =	'Your machine does not have a version of Adobe Flash Player that is\n' + 
					'required for our site to provide you with the ultimate RIDE customizing experience.\n' +
					'Therefore some content may not appear or function correctly.\n\n' +
					'Click \'OK\' if you would like to be directed to Abode\'s site to download this free player, or cancel.\n\n'
	if(version['major'] < 9){
		if(confirm(msg)==true)
		{
			window.open('http://www.adobe.com/go/getflashplayer','_new');
		}	
	}
}

// This is the funked-up Flash Player version detector for IE - God bless MS!
function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// Need this one for Mac Safari
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			return flashVer;
		}
	}
}

// Call TestSwfPlayer from any page that has a SWF file in it, to test for the existence and version of the player.
// Use this in the body tag:   onload="javascript:TestSwfPlayer();"
function HasSomeSwfPlayer(){
	var hasFlash = false;	//including the right version
	var version = -1
	
	if(browser.isFireFox){
		version = deconcept.SWFObjectUtil.getPlayerVersion();
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			if ((navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) && version['major'] > 8) {
				hasFlash = true;
			}
		}
	}else{	// browser is not FF (could be IE or NN)
		version = ControlVersion();
		//See if we are Mac Safari version of Flash.
		if(browser.isMac){
			version = GetSwfVer();
		}
		
		if(version==-1)
			hasFlash=false;
		else
			hasFlash=true;
	}
	
	return hasFlash;
}


/***************************** ShowBannerDiv Pack ******************************/

function showBannerDiv(el, timing, theHeight, TopToGoto){
	var obj = document.getElementById(el);
	if(obj.style.display == 'none'){
		var setTopAt;
		obj.style.display = '';


		// 118px is the shown header height
		if(theHeight > 118){
			setTopAt = '-' + (theHeight - 118) + 'px';
		}else{
			setTopAt = (118 - theHeight) + 'px';
		}
		obj.style.top =  setTopAt;

		var theFunctionCall = 'slide(\'' + el + '\', \'' + theHeight + '\', \'' + TopToGoto + '\')';
		var IntervalID = window.setInterval(theFunctionCall, timing);
	}	
}

function slide(el, MaxHeight, TopToGoto, dir){
	var obj = document.getElementById(el);

	if(parseInt(obj.style.top) < TopToGoto){
		var myStringT;
			if(browser.isIE){
				myStringT = (parseInt(obj.style.top) + 21) + 'px';
			}else{
				myStringT = (parseInt(obj.style.top) + 10) + 'px';
			}
		obj.style.top = myStringT;
	}

}

function hideBannerDiv(el){
	var obj = document.getElementById(el);
	obj.style.display = 'none';
}

/***************************** End ShowBannerDiv Pack *****************************/

/***************************** Begin Cookie Pack *****************************/
function set_Cookie(name,value,expires,path,domain,secure) {
  document.cookie = name + '=' + escape(value) +
    ( (expires) ? ';expires=' + expires.toGMTString() : '') +
    ( (path) ? ';path=' + path : '') + 
    ( (domain) ? ';domain=' + domain : '') +
    ( (secure) ? ';secure' : '');
}
function get_Cookie(name) {
  var start = document.cookie.indexOf(name + '=');
  var len = start + name.length + 1;
  if ((!start) && (name != document.cookie.substring(0,name.length)))
    return null;
  if (start == -1)
    return null;
  var end = document.cookie.indexOf(';',len);
  if (end == -1) end = document.cookie.length;
  return unescape(document.cookie.substring(len,end));
}
function delete_Cookie(name,path,domain) {
  if (get_Cookie(name))
    document.cookie =
      name + '=' +
      ( (path) ? ';path=' + path : '') +
      ( (domain) ? ';domain=' + domain : '') +
      ';expires=Thu, 01-Jan-1972 00:00:01 GMT';
}

/***************************** End Cookie Pack *****************************/

/***************************** DOM Object Morphing (shrink-to-nothing/grow back) Pack *****************************/
function MorphDomObject(obj){
	// NOTE: Pass in zeros for maxWidth and/or maxHeight to shrink the object.

	// Set some new attributes to the DOM object for it's original height and width, so we can use those to grow the object back
	if(!obj.getAttribute('originalWidth')){
		obj.setAttribute('originalWidth',obj.width);
		obj.setAttribute('originalHeight',obj.height);
	}

	try{
		clearInterval(MorphInterval);	
	}catch(e){

	}
	// Are we shrinking the content or growing it?
	if(obj.width>0 || obj.height>0){

		MorphInterval = window.setInterval('shrinkDomObject(document.getElementById(\'' + obj.id + '\'))', 1);
		
	}else{
	
		MorphInterval = window.setInterval('growDomObject(document.getElementById(\'' + obj.id + '\'))', 1);
			
	}

}

function shrinkDomObject(obj){
	// When both of these are true, we need to clear the 'MorphInterval' variable
	widthLimitHit = false;
	heightLimitHit = false;
	
	// Shrink width if not already at zero, else we've reached limit already
	if(parseInt(obj.width) > 0){
		obj.width = parseInt(obj.width) - 10;
	}else{
		widthLimitHit = true;
	}
	
	// Shrink height if not already at zero, else we've reached limit already
	if(parseInt(obj.height) > 0){
		obj.height = parseInt(obj.height) - 10;
	}else{
		heightLimitHit = true;
	}
	
	// if at limit, clear the interval variable
	if(widthLimitHit == true && heightLimitHit == true){
		clearInterval(MorphInterval);
	}
}

function growDomObject(obj){
	// When both of these are true, we need to clear the 'MorphInterval' variable
	widthLimitHit = false;
	heightLimitHit = false;

	// Grow width if we've not reached limit already	
	if(obj.width < obj.getAttribute('originalWidth')){
		obj.width += 10;
		//alert(obj.width);
	}else{
		widthLimitHit = true;
	}
	
	// Grow height if we've not reached limit already	
	if(obj.height < obj.getAttribute('originalHeight')){
		obj.height += 10;
	}else{
		heightLimitHit = true;
	}
	
	// if at or above limit, adjust to precise original width and height, and clear the interval variable
	if(widthLimitHit == true && heightLimitHit == true){
		// Adjustment for overshooting original size
		obj.width = obj.getAttribute('originalWidth');
		obj.height = obj.getAttribute('originalHeight');
		clearInterval(MorphInterval);
	}
	
}

/***************************** END DOM Tag Object Morphing (shrink-to-nothing/grow) Pack *****************************/

// This function returns the coordinate position of the mouse pointer (X:Y)
function getMouseXY(e,myEvent) {
	var pX=0;
	var pY=0;

	e=e || window.event;
   	
	pX= (e.clientX) || 0;
	pY= (e.clientY) || 0;
  
    return  [pX,pY];    
    
}


/************** function pack for browser width, height, scroll-left, scroll-top **************/
/*
Below are four functions that will return window width, window height, horizontal scroll bar position and vertical scroll bar position.
Although there is fifth function that filters through the values returned by different methods to determine the right one.
*/

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
/************** End of function pack for browser width, height, scroll-left, scroll-top **************/





function validateEmailAddressFormat(inputvalue){	
	var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if(pattern.test(inputvalue)){
		return true;
	}else{   
		return false; 
	}
}