
var _currentRequestedDomain = "aaaohio.com";

var _requestedURLSplit = window.location.href.split("/");

for(x = 0; x < _requestedURLSplit.length; x++)
{
	window['_requestedURLName' + x] = _requestedURLSplit[x]; // note the dynamic variable name creation
	//document.writeln( _requestedURLSplit[x] );
}

if (window.location.href.indexOf('aaaohio.com') != -1)
{
	_currentRequestedDomain = "aaaohio.com"; //"localhost";
}
else
{
	_currentRequestedDomain = _requestedURLName2;
}

//alert(_currentRequestedDomain);
document.domain = _currentRequestedDomain; //'aaaohio.com';


function Utility(values)
{
	alert("new Utility");
	
	// iterate through all the configurations and populate local variables
	for (var n in values) 
	{ 
		//alert( n );
		this[n] = values[n]; 
	}
	
}

//Utility.yell = function() { alert('i yelled'); }

//  makes certain the page is loaded inside a frameset
Utility.confirmParentWindow = function()
{
	//alert("confirmParentWindow called");
	var _documentURL = document.location.toString();
	//alert(document.location.href);
	
	//alert(_documentURL);
	
	if ( _documentURL.indexOf("/accounts/") != -1 || _documentURL.indexOf("PartnerLinkFabricator.aspx") != -1 )
	{
		//alert("Utility NOT setting targetChildWindowURL");
		document.cookie = "targetChildWindowURL=" + _documentURL + ";path=/;domain=" + document.domain + ";";
	}
	else
	{
		//alert("Utility setting targetChildWindowURL: " + _documentURL);
		document.cookie = "targetChildWindowURL=" + _documentURL + ";path=/;domain=" + document.domain + ";";	
	}
	
	if (parent.frames.length <= 1) 
	{
		//alert(document.location.href.indexOf("eshop") == -1);
		if ( document.location.href.indexOf("eshop") != -1 || document.location.href.indexOf("blogs") != -1 || document.location.href.indexOf("travelsavingsevent") != -1 || document.location.href.indexOf("travelsalesevent") != -1 )
		{
			//var _myTarget = _requestedURLName0 + "//" + _requestedURLName2;
			//alert ("YOYOYO: ");
			top.location =  "http://www.aaaohio.com"; //_myTarget;
		}
		else
		{
			//alert ("YOYOYO: ");
			top.location = "/";	
		}	
	}
}


// makes certain the page is not being loaded inside of an iframe
Utility.iframeBuster = function()
{
	//alert("iframeBuster called");
	if ( parent.frames.length > 0)
	{
		//alert('loaded in an iframe...');
		top.location = "/";
	}
}

Utility.getCookie = function (name) 
{
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return Utility.getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

Utility.getCookieVal = function (offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}


Utility.hideElementById = function(id)
{
	document.getElementById( id ).style.display = 'none';
}

Utility.showElementById = function(id)
{
	document.getElementById( id ).style.display = 'block';
}

Utility.resizeElementById = function(passedElementId, passedWidth, passedHeight)
{
	//alert("resizeElementById called with " + passedElementId + passedWidth + passedHeight);
	//Utility.message('test',"resizeElementById called with " + passedElementId + passedWidth + passedHeight,'INFO');
	
	var _elementId = passedElementId;
	var _width = passedWidth;
	var _height = passedHeight;
	
	var _element;
	
	_element = document.getElementById(_elementId);
	
	if ( _width != '' || _width != null)
	{
		//_element.style.width = _width + "px";
	}
	
	if ( _height != '' || _height != null)
	{	
		_element.style.height = _height + "px";
	}	
}


Utility.parseRequestedURLForRegion = function(passedURL)
{
	var _requestedURL = passedURL; //document.location.toString();
	
	var _requestedURLSplit = _requestedURL.split("/");

	var _websiteRegionRequestedURL;

	for(x = 0; x < _requestedURLSplit.length; x++)
	{
		window['_requestedURLName' + x] = _requestedURLSplit[x]; // note the dynamic variable name creation
		//document.writeln( _requestedURLSplit[x] );
	}

	try
	{
		_websiteRegionRequestedURL = _requestedURLName4;
	}
	catch(ex)
	{
		_websiteRegionRequestedURL = 'home';
	}	
	
	//alert("_websiteRegionRequestedURL: " + _websiteRegionRequestedURL );
	return _websiteRegionRequestedURL;
}

// hey chuck... there are 2 of these and this one is the lesser of the 2...
// Utility.browserVersion = function()
// {
// 	//Detect IE5.5+
// 	var _version=0;
// 	if (navigator.appVersion.indexOf("MSIE")!=-1)
// 	{
// 		var _temp=navigator.appVersion.split("MSIE")
// 		_version=parseFloat(_temp[1])
// 		//alert(version);
// 	}
// 	
// 	return _version;	
// }




Utility.message = function(passedTitle, passedMessage, passedType, params)
{

	var _divMessage;
	var _parent = 'parent';
	var _message = "<div id='divMessagingSystemTitle'>" + passedTitle + "</div><div id='divMessagingSystemMessage'>" + passedMessage + "</div>";

	for ( var n in params)
	{
		//var _window[n] = values[n];
		alert( values[n]);
	}
	
	if (parent.frames.length < 1)
	{
		//alert("divMessage is in this page");
		_divMessage = document.getElementById('divMessagingSystem');
		_parent='document';
	}
	else
	{
		//alert("divMessage is in the parent page");
		_divMessage = parent.window.document.getElementById('divMessagingSystem');
		_parent = 'parent';
	}


	try
	{
		window[_parent].showMessage(passedTitle,_message,passedType.toUpperCase() );
	}
	catch(ex)
	{
		alert(passedTitle + "\n\r" + _message);
	}
	//Utility.showMessage(passedTitle, _message, passedType.toUpperCase() );

}

Utility.isNumeric = function(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   
	return IsNumber;
}



Utility.isEmailValid = function(passedEmail)
{
	var _testResults = false;
	var _str = passedEmail;
	var _filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if ( _filter.test(_str) )
	{
		_testResults=true;
	}
	else
	{
		_testResults=false;
	}
	
	return (_testResults);
}


Utility.floatWindow = function(passedURL,passedTitle,params)
{
	
}

//http://webdevtips.co.uk/webdevtips/faq/javascript/index.shtml 
Utility.getWindowWidth = function()
{
	var _docWidth = 0;
	
	//opera Netscape 6 Netscape 4x Mozilla                                  
	if (window.innerWidth){
		alert("window.innerWidth: " + window.innerWidth); 
	_docWidth = window.innerWidth; 
	} 
	//IE Mozilla 
	if (document.body.clientWidth){ 
		alert("document.body.clientWidth: " + document.body.clientWidth);
	_docWidth = document.body.clientWidth; 
	}
	
	alert("Utility - _docWidth: " + _docWidth);
	return _docWidth;
}

//http://webdevtips.co.uk/webdevtips/faq/javascript/index.shtml 
Utility.getWindowHeight = function()
{
	var _docHeight = 0;
	//opera Netscape 6 Netscape 4x Mozilla                                  
	if (window.innerHeight){ 
	_docHeight = window.innerHeight; 
	} 
	//IE Mozilla 
	if (document.body.clientWidth || document.body.clientHeight){ 
	_docHeight = document.body.clientHeight; 
	}
	
	return _docHeight;
}


Utility.pageWidth = function()
{
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
	
Utility.pageHeight = function()
{
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 
	
Utility.posLeft =	function() 
{
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 
	
Utility.posTop = function() 
{
	return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
} 

Utility.isIE = function()
{
	if (navigator.appName.indexOf('Explorer') != -1)
	{
		//alert("found IE");
		return true;
	}

	//alert("not IE");
	return false;
}

Utility.browserName = function()
{
	return navigator.appName;
}

Utility.userAgent = function()
{
	var browserName = ""; 

	var ua = navigator.userAgent.toLowerCase(); 
	if ( ua.indexOf( "opera" ) != -1 ) { 
	browserName = "opera"; 
	} else if ( ua.indexOf( "msie" ) != -1 ) { 
	browserName = "msie"; 
	} else if ( ua.indexOf( "safari" ) != -1 ) { 
	browserName = "safari"; 
	} else if ( ua.indexOf( "mozilla" ) != -1 ) { 
	if ( ua.indexOf( "firefox" ) != -1 ) { 
	browserName = "firefox"; 
	} else { 
	browserName = "mozilla"; 
	} 
	} 

	return browserName;
}

Utility.browserVersion = function()
{
	var _version = "";
	
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		//alert("found MSIE");
		temp=navigator.appVersion.split("MSIE")
		_version=parseFloat(temp[1])
	}
	else
	{
		b_version=navigator.appVersion;
		_version=parseFloat(b_version);
	}
	

	//alert('version: ' + _version);
	return _version;
}	



//http://www.netlobo.com/url_query_string_javascript.html
Utility.gup = function(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


	//function posRight() {return posLeft()+pageWidth();} 
	
	//function posBottom() {return posTop()+pageHeight();}
