$(document).ready(function(){
	var siteDir = $("#site-root").val() + "/";
	/*Click Version of the menu*/
	$('#menu li .menu-arrow').click(function() {
		var checkElement = $(this).next(); 
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#menu ul:visible').slideUp('normal');
			$('#menu ul:visible').parent('li').removeClass("current_click_state");
			checkElement.parent('li').addClass("current_click_state");
			checkElement.slideDown('normal');
			return false;
			}
		else if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				checkElement.slideUp('normal');
				$('#menu ul:visible').parent('li').removeClass("current_click_state");
				return false;
		}
	});
	
	//Accordian Menu for Mini Guides Section
	$("a.numbered-list-link").click(function(event){
		$(this).parents("li").find(".hidden").slideToggle(500);
		$(this).parents("li").toggleClass("active");
		return false;
	});
	
	//Search Input Swap Value and validates with alert
	var search_input_id = $("#search_input");//Search Input Id
	var search_button_id = $("#search_button");//Search Submit Id
	//$(search_input_id).after("<input type='hidden' id='search_original_val' />");
	var original_val = $(search_input_id).val();
	$(search_button_id).click(function (){
		if ($(search_input_id).val()==original_val){
			alert('Please use a search query other than "' + original_val + '."');
			return false
		}
	});
	
	//Show Search Results in Pop-up
	$("#search_button").click(function(url){
		var SelectedView = siteDir + "search/?q=";
		var search = $("#search_input").val().replace(/ /g,'+');
		if ($(search_input_id).val()!=original_val){
			$("#search_pop_loader").show();
			$("#search_pop_title").load(SelectedView + search + " #search_results_title_inner");
			$("#search_results_pop_loader").load(SelectedView + search + " #post_excerpt_container", function(){
				$("#post_excerpt_container").addClass("search_results_container");
				$("#post_excerpt_container").removeAttr("id");
				$("#search_results_pop").show(300);
				$("#search_pop_loader").hide();
				$("#carousel_cap").fadeOut(100);//Hides the Cap for IE
			});
			return false;
		}
	});

	$("#search_pop_x").click(function(){
		$("#search_results_pop").hide(300);
		$("#carousel_cap").show(0);//Shows the Cap for IE
		return false;
	});
	
	//Swaps Read More text
	var readmore_id = $("#summary_read_more");//Read More Link Id
	var hidden_div_id = $("#hide");//Hidden Div Id
	var default_value = "Hide Additional Info.";//Default Value
	var readmore_original_val = $(readmore_id).text();
	//Toggles the text and adds a class to the anchor. If there is no rel text then "Hide This Info." is the default.
	$(readmore_id).click(function(){
		var reltext = $(this).attr("rel");
		$(hidden_div_id).slideToggle("slow");
		$(this).toggleClass("read_more_active");
		if (reltext != "") {
			$(this).text($(this).text() == readmore_original_val ? reltext : readmore_original_val);
		}
		else {
			$(this).text($(this).text() == readmore_original_val ? default_value : readmore_original_val);
		}
		return false;
	});
	
	//Toggles the text per class name
	$(".content-toggle-trigger a").click(function(){
		$(this).parent(".content-toggle-trigger").prev(".content-toggle-container").find(".toggle").slideToggle("slow");
		$(this).toggleClass("toggle-link-active");
		$(this).text($(this).text() == "Read More..." ? "Hide Additional Info." : "Read More...");
		return false;
	});
	
	//Simple Tabs
	$('#tabs #tabs_menu li a').click(function(){ 
		$('#tabs #tabs_menu li').removeClass('active');
		$(this).parent().addClass('active'); 
		var currentTab = $(this).attr('href'); 
		$('#tabs .tabs_containers').hide();
		$(currentTab).fadeIn(500);
		return false;
	});
	
	//Smooth Scrolling
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();
		
		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;
		
		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
		
		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
		
		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
	
	//Widow Open Unsubscribe
	$("#unsubscribe_link a").click(function() {
		window.open('/optout/', 'Unsubscribe', 'width=550, height=200,scrollbars,menubar=0,resizable=1');
		return false;
	});

	//Lazy Loader
	(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}
	var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}
	this.each(function(){var self=this;if(undefined==$(self).attr("original")){$(self).attr("original",$(self).attr("src"));}
	if("scroll"!=settings.event||undefined==$(self).attr("src")||settings.placeholder==$(self).attr("src")||($.abovethetop(self,settings)||$.leftofbegin(self,settings)||$.belowthefold(self,settings)||$.rightoffold(self,settings))){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}
	self.loaded=false;}else{self.loaded=true;}
	$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))
	[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});$(settings.container).trigger(settings.event);return this;};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}else{var fold=$(settings.container).offset().top+$(settings.container).height();}
	return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}else{var fold=$(settings.container).offset().left+$(settings.container).width();}
	return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollTop();}else{var fold=$(settings.container).offset().top;}
	return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollLeft();}else{var fold=$(settings.container).offset().left;}
	return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);

	//Lazy loader Preferences
	$("#content img").not("#share_container img").not(".is-an-online-degree-in-the-stars-for-you #content img").lazyload({
		placeholder : "/images/spacer.gif",
		effect      : "fadeIn"
	});	
	
	//Populate QDF
	
	var $cid = $("#cid").val();
	var $tsource = $("#tsource").val();
	
	var $eduLvl = $("#eduLvl");
	var $category = $("#category");
	var $industry = $("#industry");
	
	var CategoryText = $category.html();
	var SubjectText = $industry.html();
	
	$eduLvl.attr("onchange","");
	$category.attr("onchange","");

	function CatPop(thise){
		if ($(thise).val() == -1) {
			$("#category_select_container").slideUp(300);
			$category.html(CategoryText).attr("disabled", "disabled");
            $industry.html(SubjectText).attr("disabled", "disabled");
		}
		else {
			$("#category_select_container").slideDown(300);
			$category.html(CategoryText);
			$industry.html(SubjectText).attr("disabled", "disabled");
			$.get('/WebServices/external/ELearnersWebService.asmx/GetCategories_SSOProfile?Degree=' + $(thise).val() + '&RPCamp_GUID=' + $cid + "&tsource=" + $tsource, function (data) {
				$(data).find("Category").each(function(){
					$category.append('<option value="' + $(this).find('Value').text() + '">' + $(this).find('DisplayName').text() + '</option>').attr("disabled","");
				});
			});
		}
	}CatPop($eduLvl);
	
	function SubjectPop(thise){
		if ($(thise).val() == -1) {
			$industry.html(SubjectText).attr("disabled", "disabled");
		}
		else{
			$industry.html(SubjectText);
			$.get('/WebServices/external/ELearnersWebService.asmx/GetSubjects_SSOProfile?Degree=' + $eduLvl.val() + '&Category=' + $(thise).val() + '&RPCamp_GUID=' + $cid + "&tsource=" + $tsource, function (data) {
				$(data).find("Subject").each(function(){
					$industry.append('<option value="' + $(this).find('Value').text() + '">' + $(this).find('DisplayName').text() + '</option>').attr("disabled","");
				});
			});
		}
	}SubjectPop($category);

	$eduLvl.change(function() {
		CatPop(this);
	});
	
	$category.change(function() {
		SubjectPop(this);
	});
	
	//Populate with Query String Param
	/*
	function getQuerystring(key, default_){
	  if (default_==null) default_="";
	  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	  var qs = regex.exec(window.location.href);
	  if(qs == null)
		return default_;
	  else
		return qs[1];
	}

	var QSLevel = getQuerystring('eduLvl');
	var QSCategory = getQuerystring('category');
	var QSSubject = getQuerystring('subject');

	$(window).load(function() {
		$eduLvl.find('option[value="'+ QSLevel +'"]').attr("selected","selected");
		$category.find('option[value="'+ QSCategory +'"]').attr("selected","selected");
		$industry.find('option[value="'+ QSSubject +'"]').attr("selected","selected");
	});
	*/
	//Populate with Query String Param
	
	//Submit QDF
	$("#degree-finder").submit(function (){
	
		//Add Tracking
		var trackingString = "";

		$(this).find(".tracking-param").each(function () {
			if (trackingString.length > 1) trackingString += '&';
			else trackingString = '?';
			trackingString += (this.name + "=" + this.value);
		});

	    var eduLvl = $eduLvl.val();	
		var optOne = $category.val();
	   	var industry = $industry.val().toLowerCase().replace(/ /g, "-");
		var originalAction = $("#degree-finder").attr("action");
		
	   	if (eduLvl == "-1"){
	   		alert("Please choose a Degree Level.");
	   		return false;
	   	}
	   	else if (optOne == "-1"){
	   		alert("Please choose a Category.");
	   		return false;
	   	}
	   	else if (industry == "-1"){
	   		alert("Please choose a Subject.");
	   		return false;
	   	}
	   	else{	
			if (eduLvl == '5') {
				location.href = originalAction + "/programs/" + industry + ".htm" + trackingString;
				return false;
			}
			else{
				switch (eduLvl){
				case "1":
					eduLvl = "associate";
					break;
				case "2":
					eduLvl = "bachelor";
					break;
				case "3":
					eduLvl = "master";
					break;
				case "4":
					eduLvl = "doctorate";
					break;
				}
				location.href = originalAction + "/online-degrees/" + eduLvl + "/" + industry + ".htm" + trackingString;
				return false;
			}
	   	    return true;
	   	}
	});
	
	//Shows Degrees
	$(".show-matching-degrees").click(function(event) {
		$(this).next().next('img').show();
		//Pulls Degrees from Express
		var expresslink = $("#degree-finder").attr("action");
		var linkname = "/guide/files/ajax/proxy.aspx?u=http://guide.elearners.com/" + $(".show-matching-degrees-linkname").val();
		$(this).next().next().next("div").load(linkname + " #browseResults", function(){
			$("#browseResults a").removeAttr("onmouseover").removeAttr("onmouseout").removeAttr("onclick").removeAttr("target").removeAttr("name");
			$(".degreeMatch").next("a").wrap('<div class="degreeMatchShowMoreHolder" />').addClass("degreeMatchShowMore");
			
			$.each($('.schoolLogo'), function(i, val){
				var partnerCode = $(this).attr("href").replace("/","").replace(".htm?","");
				var logo = $(this);
				$.ajax({ url: siteDir + "files/popups/FeaturedSchoolsInfo.aspx?partner=" + partnerCode, success: function(data){
					var title = $(data).find("#jtip_excerpt").text();
					logo.attr('title',title);
			    }});
				
				$(this).addClass("south");
			});
			
			
			//Add Tracking
			var trackingString = "";

			$("#degree-finder").find(".tracking-param").each(function () {
				if (trackingString.length > 1) trackingString += '&';
				else trackingString = '?';
				trackingString += (this.name + "=" + this.value);
			});
			
			$("#browseResults a").each(function (index) {
				var currentexpresslink = $(this).attr("href").replace("http://beta.elearners.com","").replace("http://www.elearners.com",""); 
				//Need to add tsource to this
				$(this).attr("href", expresslink + currentexpresslink + trackingString.replace("?","&"));
			});
			
			
			//Show Hide Buttons and Loader
			$(this).prev("img").hide();
			$(this).prev().prev().prev("a").hide();
			$(this).prev().prev("a").show();
			$(this).hide();
			$(this).fadeIn(1000);
			
			//Initializes Tipsy
			$(function() {
				$('.south').tipsy({gravity: 's'});
			});
			
		});
		
		event.preventDefault(event);
	});
	
	//Hides Degrees
	$(".hide-matching-degrees").click(function() {
		$(this).next().next("div").fadeOut(600);
		$(this).hide();
		$(this).prev("a").show();
		return false;
	});
	
	//Loads add this script file after there has been a hover event
	$("#add-this-button").hover(function() {
		$(this).after("<script type=\"text/javascript\" src=\"http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a21ea466bcecd6a\"></script>");
	});
	
	//State By State Selection and Jump Menu
	$(".state-by-state-button-holder").click(function(event){
		var $stateSelected = $(this).parents("table").find(".state-by-state-select-holder select").val();
		location.href = $stateSelected;
		event.preventDefault();
	});
	
	//FAQ Content Accordion
	$(".faq-content:first").slideDown(500).parents("li").addClass("active");
	$(".faq-title").click(function(){
		if(!$(this).next().is(':visible')) {
			$(this).parents(".faq-holder").find(".faq-content:visible").slideUp(500).parents("li").removeClass("active");
			$(this).next().slideDown(500).parents("li").addClass("active");
		}
	});

});


//FCP Flash Charts

function fcpChart(chartTitle,chartSubHeader,chartSide,chartFooter,chartDivID,fileNazcscxme) {
	var siteDir = $("#site-root").val() + "/";
	var chartData = $(chartDivID).html();
	$(chartDivID).flash({
	swf: siteDir + 'files/graphs/swf/' + fileName + '.swf',
	flashvars:{
		xml_file: siteDir + 'files/graphs/xml/' + fileName + '.asp?chartData=' + chartData + '&chartTitle=' + chartTitle  + '&chartSubHeader=' + chartSubHeader  + '&chartSide=' + chartSide + '&chartFooter=' + chartFooter
    },
		params: {wmode: 'transparent'},
		width: 600, 
		height: 400
	});
}

//Carousel Configuration
function mycarousel_initCallback(carousel){
	$("#carousel_hide a").bind('click', function(event) {
		$.cookie('showTop', 'collapsed', {path: '/'});
		event.preventDefault();
		carousel.lock();
		$("#carousel_container").slideUp(500);
		$("#alt-carousel").fadeIn(1000);
		$("#carousel_cap").hide();

	});	
	$("#alt-carousel-show a").unbind();
	$("#alt-carousel-show a").bind('click', function (event) {
		event.preventDefault();
		$("#alt-carousel").fadeOut();
		$("#carousel_container").slideDown(500);
		$("#carousel_cap").fadeIn(1000);
		carousel.unlock();
		$.cookie('showTop', 'expanded', {path: '/'});
	});
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
};

function initCarousel(speed) {
	if ($.cookie('showTop') == "collapsed") {
		$("#carousel_container").hide();
		$("#alt-carousel").show();
		$("#carousel_cap").hide();
		
		$("#alt-carousel-show a").click(function(event) {
			event.preventDefault();
			$("#alt-carousel").fadeOut();
			$("#carousel_container").slideDown(500);
			$("#carousel_cap").fadeIn(1000);
			$('#mycarousel').jcarousel({
				auto: speed,
				wrap: 'last',
				initCallback: mycarousel_initCallback
			});
			$.cookie('showTop','expanded', {path: '/'});	
		});
	} 
	else {		
		$.cookie('showTop','expanded', {path: '/'});
		$('#mycarousel').jcarousel({
			auto: speed,
			wrap: 'last',
			initCallback: mycarousel_initCallback
		});
	}
}

//Jquery Cookie
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

//JTip
$(document).ready(JT_init);
function JT_init(){
   $("a.jTip")
   .hover(function(){JT_show(this.href,this.id,this.name)},function(){$('#JT').remove()})
   .click(function(){return false});	   
}
function JT_show(url,linkId,title){
	if(title == false)title="&nbsp;";
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var clickElementy = getAbsoluteTop(linkId) - 3; //set y position
	
	var queryString = url.replace(/^[^\?]+\??/,'');
	var params = parseQuery( queryString );
	if(params['width'] === undefined){params['width'] = 250};
	if(params['link'] !== undefined){
	$('#' + linkId).bind('click',function(){window.location = params['link']});
	$('#' + linkId).css('cursor','pointer');
	}
	
	if(hasArea>((params['width']*1)+75)){
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_left'></div><div id='JT_close_left'><span class='jtip_title'>"+title+"</span></div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//right side
		var arrowOffset = getElementWidth(linkId) + 11;
		var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
	}
	else{
		$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_right' style='left:"+((params['width']*1)+1)+"px'></div><div id='JT_close_right'><span class='jtip_title'>"+title+"</span></div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//left side
		var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position
	}
	
	$('#JT').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#JT').show();
	$('#JT_copy').load(url);
}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}

function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function blockEvents(evt) {
  if(evt.target){
	evt.preventDefault();
  }
  else{
	evt.returnValue = false;
  }
}
//End of JTip

//Tipsy: Twitter Styled Tip Layer
(function($) {
    $.fn.tipsy = function(options) {

        options = $.extend({}, $.fn.tipsy.defaults, options);
        
        return this.each(function() {
            
            var opts = $.fn.tipsy.elementOptions(this, options);
            
            $(this).hover(function() {

                $.data(this, 'cancel.tipsy', true);

                var tip = $.data(this, 'active.tipsy');
                if (!tip) {
                    tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>');
                    tip.css({position: 'absolute', zIndex: 100000});
                    $.data(this, 'active.tipsy', tip);
                }

                if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
                    $(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
                }

                var title;
                if (typeof opts.title == 'string') {
                    title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
                } else if (typeof opts.title == 'function') {
                    title = opts.title.call(this);
                }

                tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);

                var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
                tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity
                tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
                var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
                var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;

                switch (gravity.charAt(0)) {
                    case 'n':
                        tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
                        break;
                    case 's':
                        tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
                        break;
                    case 'e':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
                        break;
                    case 'w':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
                        break;
                }

                if (opts.fade) {
                    tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8});
                } else {
                    tip.css({visibility: 'visible'});
                }

            }, function() {
                $.data(this, 'cancel.tipsy', false);
                var self = this;
                setTimeout(function() {
                    if ($.data(this, 'cancel.tipsy')) return;
                    var tip = $.data(self, 'active.tipsy');
                    if (opts.fade) {
                        tip.stop().fadeOut(function() { $(this).remove(); });
                    } else {
                        tip.remove();
                    }
                }, 100);

            });
            
        });
        
    };
    
    // Overwrite this method to provide options on a per-element basis.
    // For example, you could store the gravity in a 'tipsy-gravity' attribute:
    // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
    // (remember - do not modify 'options' in place!)
    $.fn.tipsy.elementOptions = function(ele, options) {
        return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
    };
    
    $.fn.tipsy.defaults = {
        fade: false,
        fallback: '',
        gravity: 'n',
        html: false,
        title: 'title'
    };
    
    $.fn.tipsy.autoNS = function() {
        return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
    };
    
    $.fn.tipsy.autoWE = function() {
        return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
    };
    
})(jQuery);

//Tipsy Definitions
$(function() {
	$('.north').tipsy({gravity: 'n'});
	$('.south').tipsy({gravity: 's'});
	$('.east').tipsy({gravity: 'e'});
	$('.west').tipsy({gravity: 'w'});
});

//jCarousel
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(9($){$.1s.A=9(o){z 4.14(9(){2H r(4,o)})};8 q={W:F,23:1,1G:1,u:7,15:3,16:7,1H:\'2I\',24:\'2J\',1i:0,B:7,1j:7,1I:7,25:7,26:7,27:7,28:7,29:7,2a:7,2b:7,1J:\'<N></N>\',1K:\'<N></N>\',2c:\'2d\',2e:\'2d\',1L:7,1M:7};$.A=9(e,o){4.5=$.17({},q,o||{});4.Q=F;4.D=7;4.H=7;4.t=7;4.R=7;4.S=7;4.O=!4.5.W?\'1N\':\'2f\';4.E=!4.5.W?\'2g\':\'2h\';8 a=\'\',1d=e.J.1d(\' \');1k(8 i=0;i<1d.K;i++){6(1d[i].2i(\'A-2j\')!=-1){$(e).1t(1d[i]);8 a=1d[i];1l}}6(e.2k==\'2K\'||e.2k==\'2L\'){4.t=$(e);4.D=4.t.18();6(4.D.1m(\'A-H\')){6(!4.D.18().1m(\'A-D\'))4.D=4.D.B(\'<N></N>\');4.D=4.D.18()}X 6(!4.D.1m(\'A-D\'))4.D=4.t.B(\'<N></N>\').18()}X{4.D=$(e);4.t=$(e).2M(\'>2l,>2m,N>2l,N>2m\')}6(a!=\'\'&&4.D.18()[0].J.2i(\'A-2j\')==-1)4.D.B(\'<N 2N=" \'+a+\'"></N>\');4.H=4.t.18();6(!4.H.K||!4.H.1m(\'A-H\'))4.H=4.t.B(\'<N></N>\').18();4.S=$(\'.A-11\',4.D);6(4.S.u()==0&&4.5.1K!=7)4.S=4.H.1u(4.5.1K).11();4.S.V(4.J(\'A-11\'));4.R=$(\'.A-19\',4.D);6(4.R.u()==0&&4.5.1J!=7)4.R=4.H.1u(4.5.1J).11();4.R.V(4.J(\'A-19\'));4.H.V(4.J(\'A-H\'));4.t.V(4.J(\'A-t\'));4.D.V(4.J(\'A-D\'));8 b=4.5.16!=7?1n.1O(4.1o()/4.5.16):7;8 c=4.t.2O(\'1v\');8 d=4;6(c.u()>0){8 f=0,i=4.5.1G;c.14(9(){d.1P(4,i++);f+=d.T(4,b)});4.t.y(4.O,f+\'U\');6(!o||o.u===L)4.5.u=c.u()}4.D.y(\'1w\',\'1x\');4.R.y(\'1w\',\'1x\');4.S.y(\'1w\',\'1x\');4.2n=9(){d.19()};4.2o=9(){d.11()};4.1Q=9(){d.2p()};6(4.5.1j!=7)4.5.1j(4,\'2q\');6($.2r.2s){4.1e(F,F);$(2t).1y(\'2P\',9(){d.1z()})}X 4.1z()};8 r=$.A;r.1s=r.2Q={A:\'0.2.3\'};r.1s.17=r.17=$.17;r.1s.17({1z:9(){4.C=7;4.G=7;4.Y=7;4.12=7;4.1a=F;4.1f=7;4.P=7;4.Z=F;6(4.Q)z;4.t.y(4.E,4.1A(4.5.1G)+\'U\');8 p=4.1A(4.5.23);4.Y=4.12=7;4.1p(p,F);$(2t).1R(\'2u\',4.1Q).1y(\'2u\',4.1Q)},2v:9(){4.t.2w();4.t.y(4.E,\'2R\');4.t.y(4.O,\'2S\');6(4.5.1j!=7)4.5.1j(4,\'2v\');4.1z()},2p:9(){6(4.P!=7&&4.Z)4.t.y(4.E,r.I(4.t.y(4.E))+4.P);4.P=7;4.Z=F;6(4.5.1I!=7)4.5.1I(4);6(4.5.16!=7){8 a=4;8 b=1n.1O(4.1o()/4.5.16),O=0,E=0;$(\'1v\',4.t).14(9(i){O+=a.T(4,b);6(i+1<a.C)E=O});4.t.y(4.O,O+\'U\');4.t.y(4.E,-E+\'U\')}4.15(4.C,F)},2T:9(){4.Q=1g;4.1e()},2U:9(){4.Q=F;4.1e()},u:9(s){6(s!=L){4.5.u=s;6(!4.Q)4.1e()}z 4.5.u},2V:9(i,a){6(a==L||!a)a=i;6(4.5.u!==7&&a>4.5.u)a=4.5.u;1k(8 j=i;j<=a;j++){8 e=4.M(j);6(!e.K||e.1m(\'A-1b-1B\'))z F}z 1g},M:9(i){z $(\'.A-1b-\'+i,4.t)},2x:9(i,s){8 e=4.M(i),1S=0,2x=0;6(e.K==0){8 c,e=4.1C(i),j=r.I(i);1q(c=4.M(--j)){6(j<=0||c.K){j<=0?4.t.2y(e):c.1T(e);1l}}}X 1S=4.T(e);e.1t(4.J(\'A-1b-1B\'));1U s==\'2W\'?e.2X(s):e.2w().2Y(s);8 a=4.5.16!=7?1n.1O(4.1o()/4.5.16):7;8 b=4.T(e,a)-1S;6(i>0&&i<4.C)4.t.y(4.E,r.I(4.t.y(4.E))-b+\'U\');4.t.y(4.O,r.I(4.t.y(4.O))+b+\'U\');z e},1V:9(i){8 e=4.M(i);6(!e.K||(i>=4.C&&i<=4.G))z;8 d=4.T(e);6(i<4.C)4.t.y(4.E,r.I(4.t.y(4.E))+d+\'U\');e.1V();4.t.y(4.O,r.I(4.t.y(4.O))-d+\'U\')},19:9(){4.1D();6(4.P!=7&&!4.Z)4.1W(F);X 4.15(((4.5.B==\'1X\'||4.5.B==\'G\')&&4.5.u!=7&&4.G==4.5.u)?1:4.C+4.5.15)},11:9(){4.1D();6(4.P!=7&&4.Z)4.1W(1g);X 4.15(((4.5.B==\'1X\'||4.5.B==\'C\')&&4.5.u!=7&&4.C==1)?4.5.u:4.C-4.5.15)},1W:9(b){6(4.Q||4.1a||!4.P)z;8 a=r.I(4.t.y(4.E));!b?a-=4.P:a+=4.P;4.Z=!b;4.Y=4.C;4.12=4.G;4.1p(a)},15:9(i,a){6(4.Q||4.1a)z;4.1p(4.1A(i),a)},1A:9(i){6(4.Q||4.1a)z;i=r.I(i);6(4.5.B!=\'1c\')i=i<1?1:(4.5.u&&i>4.5.u?4.5.u:i);8 a=4.C>i;8 b=r.I(4.t.y(4.E));8 f=4.5.B!=\'1c\'&&4.C<=1?1:4.C;8 c=a?4.M(f):4.M(4.G);8 j=a?f:f-1;8 e=7,l=0,p=F,d=0;1q(a?--j>=i:++j<i){e=4.M(j);p=!e.K;6(e.K==0){e=4.1C(j).V(4.J(\'A-1b-1B\'));c[a?\'1u\':\'1T\'](e)}c=e;d=4.T(e);6(p)l+=d;6(4.C!=7&&(4.5.B==\'1c\'||(j>=1&&(4.5.u==7||j<=4.5.u))))b=a?b+d:b-d}8 g=4.1o();8 h=[];8 k=0,j=i,v=0;8 c=4.M(i-1);1q(++k){e=4.M(j);p=!e.K;6(e.K==0){e=4.1C(j).V(4.J(\'A-1b-1B\'));c.K==0?4.t.2y(e):c[a?\'1u\':\'1T\'](e)}c=e;8 d=4.T(e);6(d==0){2Z(\'30: 31 1N/2f 32 1k 33. 34 35 36 37 38 39. 3a...\');z 0}6(4.5.B!=\'1c\'&&4.5.u!==7&&j>4.5.u)h.3b(e);X 6(p)l+=d;v+=d;6(v>=g)1l;j++}1k(8 x=0;x<h.K;x++)h[x].1V();6(l>0){4.t.y(4.O,4.T(4.t)+l+\'U\');6(a){b-=l;4.t.y(4.E,r.I(4.t.y(4.E))-l+\'U\')}}8 n=i+k-1;6(4.5.B!=\'1c\'&&4.5.u&&n>4.5.u)n=4.5.u;6(j>n){k=0,j=n,v=0;1q(++k){8 e=4.M(j--);6(!e.K)1l;v+=4.T(e);6(v>=g)1l}}8 o=n-k+1;6(4.5.B!=\'1c\'&&o<1)o=1;6(4.Z&&a){b+=4.P;4.Z=F}4.P=7;6(4.5.B!=\'1c\'&&n==4.5.u&&(n-k+1)>=1){8 m=r.10(4.M(n),!4.5.W?\'1r\':\'1Y\');6((v-m)>g)4.P=v-g-m}1q(i-->o)b+=4.T(4.M(i));4.Y=4.C;4.12=4.G;4.C=o;4.G=n;z b},1p:9(p,a){6(4.Q||4.1a)z;4.1a=1g;8 b=4;8 c=9(){b.1a=F;6(p==0)b.t.y(b.E,0);6(b.5.B==\'1X\'||b.5.B==\'G\'||b.5.u==7||b.G<b.5.u)b.2z();b.1e();b.1Z(\'2A\')};4.1Z(\'3c\');6(!4.5.1H||a==F){4.t.y(4.E,p+\'U\');c()}X{8 o=!4.5.W?{\'2g\':p}:{\'2h\':p};4.t.1p(o,4.5.1H,4.5.24,c)}},2z:9(s){6(s!=L)4.5.1i=s;6(4.5.1i==0)z 4.1D();6(4.1f!=7)z;8 a=4;4.1f=3d(9(){a.19()},4.5.1i*3e)},1D:9(){6(4.1f==7)z;3f(4.1f);4.1f=7},1e:9(n,p){6(n==L||n==7){8 n=!4.Q&&4.5.u!==0&&((4.5.B&&4.5.B!=\'C\')||4.5.u==7||4.G<4.5.u);6(!4.Q&&(!4.5.B||4.5.B==\'C\')&&4.5.u!=7&&4.G>=4.5.u)n=4.P!=7&&!4.Z}6(p==L||p==7){8 p=!4.Q&&4.5.u!==0&&((4.5.B&&4.5.B!=\'G\')||4.C>1);6(!4.Q&&(!4.5.B||4.5.B==\'G\')&&4.5.u!=7&&4.C==1)p=4.P!=7&&4.Z}8 a=4;4.R[n?\'1y\':\'1R\'](4.5.2c,4.2n)[n?\'1t\':\'V\'](4.J(\'A-19-1E\')).20(\'1E\',n?F:1g);4.S[p?\'1y\':\'1R\'](4.5.2e,4.2o)[p?\'1t\':\'V\'](4.J(\'A-11-1E\')).20(\'1E\',p?F:1g);6(4.R.K>0&&(4.R[0].1h==L||4.R[0].1h!=n)&&4.5.1L!=7){4.R.14(9(){a.5.1L(a,4,n)});4.R[0].1h=n}6(4.S.K>0&&(4.S[0].1h==L||4.S[0].1h!=p)&&4.5.1M!=7){4.S.14(9(){a.5.1M(a,4,p)});4.S[0].1h=p}},1Z:9(a){8 b=4.Y==7?\'2q\':(4.Y<4.C?\'19\':\'11\');4.13(\'25\',a,b);6(4.Y!==4.C){4.13(\'26\',a,b,4.C);4.13(\'27\',a,b,4.Y)}6(4.12!==4.G){4.13(\'28\',a,b,4.G);4.13(\'29\',a,b,4.12)}4.13(\'2a\',a,b,4.C,4.G,4.Y,4.12);4.13(\'2b\',a,b,4.Y,4.12,4.C,4.G)},13:9(a,b,c,d,e,f,g){6(4.5[a]==L||(1U 4.5[a]!=\'2B\'&&b!=\'2A\'))z;8 h=1U 4.5[a]==\'2B\'?4.5[a][b]:4.5[a];6(!$.3g(h))z;8 j=4;6(d===L)h(j,c,b);X 6(e===L)4.M(d).14(9(){h(j,4,d,c,b)});X{1k(8 i=d;i<=e;i++)6(i!==7&&!(i>=f&&i<=g))4.M(i).14(9(){h(j,4,i,c,b)})}},1C:9(i){z 4.1P(\'<1v></1v>\',i)},1P:9(e,i){8 a=$(e).V(4.J(\'A-1b\')).V(4.J(\'A-1b-\'+i));a.20(\'3h\',i);z a},J:9(c){z c+\' \'+c+(!4.5.W?\'-3i\':\'-W\')},T:9(e,d){8 a=e.2C!=L?e[0]:e;8 b=!4.5.W?a.1F+r.10(a,\'2D\')+r.10(a,\'1r\'):a.2E+r.10(a,\'2F\')+r.10(a,\'1Y\');6(d==L||b==d)z b;8 w=!4.5.W?d-r.10(a,\'2D\')-r.10(a,\'1r\'):d-r.10(a,\'2F\')-r.10(a,\'1Y\');$(a).y(4.O,w+\'U\');z 4.T(a)},1o:9(){z!4.5.W?4.H[0].1F-r.I(4.H.y(\'3j\'))-r.I(4.H.y(\'3k\')):4.H[0].2E-r.I(4.H.y(\'3l\'))-r.I(4.H.y(\'3m\'))},3n:9(i,s){6(s==L)s=4.5.u;z 1n.3o((((i-1)/s)-1n.3p((i-1)/s))*s)+1}});r.17({3q:9(d){z $.17(q,d||{})},10:9(e,p){6(!e)z 0;8 a=e.2C!=L?e[0]:e;6(p==\'1r\'&&$.2r.2s){8 b={\'1w\':\'1x\',\'3r\':\'3s\',\'1N\':\'1i\'},21,22;$.2G(a,b,9(){21=a.1F});b[\'1r\']=0;$.2G(a,b,9(){22=a.1F});z 22-21}z r.I($.y(a,p))},I:9(v){v=3t(v);z 3u(v)?0:v}})})(3v);',62,218,'||||this|options|if|null|var|function||||||||||||||||||||list|size||||css|return|jcarousel|wrap|first|container|lt|false|last|clip|intval|className|length|undefined|get|div|wh|tail|locked|buttonNext|buttonPrev|dimension|px|addClass|vertical|else|prevFirst|inTail|margin|prev|prevLast|callback|each|scroll|visible|extend|parent|next|animating|item|circular|split|buttons|timer|true|jcarouselstate|auto|initCallback|for|break|hasClass|Math|clipping|animate|while|marginRight|fn|removeClass|before|li|display|block|bind|setup|pos|placeholder|create|stopAuto|disabled|offsetWidth|offset|animation|reloadCallback|buttonNextHTML|buttonPrevHTML|buttonNextCallback|buttonPrevCallback|width|ceil|format|funcResize|unbind|old|after|typeof|remove|scrollTail|both|marginBottom|notify|attr|oWidth|oWidth2|start|easing|itemLoadCallback|itemFirstInCallback|itemFirstOutCallback|itemLastInCallback|itemLastOutCallback|itemVisibleInCallback|itemVisibleOutCallback|buttonNextEvent|click|buttonPrevEvent|height|left|top|indexOf|skin|nodeName|ul|ol|funcNext|funcPrev|reload|init|browser|safari|window|resize|reset|empty|add|prepend|startAuto|onAfterAnimation|object|jquery|marginLeft|offsetHeight|marginTop|swap|new|normal|swing|UL|OL|find|class|children|load|prototype|0px|10px|lock|unlock|has|string|html|append|alert|jCarousel|No|set|items|This|will|cause|an|infinite|loop|Aborting|push|onBeforeAnimation|setTimeout|1000|clearTimeout|isFunction|jcarouselindex|horizontal|borderLeftWidth|borderRightWidth|borderTopWidth|borderBottomWidth|index|round|floor|defaults|float|none|parseInt|isNaN|jQuery'.split('|'),0,{}));

//swf Object
(function(E,B){var C=function(G){var F,H=[];for(F in G){H.push(F+'="'+G[F]+'"')}return H.join("")},D=function(H){var F,J,I=[],G;for(F in H){if(typeof H[F]=="object"){G=[];for(J in H[F]){G.push([J,"=",encodeURIComponent(H[F][J])].join(""))}H[F]=G.join("&amp;")}I.push(['<param name="',F,'" value="',H[F],'" />'].join(""))}return I.join("")},A=false;E[B]=(function(){var F="0,0,0",G=navigator.plugins["Shockwave Flash"]||ActiveXObject;F=G.description||(function(){try{return(new G("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}catch(H){}}());F=F.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+r|,)(\d+)/);return{available:F[1]>0,activeX:!G.name,version:{major:F[1]*1,minor:F[2]*1,release:F[3]*1},hasVersion:function(I){var L=this.version,J="major",K="minor",H="release";I=(/string|number/.test(typeof I))?I.toString().split("."):I||[0,0,0];I=[I[J]||I[0]||L[J],I[K]||I[1]||L[K],I[H]||I[2]||L[H]];return(I[0]<L[J])||(I[0]==L[J]&&I[1]<L[K])||(I[0]==L[J]&&I[1]==L[K]&&I[2]<=L[H])},expressInstall:"expressInstall.swf",create:function(H){if(!E[B].available||A||!typeof H=="object"||!H.swf){return false}if(H.hasVersion&&!E[B].hasVersion(H.hasVersion)){H={swf:H.expressInstall||E[B].expressInstall,attrs:{id:"SWFObjectExprInst",height:Math.max(H.height||137),width:Math.max(H.width||214)},params:{flashvars:{MMredirectURL:location.href,MMplayerType:(E[B].activeX)?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}};A=true}else{H=E.extend(true,{attrs:{height:H.height||180,width:H.width||320},params:{wmode:H.wmode||"opaque",flashvars:H.flashvars}},H)}return"<object "+(C(H.attrs))+(E[B].activeX?' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="'+H.swf+'" />':' type="application/x-shockwave-flash" data="'+H.swf+'">')+(D(H.params))+"</object>"}}}());E.fn[B]=function(F){if(typeof F=="object"){this.each(function(){var G=document.createElement(B);G.innerHTML=E[B].create(F);if(G.childNodes[0]){this.appendChild(G.childNodes[0])}})}else{if(typeof F=="function"){this.find("object").andSelf().filter("object").each(function(){var H=this,G="jsInteractionTimeoutMs";H[G]=H[G]||0;if(H[G]<660){if(H.clientWidth||H.clientHeight){F.call(this)}else{setTimeout(function(){E(H)[B](F)},H[G]+66)}}})}}return this}}(jQuery,"flash"));


/*

//QDF Web Service
function Querystring(qs) { 
	this.params = new Object();
	this.get=Querystring_get;
	if (qs == null)	qs=location.search.substring(1,location.search.length);
	qs=qs.toLowerCase();
	if (qs.length == 0) return;
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=');
		var name = unescape(pair[0]);
		if (pair.length == 2)
		{
			value = unescape(pair[1]);
		}
		else
		{
			value = name;
		}	
		this.params[name] = value;
	}
}
function Querystring_get(key, default_) {
	if (default_ == null) default_ = null;
	var value=this.params[key];
	if (value==null) value=default_;
	return value;
}

var qs = new Querystring();
var DefEduLvl;
var DefCategory;
var DefSubject;
var ExecuteNextStep=false;
SetQSValues();

function SetQSValues(){
    DefEduLvl=qs.get("edulvl","-1");
    DefCategory=qs.get("category","-1");   
    DefSubject=qs.get("subject","-1");        
}

function IsAsyncEduLvlCall(){
    return true;
//    return DefEduLvl=="-1";
}

function IsAsyncCategoryCall(){
    return true;
//    return DefCategory=="-1";
}

//var xmlhttp=null;
var xml;
var doc;
var str;

function SetXMLHttp(){
    var xmlhttp=null;
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.ActiveXObject) {
	    try {
		    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    return xmlhttp;
}

function PopulateDegreeLevel(result){

    ExecuteNextStep=false;
    xml = result;
    var nodes = xml.split("<EduLevel>");
    var i=0;
    var index=1;

    for(i=0;i<nodes.length;i++)
    {
        if(nodes[i].indexOf("<Value>") > -1)
        {
            var nodeval = nodes[i].substr(nodes[i].indexOf("<Value>")+7, 1);
            var nodetext = nodes[i].substr(nodes[i].indexOf("<DisplayName>")+13, nodes[i].indexOf("</DisplayName>")-13);
            document.myform.eduLvl[index] = new Option(nodetext, nodeval);
            if (nodeval==DefEduLvl)
            { 
                document.myform.eduLvl.selectedIndex = index;                
                ExecuteNextStep=true;
            }
            index++;
        }
    }
    if (ExecuteNextStep) DegreeChanged();

}

function PopulateCategory(result){

    ExecuteNextStep=false;
    xml = result;
    var nodes = xml.split("<Category>");
    var i=0;
    var index=1;
    for(i=0;i<nodes.length;i++)
    {
        if(nodes[i].indexOf("<Value>") > -1)
        {
            var nodeval = nodes[i].substr(nodes[i].indexOf("<Value>")+7, nodes[i].indexOf("</Value>")-nodes[i].indexOf("<Value>")-7);
            var nodetext = nodes[i].substr(nodes[i].indexOf("<DisplayName>")+13, nodes[i].indexOf("</DisplayName>")-13);
           	
            if(nodetext.indexOf("&amp;") > -1) 
            {
                nodetext = nodetext.substr(0, nodetext.indexOf("&amp;")) + "&" + nodetext.substr(nodetext.indexOf("&amp;")+5)
            }
            document.myform.optone[index] = new Option(nodetext, nodeval);
            if (nodeval.toUpperCase()==DefCategory.toUpperCase())
            { 
                document.myform.optone.selectedIndex = index;
                ExecuteNextStep=true;
            }
            index++;
        }
    }
    if (ExecuteNextStep) CategoryChanged();

}

function PopulateSubjects(result){

    xml = result;
    var nodes = xml.split("<Subject>");
    var i=0;
    var index=1;

    for(i=0;i<nodes.length;i++)
    {
        if(nodes[i].indexOf("<Value>") > -1)
        {
            var nodeval = nodes[i].substr(nodes[i].indexOf("<Value>")+7, nodes[i].indexOf("</Value>")-nodes[i].indexOf("<Value>")-7);	
            var nodetext = nodes[i].substr(nodes[i].indexOf("<DisplayName>")+13, nodes[i].indexOf("</DisplayName>")-13);
            document.myform.industry[index] = new Option(nodetext, nodeval);
            if (nodeval.toUpperCase()==DefSubject.toUpperCase())
            { 
                document.myform.industry.selectedIndex = index;                
            }                
            index++;
        }
    }

}
*/

/*
function LoadDegrees(){
    var dtmNow = new Date();
    var strMS = dtmNow.valueOf();
    
    SetQSValues();
    xmlhttp=SetXMLHttp();
    xmlhttp.open("POST", "/WebServices/external/ELearnersWebService.asmx?time=" + strMS,IsAsyncEduLvlCall());
    xmlhttp.setRequestHeader("SOAPAction", "http://elearners.com/GetEDULevel_ByCampaign");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) 
        {
            PopulateDegreeLevel(xmlhttp.responseText);
        }
    }

    str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
		    "<soap12:Envelope " +
		    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
		    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
		    "xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
		    "<soap12:Body>" +
		    "<GetEDULevel_ByCampaign xmlns=\"http://elearners.com/\">" +
		    "<RPCamp_GUID>" + document.myform.cid.value + "</RPCamp_GUID>" +
		    "</GetEDULevel_ByCampaign>" +
		    "</soap12:Body>" +
		    "</soap12:Envelope>";
     xmlhttp.send(str);
}*/

/*
function DegreeChanged() {
    SetQSValues();
    xmlhttp=SetXMLHttp();
    document.myform.optone.disabled=false;
    document.myform.industry.disabled=true;
    document.myform.industry.selectedIndex=0;
    var x;
    for(x=document.myform.optone.length-1;x>0;x--)
    {
	    document.myform.optone[x] = null;
    }
    xmlhttp.open("POST", "/WebServices/external/ELearnersWebService.asmx",IsAsyncCategoryCall());
    xmlhttp.setRequestHeader("SOAPAction", "http://elearners.com/GetCategories_SSOProfile");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) 
        {
            PopulateCategory(xmlhttp.responseText);
        }
    }
    str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
		    "<soap12:Envelope " +
		    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
		    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
		    "xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
		    "<soap12:Body>" +
		    "<GetCategories_SSOProfile xmlns=\"http://elearners.com/\">" +
		    "<Degree>" + document.myform.eduLvl[document.myform.eduLvl.selectedIndex].value + "</Degree>" +
		    "<RPCamp_GUID>" + document.myform.cid.value + "</RPCamp_GUID>" +
		    "</GetCategories_SSOProfile>" +
		    "</soap12:Body>" +
		    "</soap12:Envelope>";
    xmlhttp.send(str);
}

function CategoryChanged() {
    SetQSValues();
    xmlhttp=SetXMLHttp();
    document.myform.industry.disabled=false;
    document.myform.industry.selectedIndex=0;
    var x;
    for(x=document.myform.industry.length-1;x>0;x--)
    {
	    document.myform.industry[x] = null;
    }
    xmlhttp.open("POST", "/WebServices/external/ELearnersWebService.asmx",IsAsyncCategoryCall());
    xmlhttp.setRequestHeader("SOAPAction", "http://elearners.com/GetSubjects_SSOProfile");
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) 
        {
            PopulateSubjects(xmlhttp.responseText);
        }
    }
    str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
		    "<soap12:Envelope " +
		    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
		    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
		    "xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
		    "<soap12:Body>" +
		    "<GetSubjects_SSOProfile xmlns=\"http://elearners.com/\">" +
		    "<Degree>" + document.myform.eduLvl[document.myform.eduLvl.selectedIndex].value + "</Degree>" +
		    "<Category>"  + document.myform.optone[document.myform.optone.selectedIndex].value + "</Category>" + 
		    "<RPCamp_GUID>" + document.myform.cid.value + "</RPCamp_GUID>" +
		    "</GetSubjects_SSOProfile>" +
		    "</soap12:Body>" +
		    "</soap12:Envelope>";
    xmlhttp.send(str);
}
*/
