var Walden = {};

Walden.popupVideoHTML = '<div id="jsVideoPlayer" class="jsVideoPlayerLoader"><div id="jsVideoPlayerClose"></div></div><div id="jsVideoPlayerScreen"></div>';
Walden.oldTrackingCode ="";
Walden.nonDegreeTrackingCode = "NDEG0020";
Walden.waldenStoriesDirectory = "Walden-Stories";
Walden.waldenVideoGallery = "University-Videos";

$(document).ready(function(){	
	/* VR 2009.02.04*/ 
	// table zebra stripes
	$('div.center table tr:nth-child(odd)').addClass('odd');
	
	$('#iframe-container table tr:nth-child(odd)').addClass('odd');
	
	// :psuedo class fix
	$('ul>li:first-child, tr>td:first-child, tr>th:first-child').addClass('firstChild');
	$('ul>li:last-child,  tr>td:last-child,  tr>th:last-child').addClass('lastChild');
	
	// highlight first td
	$('div.center table tr td:first-child').addClass('highlight');
	
	$('ul.xtabs').tabs();
	
	// add functions and HTML to style the primary nav
	$('ul#main-menu>li').each(function(i){
		$(this)
			.attr('id', 'mainMenuLi' + i)
			.find('a').eq(0).append('<span></span>') // the SPAN holds the BG image of the nav
			.end()
			.end()
			.hover(
				function () {
					$('ul#main-menu li.active').removeClass('active').addClass('activeOff');
					$(this).addClass('hover');
				}, 
				function () {
					$('ul#main-menu li.activeOff').removeClass('activeOff').addClass('active');
					$(this).removeClass('hover');
				}
			);
	});
	
	// add slider functionality
	$('div.slider h1').click(function(i){
		if($(this).is('.active') == false) {
			$(this)
				.addClass('active')
				.next()
				.slideDown();
		}
		else {
			$(this)
				.removeClass('active')
				.next()
				.slideUp();
		}
	});

	// two-column-content float fix
	$('#two-column-content div.promo-image').each(function(i){
		if(i % 2) {
			$(this).after('<div style="clear: both"></div>');
		}
	});


           $('div#liketo h3').each(function(i){
                if(i === 0){
                    $(this).addClass("open"); // set the first one OPEN by default
                }
                //Removed other logic after home page sliders removed (ds)
            });

	// onclick hander for links defined as popup windows (ds)
	    $("a.popup").click(function () {
	        var args = getPageandArgs($(this).attr("href"));
	        var popupwin = newpopup($(this).attr("href"),args.name,args.width,args.height,args.offsetx,args.offsety,args.toolbar,args.scrollbars,args.resizable);
	        popupwin.focus();
	        return false;
    	});
    	
    	// onclick handler for print tracking via SiteCatalyst
    	$("a[href='javascript:window.print()']").click (function () {
    		SiteCatalyst.sendPrintEvent();
    	});
    	
    	// onclick handler for continue button on the short homepage request info form 
    	$("form div input[src='/_res/img/continue.gif']").click (function () {
    		SiteCatalyst.sendShortFormContinueEvent();
    	});
    	
    	// Replace link to Request Information form with link to the optimal two step form 05.06.2009 (ds)
    	$("a[href='/Forms/Request-Information-TwoStep.aspx']").attr("href","/Forms/Request-Information-TwoStep.aspx?FormID=2");
	$("a[href='/Forms/Request-Information.aspx']").attr("href","/Forms/Request-Information-TwoStep.aspx?FormID=2");
	
	$(".loading").css({'display':'none'});
		
	$("#rotator").after('<div id="controls">').cycle({
		pager : '#controls',
		speed: 'slow',
		timeout: 7000,
		fx: 'fade',
		pagerClick: pauseSlideShow
	});	
	$("input.referanother").click(function () {
      		$(".extrarows").show();
      		$("input.referanother").hide();
    	}); 
	 
	$("a.media").click(function(){$(this).blur();$("body").append(Walden.popupVideoHTML);$("#jsVideoPlayerScreen").css("opacity",0.7);var e=$(this).attr("class").replace("media ","");var k=$(this).attr("href");var g=$(this).offset().left;var f=$(this).offset().top;var b=$(this).width()-10;var i=$(this).height()-10;if($(this).find("img").size()===1){b=$(this).find("img").width()-10;i=$(this).find("img").height()-10;g=$(this).find("img").offset().left;f=$(this).find("img").offset().top}if(b<1){b=1}if(i<1){i=1}var j=parseInt(((e.match(/w:(\d+)/)||[])[1]||0),10);var d=parseInt(((e.match(/h:(\d+)/)||[])[1]||0),10);var a=parseInt($(window).width()/2,10)-parseInt((j/2),10);var m=parseInt($(window).scrollTop()+140,10);$("#jsVideoPlayer").css("width",b+"px").css("height",i+"px").css("top",f+"px").css("left",g+"px").css("display","block").animate({width:j+"px",height:d+"px",left:a-5+"px",top:m-5+"px"},250,function(){$(this).append('<div class="getFlashPlayer"></a>').find("div.getFlashPlayer").click(function(){location.href="http://www.adobe.com/go/EN_US-H-GET-FLASH"}).end().removeClass("videoPlayerLoader").find("div.getFlashPlayer").jmedia({version:"9,0"},{src:k+"?type=.swf",width:j,height:d,quality:"best"})});$("#jsVideoPlayerScreen, #jsVideoPlayerClose").click(function(){$("#jsVideoPlayer").addClass("videoPlayerLoader").css("height",$("#jsVideoPlayer").height()).html("").animate({width:b+"px",height:i+"px",top:f+"px",left:g+"px",opacity:0.1},250,function(){$("#jsVideoPlayer, #jsVideoPlayerScreen").remove()})});return false});

	$(".video-section h2").click (function () { $(this).toggleClass("closed").next(".video-section-more").slideToggle("normal").end().next(".related-videos").slideToggle("normal");})
			      
	$("a[rel='transparency']").colorbox({width:"650px", height:"650px"});
	
	//Social Media Click tracking
	$("a.sm-facebook").click (function () {SiteCatalyst.sendSocialMediaClickEvent("Facebook");});
	$("a.sm-linkedin").click (function () {SiteCatalyst.sendSocialMediaClickEvent("LinkedIn");});
	$("a.sm-myspace").click (function () {SiteCatalyst.sendSocialMediaClickEvent("Myspace");});
	$("a.sm-youtube").click (function () {SiteCatalyst.sendSocialMediaClickEvent("YouTube");});
	$("a.sm-twitter").click (function () {SiteCatalyst.sendSocialMediaClickEvent("Twitter");});
	
	$("#RequestInformationTwoStep_PersonalInfoButton").attr("value", "");
	$("#RequestInformationTwoStep_EducationalInfoButton").attr("value", "");

	progressControls = new Array();
        
        $("#RequestInformationTwoStep_Wizard1_StartNavigationTemplateContainerID_StartNextImageButton, #RequestInformationTwoStep_Wizard1_FinishNavigationTemplateContainerID_FinishImageButton").click
			(function(){SiteCatalyst.reportErrors();});
        
        if (location.href.indexOf('TwoStep') > 0)
        {
        	var fixString = $("#RequestInformationTwoStep_Wizard1 p:first").html();
		if (fixString.indexOf('Thank you for sharing your goals with us') > 0)
		{
        		$("#RequestInformationTwoStep_Wizard1 p:first").html(fixString.replace("goals", "information"));
        	}
	}	
	// Create Tracking ID cookie
	var pageArgs = getArgs();
	if ("cid" in pageArgs)
	{
		var tCode = pageArgs.cid.split(":");
		// If tracking code exists in the format ret:XXXXXXX:2 where XXXXXXX is the tracking code
		if (tCode[1] != undefined && (tCode.length == 3 || tCode.length == 2))
			createCookie("TrackingCode", tCode[1], 365);
		else if (tCode.length == 1)
			createCookie("TrackingCode", tCode[0], 365)
	}

	//Begin: cookie check for sub-hero area
	//Checks whether "to-do" options have been checked
	var toDoList = readCookie("to-do");
	if(toDoList == null)
	{
		createCookie("to-do", "00000", 365);
	}
	else {
		for(i=0;i<toDoList.length;i++)
		{
			if (toDoList.charAt(i) == "1")
			{
				$("#to-do li:eq(" + i + ")").addClass("done");
			}
		}
	}
	$("#to-do li").click (function(){
		$(this).addClass("done");
		var toDoList = readCookie("to-do");
		for (i=0;i<toDoList.length;i++)
		{
			if ($(this).parent().children().eq(i).html() == $(this).html())
			{
				// We flip the checklist
				var a = toDoList.substr(0,i);
				var b = toDoList.substr(i+1,toDoList.length-1);
				var newToDoList = a + "1" + b;
				createCookie("to-do",newToDoList, 365);
			}
		}
	});
	
			
	checkRememberCookies();
	//End: Cookie logic for sub-hero area

	$("ul.homepage-tabs").tabs();

	$(".colorbox-story").click(function(e){
		e.preventDefault();
		window.location.hash = $(this).attr("href");
		$.fn.colorbox({iframe:true, href:$(this).attr("href"),width:960, height:650, overlayClose:false});
	});
	
	$(".thickbox").click (function(){
		parent.location.hash = $(this).attr("href");
	});

	$(".videos").colorbox({iframe:true, innerWidth:1040, innerHeight:580});
    $(".video-single").colorbox({iframe:true, innerWidth:600, innerHeight:400});
	$(".video-single-640").colorbox({iframe:true, innerWidth:700, innerHeight:520});
	
	// Open colorbox window for pages for hashed Walden Story or University Video embed pages
	if (window.location.hash && (top == window))
	{				
		if (window.location.hash.indexOf(Walden.waldenStoriesDirectory) >= 0)
		{
			var url = window.location.hash.replace("#", "");
			$.fn.colorbox({iframe:true, href:url,width:960, height:650, overlayClose:false})
		}
		else if (window.location.toString().indexOf(Walden.waldenVideoGallery) >= 0)
		{
			var url = window.location.hash.replace("#", "");
			// If URL indicates the embedded page has a single video on it
			if (getArgs().singleVideo)
				$.fn.colorbox({iframe:true, href:url,innerWidth:700, innerHeight:500});
			else if (url.indexOf('/') >=0)
				$.fn.colorbox({iframe:true, href:url,innerWidth:1000, innerHeight:590});
		}
	}
	
	$(".sitemap ul li ul li").each(function(){
		if ($(this).children("ul").children().length > 2) {
			$(this).addClass("expandable");
		}
	});

	$(".sitemap ul li ul li").click(function(){
		$(this).toggleClass("opened");
	});
	
	addLoadEvent(function() {
	setTimeout(initOverLabels, 50);
});
        
});
function pauseSlideShow() {
	$('#rotator').cycle('pause');
}

// New function to open a popup window
// undefined parameters are initialzed to default values
function newpopup(loc, name, width, height, offsetx, offsety, toolbar, scrollbars, resizable){
 	//Check for width and height, if undefined then define as screen width and height
 	if (!width) {width=screen.width;}
 	if (!height) {height = screen.height;}
 	//Set default for popup offsets
  	if(!offsetx && !offsety){
  		var scr_x = screen.width;
  		var scr_y = screen.height;
  		var offsetx = (scr_x/2)-(width/2);
  		var offsety = (scr_y/2)-(height/2);
  	}
	var optToolbar, optScrollbars, optResizable;
	//Check for nulls and assign defaults if we find one, otherwise assign the passed value
	(!name) ? optName = "popup" : optName= name;
	(!toolbar) ? optToolbar = "toolbar=no" : optToolbar = "toolbar=" + toolbar;
	(!scrollbars) ? optScrollbars = "scrollbars=no" : optScrollbars = "scrollbars=" + scrollbars;
	(!resizable) ? optResizable = "resizable=no" : optResizable = "resizable=" + resizable;
	var options = optToolbar + ",location=no, directories=no, status=no, menubar=no," + optScrollbars + "," + optResizable + ", width="+width+", height="+height+", left="+offsetx+", top="+offsety;
	return window.open(loc, optName, options);
}

// Function to parse an href value and return an object
// with the href page value and any arguments passed as well.
function getPageandArgs(href) {
	var args = new Object( );
    	var url = href.split("?");
    	args["page"] = url[0];
    	var query = url[1];
    	// Only parse query parameters if there are some
    	if (query) {
    		var pairs = query.split("&");
		for(var i = 0; i < pairs.length; i++) {
			var pos = pairs[i].indexOf('=');
			if (pos == -1) continue;
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			value = decodeURIComponent(value);
			args[argname] = value;
		}
    	}
    	return args;
}

/*
 * This function parses ampersand-separated name=value argument pairs from
 * the query string of the URL. It stores the name=value pairs in
 * properties of an object and returns that object. Use it like this:
 *
 * var args = getArgs( );  // Parse args from URL
 * var q = args.q || "";  // Use argument, if defined, or a default value
 * var n = args.n ? parseInt(args.n) : 10;
 */
function getArgs( ) {
    var args = new Object( );
    var query = location.search.substring(1);     // Get query string
    var pairs = query.split("&");                 // Break at ampersand
    for(var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');          // Look for "name=value"
        if (pos == -1) continue;                  // If not found, skip
        var argname = pairs[i].substring(0,pos);  // Extract the name
        var value = pairs[i].substring(pos+1);    // Extract the value
        value = decodeURIComponent(value);        // Decode it, if needed
        args[argname] = value;                    // Store as a property
    }
    return args;                                  // Return the object
}

var SiteCatalyst = {};

SiteCatalyst.sendVideoStartEvent = function (title) {
	s=s_gi('laureateWaldenU');
        s.linkTrackVars= 'prop7,eVar7,events';
        s.linkTrackEvents= 'event6';
        s.prop7 = title;
        s.eVar7 = title;
	s.events = 'event6';
        s.tl(this,'o', 'Video Started');
}

SiteCatalyst.sendVideoCompleteEvent = function (title) {
	s=s_gi('laureateWaldenU');
        s.linkTrackVars= 'prop7,eVar7,events';
        s.linkTrackEvents= 'event7';
        s.prop7 = title;
        s.eVar7 = title;
	s.events = 'event7';
        s.tl(this,'o', 'Video Completed');
}

SiteCatalyst.sendPrintEvent = function () {
	s.linkTrackVars = 'eVar8,events';
	s.linkTrackEvents = 'event8';
	s.eVar8 = s.pageName;
	s.events = 'event8';
	s.tl(this,'o', 'Page Printed');
}

SiteCatalyst.sendSocialMediaClickEvent = function (link) {
	s.linkTrackVars = 'prop18,eVar18';
	s.eVar18 = link;
	s.prop18 = link;
	s.tl(this,'o', 'Social Media Clickthrough');
}

SiteCatalyst.sendShortFormContinueEvent = function () {
	s.linkTrackVars = 'events';
	s.linkTrackEvents = 'event14';
	s.events = 'event14';
	s.tl(this,'o', 'Request Info Short Form-Continue');
}

SiteCatalyst.setSectionLevelProps = function (lstr) {
	var c = lstr.split("|");
	if (c.length > 3) {
		s.prop21 = c.slice(0,4).join("|");
	}
	if (c.length > 2) {
		s.prop20 = c.slice(0,3).join("|");
	}
	if (c.length > 1) {
		s.prop19 = c.slice(0,2).join("|");
	}
}
// Function to send a list of errors to SiteCatalyst
SiteCatalyst.reportErrors = function () {
	// Check validations summaries to see if they are empty. If so, when the submit button is
	// clicked in either step, check if the validator has fired. If so, report the errors.
	if ($("#RequestInformationTwoStep_Wizard1_ValidationSummary2, #RequestInformationTwoStep_Wizard1_ValidationSummary1").html() != null) {
	    if ($("#RequestInformationTwoStep_Wizard1_ValidationSummary2, #RequestInformationTwoStep_Wizard1_ValidationSummary1").html().length > 0) {
		if (typeof(Page_ClientValidate) == 'function') {
			isValid = Page_ClientValidate();
		}
		if (!isValid){
			scEvents="";
			var formErrors="";
			$("#RequestInformationTwoStep_Wizard1_ValidationSummary2 ul li, #RequestInformationTwoStep_Wizard1_ValidationSummary1 ul li").each(function(){
				if (formErrors.length > 0){
					formErrors+= "|" + $(this).html();
				}
				else {
					formErrors+= $(this).html();
				}
			});
			formErrors = formErrors.replace(/ is a (mandatory|required) field[. ]?/g, "");
			s.sendFormEvent('e','Request Information', 'aspnetForm', formErrors);
		}
	    }
	}
}

var progressControls = new Array();

// Page Load function for Asynch postback for .NET forms
function pageLoad() {
	// Attempt to read Tracking ID cookie
	var TrackingCode = readCookie("TrackingCode");
	if (!IsNullOrBlank(TrackingCode))
	{
		$("#RequestInformationTwoStep_Wizard1_hfCommCode").val(TrackingCode);
	}	

	var milestonesrc = $("#RequestInformationTwoStep_Wizard1_RegisterMilestoneImage").attr("src");
	if (milestonesrc) {$("#RequestInformationTwoStep_Wizard1_RegisterMilestoneImage").attr("src", milestonesrc.replace(".qual", ""));}

	$("#RequestInformationTwoStep_Wizard1_ddlCountry").unbind();
	$("#RequestInformationTwoStep_Wizard1_ddlCountry").change(function() {
	if ($(this).val() != null || $(this).val() != "") 
	    {
		$(".countrycode").show();
		$("#RequestInformationTwoStep_Wizard1_tbHomeCountryCode").val(CountryCodes[$(this).val().toString()]);
		$("#RequestInformationTwoStep_Wizard1_tbWorkCountryCode").val(CountryCodes[$(this).val().toString()]);
	    }
	    if ($(this).val() == "USA")
	    {
		$(".countrycode").hide();
	    }
	});

	$("#ODWrap .areacode,#ODWrap .phone1,#ODWrap .phone2").keyup(function() {
	    //check if the length is equal to the max length
	    if ($(this).val().length >= parseInt($(this).attr("maxlength"))) {
		$(this).next().next("input").focus();
	    }
	});
	
	$(".areacode,.phone1,.phone2").keyup(function() {
	    //check if the length is equal to the max length
	    if ($(this).val().length >= parseInt($(this).attr("maxlength"))) {
		$(this).next("input").focus();
	    }
	});
	
        $("#RequestInformationTwoStep_Wizard1_ddlDegree").change(function(){
        	//Change Onyx Tracking code to NonDegree code if "Individual Courses" is selected
        	if($("#RequestInformationTwoStep_Wizard1_ddlDegree").val() == "Individual Courses")
        	{
        		Walden.oldTrackingCode = $("#RequestInformationTwoStep_Wizard1_hfCommCode").val();
        		//alert ("change code");
        		$("#RequestInformationTwoStep_Wizard1_hfCommCode").val(Walden.nonDegreeTrackingCode);
        	}
        	else 
        	{
        		$("#RequestInformationTwoStep_Wizard1_hfCommCode").val(Walden.oldTrackingCode);        	
        	}
        	
        });
        // if the validator code is included on the page, initialize it
        if (jQuery.validator)
        {
		// jQuery Validator Code

		// Define template for custom error bubble HTML for each step
		var customErrorContainerStep1 = "<!--start error bubble--><div class=\"errorbubble\"><div class=\"leftcap\"></div><div class=\"rightcap\"><p>{0}</p></div><br class=\"clear\" /></div><!--end error bubble-->";
		var customErrorContainerStep2 = "<!--start error bubble--><div class=\"errorbubble2\"><div class=\"topcap\"><div class=\"btmcap\"><p>{0}</p></div></div></div><!--end error bubble-->";
	
		// Custom Validator method for the 3 phone fields
		// Require all three fields to be filled out, but only display one message
		jQuery.validator.addMethod('required_phone', function(val, el) {
			//check that all elements in a group are filled
			var $module = $(el).parent();
			// Check that there are three filled out fields for the phone
			if ($module.find('input:filled').length >= 3)
			{
				if ($("#RequestInformationTwoStep_Wizard1_ddlCountry").val() === "USA")
				{
					if($("#RequestInformationTwoStep_Wizard1_tbHomeAreaCode").val().length ==3 &&
					   $("#RequestInformationTwoStep_Wizard1_tbPhone1").val().length ==3 &&
					   $("#RequestInformationTwoStep_Wizard1_tbPhone2").val().length ==4)
					{
						return true;
					}
				}
				else 
				{
					return true;
				}
			}
			return false;
		},jQuery.format(customErrorContainerStep1, "Enter a valid phone"));

		// jQuery validate call
		// Field identifiers must change if the user control prefix tag changes cause asp.net is awesome
		$("#aspnetForm").validate({ 
			rules: 	{
					RequestInformationTwoStep$Wizard1$ddlDegree: {
						required: true
					},
					RequestInformationTwoStep$Wizard1$ddlHighestEd: {
						required: true
					},
					RequestInformationTwoStep$Wizard1$tbFirst_Name: {
						required: true
					},
					RequestInformationTwoStep$Wizard1$tbLast_Name: {
						required: true
					},				
					RequestInformationTwoStep$Wizard1$tbEmail: {
						required: true,
						email: true
					},
					RequestInformationTwoStep$Wizard1$tbAddress1: {
						required: true
					},
					RequestInformationTwoStep$Wizard1$tbCity: {
						required: true
					},				
					RequestInformationTwoStep$Wizard1$ddlCountry: {
						required: true
					},
					RequestInformationTwoStep$Wizard1$tbZip: {
						required: true
					},			
					// ddlStateBackup should only be evaluated if it is on the 
					// page. Validator plugin only evaluates if it is there.
					RequestInformationTwoStep$Wizard1$ddlStateBackup: {
						required:true
					},
					RequestInformationTwoStep$Wizard1$tbState: {
						required:true
					},
					RequestInformationTwoStep$Wizard1$ca_provinces: {
						required:true			
					},
					RequestInformationTwoStep$Wizard1$DropDownListPreferOnline: 	{
						required:true			
					}				
			},
			messages: { 
				RequestInformationTwoStep$Wizard1$ddlDegree: {
					required: jQuery.format(customErrorContainerStep1, "Select a program")
				},
				RequestInformationTwoStep$Wizard1$ddlHighestEd: {
					required: jQuery.format(customErrorContainerStep1, "Select a level of education")
				},
				RequestInformationTwoStep$Wizard1$tbFirst_Name: {
					required: jQuery.format(customErrorContainerStep2, "Enter a First Name")
				},
				RequestInformationTwoStep$Wizard1$tbLast_Name: {
					required: jQuery.format(customErrorContainerStep2, "Enter a Last Name")
				},				
				RequestInformationTwoStep$Wizard1$tbEmail: {
					required: jQuery.format(customErrorContainerStep2, "Enter a email"),
					email: jQuery.format(customErrorContainerStep2, "Enter a valid email address")
				},
				RequestInformationTwoStep$Wizard1$tbAddress1: {
					required: jQuery.format(customErrorContainerStep2, "Enter a street address")
				},
				RequestInformationTwoStep$Wizard1$tbCity: {
					required: jQuery.format(customErrorContainerStep2, "Enter a city")
				},
				RequestInformationTwoStep$Wizard1$ddlCountry: {
					required: jQuery.format(customErrorContainerStep2, "Select a country")
				},			
				RequestInformationTwoStep$Wizard1$tbZip: {
					required: jQuery.format(customErrorContainerStep1, "Enter a Zip/Postal Code")
				},
				RequestInformationTwoStep$Wizard1$ddlStateBackup: {
					required: jQuery.format(customErrorContainerStep2, "Select a state")
				},
				RequestInformationTwoStep$Wizard1$tbState: {
					required: jQuery.format(customErrorContainerStep2, "Enter a state")
				},
				RequestInformationTwoStep$Wizard1$ca_provinces: {
					required: jQuery.format(customErrorContainerStep2, "Select a province")
				},
				RequestInformationTwoStep$Wizard1$DropDownListPreferOnline: {
					required: jQuery.format(customErrorContainerStep1, "Select online degree preference")
				}
			},        		
			errorPlacement:function(error,element) {
				if (element.attr("name") === "RequestInformationTwoStep$Wizard1$tbPhone2")
				{
					error.appendTo(element.parent().parent().parent().parent().parent().next());
				}
				else if (element.attr("name") === "RequestInformationTwoStep$Wizard1$tbCity" ||
					 element.attr("name") === "RequestInformationTwoStep$Wizard1$ddlStateBackup" ||
					 element.attr("name") === "RequestInformationTwoStep$Wizard1$ca_provinces")
				{
					error.appendTo(element.parent().parent().next());
				}
				else if (element.attr("name") === "RequestInformationTwoStep$Wizard1$DropDownListPreferOnline" ||
							element.attr("name") === "RequestInformationTwoStep$Wizard1$ddlDegree")
				{
					error.appendTo(element.parent());
				}	
				else 
				{
					error.appendTo(element.parent().next());
				}  
			},
			errorElement:"div"   			
		});
	}
	
	// Utility function for hiding/showing labels over top of input fields
	setTimeout(initOverLabels, 50);
        
}

Array.prototype.containsValue = function(value) {
for (var i=0;i<this.length;i++)
{
    if (this[i] == value){
	return true;
    }
}
return false;
}

function IsNullOrBlank(s) {
if (s == "" || s == null || s == "none") {
    //console.log("true: " + s);
    return true;
}
else {
    //console.log("false: " + s);
    return false;
}
}
// Begin Utility functions for Cookie for Sub-hero to do area
function createCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	$("#to-do li").removeClass("done");
	createCookie(name,"",-1);
}
	
function checkRememberCookies()
{
	var x =document.getElementById('chk_5');
	if(x)
	{
		captureCheckValues();
	}else{
		setTimeout('checkRememberCookies();',200);
	}
}
function captureCheckValues(){
	for(i=1;i<6;i++){
		if (readCookie('chk_'+i)=='on')
		{
			try{
			document.getElementById('chk_'+i).checked = true;
			}
			catch(e){alert('chk_'+i);}
		}
	}
	
}
function workChecker(w,chker)
{
	if (chker=='false')
	{document.getElementById(w).checked = !document.getElementById(w).checked;}
	if (document.getElementById(w).checked)
	{
		createCookie(w,'on',999999);
	}else{
		eraseCookie(w);
	}
	
}
function checkme(w, chker, _href)
{
	workChecker('chk_'+w, chker);
        if (_href != 'none'){ document.location.href=_href;}
}
// End Utility functions for Cookie for Sub-hero to do area


function initOverLabels () {
  if (!document.getElementById) return;      

  var labels, id, field;

  // Set focus and blur handlers to hide and show 
  // LABELs with 'overlabel' class names.
  labels = document.getElementsByTagName('label'); 
  for (var i = 0; i < labels.length; i++) {

    if (labels[i].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute ('for');
      if (!id || !(field = document.getElementById(id))) {
	continue;
      } 

      // Hide any fields having an initial value.
      if (field.value !== '') {
	hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
	hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
	if (this.value === '') {
	  hideLabel(this.getAttribute('id'), false);
	}
      };

      // Handle clicks to LABEL elements (for Safari).
      labels[i].onclick = function () {
	var id, field;
	id = this.getAttribute('for');
	if (id && (field = document.getElementById(id))) {
	  field.focus();
	}
      };

    }
  }
};

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    field_for = labels[i].htmlFor || labels[i]. getAttribute('for');
    if (field_for == field_id) {
      labels[i].style.textIndent = (hide) ? '-1000px' : '0px';
      return true;
    }
  }
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
	oldonload();
      }
      func();
    }
  }
}


