/******** begin calendar *********/
	//setup some default values
	var myMaxYear			= 2029;
	var myCurrentYear 		= new Date().getFullYear();
	var myYearInView		= myCurrentYear;

	//this is what loops through the array
	function navigateCalendar(direction) {
		if(direction == "back") {
			// step backward 1 year
			myYearInView--;
			if(myYearInView<myCurrentYear) myYearInView=myMaxYear;//wrap
		} else if(direction == "forward") {
			// step forward 1 year
			myYearInView++;
			if(myYearInView>myMaxYear) myYearInView=myCurrentYear;//wrap
		} else {
			// move to specified year
			myYearInView=direction;
		}
		//set the new image
		//var img = new Image();
		//img.src = '/i/SITE_051110_15412548_16FSD/calendars/' + myYearInView + '.gif';
		//img.onload=switchCal;
		document.getElementById('myCalendarImageID').src = '/i/SITE_051110_15412548_16FSD/calendars/' + myYearInView + '.gif';
                document.getElementById("yearPicker").value=myYearInView
	}
	function switchCal() {
		document.getElementById('myCalendarImageID').src = '/i/SITE_051110_15412548_16FSD/calendars/' + myYearInView + '.gif';
		//document.myCalendarImage.src = '/i/SITE_051110_15412548_16FSD/calendars/' + myYearInView + '.gif';
	}
/******** end calendar *********/
	function replaceChars(entry,out,add)
		{
		temp = "" + entry; // temporary holder
		//run the while loop to remove all instances of the string
		while (temp.indexOf(out)>-1) 
			{
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
			}
		return temp;
		}

	function createAnchor(baseLink)
		{
		var myString = document.title;
		var myLength = myString.length;
		var myPropName = "";
		var myReturnName = "";
		var myReturnURL = "";
		//loop up the string till you find the lst delim
		for(var uu = myLength; uu >= 0; uu--)
			{
			if(	myString.substr(uu, 1) == "-")
				{myPropName = (myString.substr(uu + 2, myLength)); break;}
			}
		//remove the spaces
		myPropName = replaceChars(myPropName, "'", " ");
		myPropName = replaceChars(myPropName, "'", " ");
		myPropName = replaceChars(myPropName, " ", "_");		
		//set the name to the return var
		myReturnName = myPropName;
		myReturnURL = baseLink + "#" + myReturnName;
		window.location.href=(myReturnURL);		
		}	
	function hideProtectedText()
		{
		/*vars */
		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
		var isPC = (navigator.appVersion.indexOf("Mac") != -1) ? false : true;
		/*replace this with a check of the cookie*/
		var groupType = GetCFCookie("USERTYPE");
		var myElement = "";
		var arraylength = 0;
		var isInCMS = (window.location.href.indexOf("hands-on") != -1) ? true : false;
		var myGroupToHide = "";
		/*action code*/
			/*check to see that the cookie exists and has a value, if not send them to the homepage*/
		if(!isInCMS)	
			{
			if(!groupType.length)
				{/*window.location.href=('/');*/}
			else
				{
				/*whatever the group is I need to hide the other*/
				if(groupType == "core")
					{myGroupToHide = "associate";}
				else
					{myGroupToHide = "core";}
				
				myElement = document.getElementsByName(myGroupToHide);
				arraylength = (myElement.length * 1);
				/*check to make sure the array has a length and the loop through it*/
				if(arraylength)
					{
					for(var j=0;j<arraylength;j++)
						{
						if(isIE && isPC)
							{myElement[j].innerText = "";}
						else
							{myElement[j].innerHTML = "";}
						}
					}
				}
				//check to see if we need to hide any nav elements
				if( (document.getElementById('PAGE_10202006_103802630_65FPM')) && (groupType == 'associate' || groupType == 'guest') )
					{
					document.getElementById('PAGE_10202006_103802630_65FPM').style.visibility = "hidden";
					if(isIE && isPC)
						{document.getElementById('PAGE_10202006_103802630_65FPM').innerText = "";}
					else
						{document.getElementById('PAGE_10202006_103802630_65FPM').innerHTML = "";}
					}
			}
		};
        function makeSelection()
		{
		//setup any needed vars
		var myValue = document.PropSwitcher.prop[document.PropSwitcher.prop.selectedIndex].value;
		//check to see if the value has a length
		if(myValue.length)
			{
				//set the cookies
				SetCFDomainCookie('USERTYPE',myValue);
				//send me to the homepage
				window.location.href = '/index.cfm?skip=once';
			}
		else
			{alert("Please Select A Property");}
		};
	function replaceLabelTxt() {
		// get label tags
		labels = document.getElementsByTagName("label");
		for(var i=0;i<labels.length;i++){
			if(labels[i].id){
				// ajax to server
				retrieveText(labels[i].id);
				//labels[i].innerText="and non-useless label";
			}
		}
	}

	function retrieveText(id) {
		// open ajax connection
		httpa.open("GET", url + id, true);
		// set method for retrieving data
		httpa.onreadystatechange = handleTextRetrieved;
		// send request
		httpa.send(null);
	}
	function handleTextRetrieved() {
	/*
		format:
		<text id="#id#">#text_to_insert#</text>
	*/
		if (httpa.readyState==4&&typeof httpa.responseXML != null) {
			// load the XML
			var xmlDoc = httpa.responseXML;
			var xmlObj = xmlDoc.documentElement;
			var labelToReplace = document.getElementById(xmlObj.id);
			if (!labelToReplace)return;
			labelToReplace.innerText=xmlObj.innerText;
		}
	}

     function getHTTPObject() {
	  var xmlhttp;
	  /*@cc_on
	  @if (@_jscript_version >= 5)
	    try {
	      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	      try {
	        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	      } catch (E) {
	        xmlhttp = false;
	      }
	    }
	  @else
	  xmlhttp = false;
	  @end @*/
	  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	    try {
	      xmlhttp = new XMLHttpRequest();
	    } catch (e) {
	      xmlhttp = false;
	    }
	  }
	  return xmlhttp;
	}

	function SetCFDomainCookie (name, value)
	{
	var name = name.toUpperCase();
	var path = "/";
	document.cookie = name + "=" + escape (value) +"; path=" + path + "; domain=theregistrycollection.com;";
	};

	var url = "/i/SITE_051110_15412548_16FSD/ajax.cfm?id="; // The server-side script
	var httpa = getHTTPObject(); // We create the HTTP Object
	window.onload=replaceLabelTxt; // Create onload event to fire off label finding & replacing



	$(document).ready(function(){
		$('.CollapseTitle').bind('click',function(){
			var el = $(this).next();
			if(el.is(':hidden')){
				$(this).next().slideDown(250);
				$(this).addClass('CollapseHidden');
			}else{
				$(this).next().slideUp(250);
				$(this).removeClass('CollapseHidden');
			}
		});
		$('.OneColumn li:odd').addClass('alt');
		$('.TwoColumn li:nth-child(4n-1),.TwoColumn li:nth-child(4n)').addClass('alt');
		$('.OneColumn span').each(function(){
			var ht = $(this).html();
			if (!ht.match(/(<p|<li)/i))
				$(this).html('<p>'+ht+'</p>');
		});
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)	

});


