// START LOGO LINK CHANGE FUNCTION 
 $(document).ready(function(){
	$('div#hdr').replaceWith('<div id="hdr"><div id="hdr-btns"><a href="/nuservices/request_information.aspx"><img src="cmsimages/btn-rqi.jpg" alt="Request Info" title="Request Info" id="rqi" style="top: 0px; "></a><a href="/admissionsapplication.html"><img src="cmsimages/btn-apn.jpg" alt="Apply Now" title="Apply Now" id="apn" style="top: 0px; "></a><a href="/nuservices/quick-question.aspx"><img src="cmsimages/btn-qq.jpg" alt="Quick Question" title="Quick Question" id="qq" style="top: 0px; "></a><div id="sb" style="top: 0px; "><form action="/search-results.html" method="get"><input type="hidden" name="cx" value="002415629415276528023:twdawfwltzs"><input type="hidden" name="client" value="google-csbe"><input type="hidden" name="output" value="xml_no_dtd">Search<br><input type="text" name="q" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; "><button type="submit">Go</button></form></div></div><a href="http://www.neumont.edu/nuservices/request_information.aspx"><img src="http://www.neumont.edu/cmsimages/neumont-logo-home.jpg" alt="Neumont University. Encoding the Next_" name="logo" id="logo" title="Neumont University. Encoding the Next_"></a></div>');
  });
// END LOGO LINK CHANGE FUNCTION 

$(function(){
	$("input[type='text'],input[type='password'],textarea").css({"border":"1px solid #cccccc","padding":"2px"});
	$("input[type='text'],input[type='password'],textarea").focus(function(){
		$(this).css({"border":"1px solid #a3a3a3"}); 
	});
	$("input[type='text'],input[type='password'],textarea").blur(function(){
		$(this).css({"border":"1px solid #cccccc"});
	});
	$("textarea").autogrow();
	$(".validateMe").validate();
	var year = new Date();
	$("#year").html(year.getFullYear());
	setTimeout("animate_btns()", 250);
	$.extend({ // to get URL Variables
	  getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++) {
		  hash = hashes[i].split('=');
		  vars.push(hash[0]);
		  vars[hash[0]] = hash[1];
		}
		return vars;
	  },
	  getUrlVar: function(name){
		return $.getUrlVars()[name];
	  }
	});
		$(".sb-content .btn-next2").click(function(){
		if ( $(this).hasClass("usable") ){
			var x = $(".cq");
			$(x).animate({
				left: '400'
			},400).removeClass("cq");
			$(x).next(".sd").addClass("cq");
			$(".btn-next2").css({"color":"gray","cursor":"default"}).removeClass("usable");
			if ( $(".cq").html() == null ){
				var dataString = $("#sf").serialize();
				window.location="paying-for-college-survey-result.html?"+dataString;
			} else {
				$(".cq").css("left","-400px");
				$(".cq").animate({
					left: '0'
				},400);
				var count = $(".cq ol").attr("start");
				$(".sc").html(count + "/5");
				$("ul.blocks li.active").removeClass("active");
				$(".b"+count).addClass("active");
			}
		}
	});
	$("#sf input").click(function(){
		checkA();
	});
	$(".rollover-list li").each(function(){
		if( $(this).index() == 6 ){
			$(this).addClass("show_offset");
		}
	});
	$(".gen_table tr:even td").css("background","#e3e3e3");
	
	if(render_javascript()) {
		$(".rdb div").hide();
		$(".rollover-list li:first").addClass("showing");
		$(".rdb div:first").show();
		$(".rollover-list li").hover(function(){
			$(".rollover-list li").removeClass("showing");
			$(this).addClass("showing");		
			var x = $(this).index();		
			$(".rdb > div").hide();
			$(".rdb > div").each(function(i){
				if(i==x) {
					$(this).show();
				}
			});		
		});
	}
	
	
	// Tier 2 background image swap
	if($("#side-bg").length) {
		if($("#pageimage img").length) {
			if(!($("#pageimage img")[0].src.toString().indexOf("blank.gif")>=0)) {
				$("#side-bg").css({background:"url("+$("#pageimage img")[0].src.toString()+") no-repeat top center"});			
			}
		}
	}
	
	// Financial Aid background image swap
	if($("#fa-bg").length) {
		if($("#pageimage img").length) {
			if(!($("#pageimage img")[0].src.toString().indexOf("blank.gif")>=0)) {
				$("#fa-bg").css({background:"url("+$("#pageimage img")[0].src.toString()+") no-repeat top center"});			
			}
		}
	}
	
	// Homepage view Next Project
	$(".pl-content:first").css("left","0px").addClass("current");
	$("#pl-next img").click(function(){
		$(".pl-content.current").stop().animate({
			left: '-305'
		},400,function(){
			$(".pl-content").css({"left":"305px"});
		});
		if ( $(".pl-content.current").next(".pl-content").html() == null ){
			$(".pl-content:first").stop().animate({
				left: '0'
			}).addClass("current");
			$(".pl-content.current:last").removeClass("current");
		} else {
			$(".pl-content.current").next(".pl-content").stop().animate({
				left: '0'
			}).addClass("current");
			$(".pl-content.current:first").removeClass("current");
		}
	});
    
    $(".rl-content:first").css("left","0px").addClass("current");
	$("#rl-next img").click(function(){
		$(".rl-content.current").stop().animate({
			left: '-305'
		},400,function(){
			$(".rl-content").css({"left":"305px"});
		});
		if ( $(".rl-content.current").next(".rl-content").html() == null ){
			$(".rl-content:first").stop().animate({
				left: '0'
			}).addClass("current");
			$(".rl-content.current:last").removeClass("current");
		} else {
			$(".rl-content.current").next(".rl-content").stop().animate({
				left: '0'
			}).addClass("current");
			$(".rl-content.current:first").removeClass("current");
		}
	});
	
	// Homepage view Previous Project
	$("#pl-prev img").click(function(){
		$(".pl-content.current").stop().animate({
			left: '325'
		},400,function(){
			$(".pl-content").css({"left":"305px"});
		});
		if ( $(".pl-content.current").prev(".pl-content").html() == null ){
			$(".pl-content:last").css("left","-305px").stop().animate({
				left: '0'
			}).addClass("current");
			$(".pl-content.current:first").removeClass("current");
		} else {
			$(".pl-content.current").prev(".pl-content").css("left","-305px").stop().animate({
				left: '0'
			}).addClass("current");
			$(".pl-content.current:last").removeClass("current");
		}
	});
    
    $("#rl-prev img").click(function(){
		$(".rl-content.current").stop().animate({
			left: '325'
		},400,function(){
			$(".rl-content").css({"left":"305px"});
		});
		if ( $(".rl-content.current").prev(".rl-content").html() == null ){
			$(".rl-content:last").css("left","-305px").stop().animate({
				left: '0'
			}).addClass("current");
			$(".rl-content.current:first").removeClass("current");
		} else {
			$(".rl-content.current").prev(".rl-content").css("left","-305px").stop().animate({
				left: '0'
			}).addClass("current");
			$(".rl-content.current:last").removeClass("current");
		}
	});
	
	$("#programs-bg #ln ul li a").mouseover(function(){
		$(this).find("span").show();
	}).mouseout(function(){
		$(this).find("span").hide();
	});
});

function checkProgram(x){
	if ( x == "bscs" ){
		$(".bscs").addClass("selected");
	} else if ( x == "bsgd"){
		$(".bsgd").addClass("selected");
	} else if ( x == "bstm"){
		$(".bstm").addClass("selected");
	} else if ( x == "bswd"){
		$(".bswd").addClass("selected");
	} else if ( x == "mscs"){
		$(".mscs").addClass("selected");
	} else if ( x == ""){
		$(".graylink").hide();
	}
}

function buildChart(){
	var allVars = $.getUrlVars();
	
	var q1 = $.getUrlVar("q1");
	var q2 = $.getUrlVar("q2");
	var q3 = $.getUrlVar("q3");
	var q4 = $.getUrlVar("q4");
	var q5 = $.getUrlVar("q5");
	
	var fg = 0; // Federal Grants
	var fl = 0; // Federal Loans
	var ns = 0; // Neumont Scholarships
	var other = 0; // Other
	var pl = 72000; // Private Loans
	var parentLoans = "Private Loans";
	
	if (q1 == 0){
		fl = fl + 2000;
		pl = pl - 2000;	
		parentLoans = "Private and Parent PLUS Loans";
	} else if ( q1 == 1 ){
		fl = fl + 6000;
		pl = pl - 6000;
	}
	$(".plname").html(parentLoans);
	
	if ( q2 == 0 ){
		/*ns = ns + 10000;
		pl = pl - 10000;*/
		ns = ns + 15000;
		pl = pl - 15000;
	} else if ( q2 == 1 ) {
		/*ns = ns + 5000;
		pl = pl - 5000;*/
		ns = ns + 10000;
		pl = pl - 10000;
	} else if ( q2 == 2 ){
		/*ns = ns + 3500;
		pl = pl - 3500;*/
		ns = ns + 5000;
		pl = pl - 5000;
	} else if ( q2 == 3 ){
		/*ns = ns + 2500;
		pl = pl - 2500;*/
		ns = ns + 3600;
		pl = pl - 3600;
	}
	
	if ( q4 == 0 ){
		/*fg = fg + 7300;
		fl = fl + 3500;
		pl = pl - 10800;*/
		fg = fg + 18150;
		pl = pl - 18150;
	} else if ( q4 == 1 && q3 != 0 ){
		/*fg = fg + 1800;
		fl = fl + 3500;
		pl = pl - 5300;*/
		fg = fg + 18150;
		pl = pl - 18150;
	} else if ( q4 == 2 && q3 == 3 ){
		/*fg = fg + 900;
		fl = fl + 3500;
		pl = pl - 4400;*/
		fg = fg + 18150;
		pl = pl - 18150;
	} else if ( q4 == 3 ){
		fg = fg + 0;
		fl = fl + 0;
		pl = pl - 0;
	}
	
	if ( q5 == 0 ){
		other = other;
	} else if ( q5 == 1 ){
		other = other + 5000;
		pl = pl - 5000;
	} else if ( q5 == 2 ){
		other = other + 10000;
		pl = pl - 10000;
	} else if ( q5 == 3 ){
		other = other + 15000;
		pl = pl - 15000;
	}
		
	$('#chart').insertFusionCharts({
		type: "Pie2D",
		data: "<graph showNames='0' showValues='0' pieBorderThickness='3' pieRadius='210' showhovercap='0' animation='0' showPercentageValues='1' baseFont='Trebuchet MS' baseFontSize='13' bgAlpha='0'>" +
		"<set name='"+parentLoans+"' value='"+pl+"' color='b6b5aa' />" +
		"<set name='Neumont or Private Scholarships' value='"+ns+"' color='ffcc00' />" +
		"<set name='Subsidized Federal Loans and Unsubsidized Federal Loans' value='"+fl+"' color='ea9919' />" +
		"<set name='Federal Grants' value='"+fg+"' color='bf2e1a' />" +
		"<set name='Savings, Other Funding Sources' value='"+other+"' color='056cb6' />" +
		"</graph>",
		dataFormat: "XMLData",
		width: "420",height: "440",
		wmode: "transparent"
	});
};

function checkA(){
	var count = $(".cq ol").attr("start");
	if ( $("input[name='q"+count+"']").val() >= 0 ){
		$(".btn-next2").css({"color":"white","cursor":"pointer"}).addClass("usable");
	} else {
		$(".btn-next2").css({"color":"gray","cursor":"default"}).removeClass("usable");
	}
}
function animate_btns(){
	$("#rqi").animate({
		top: '0'
	},400);
	$("#apn").animate({
		top: '0'
	},500);
	$("#qq").animate({
		top: '0'
	},600);
	$("#sb").animate({
		top: '0'
	},700);
}

// START GALLERY FUNCTIONS

var vgallery_property={};
vgallery_property.display_count=5;
vgallery_property.size=0;
vgallery_property.current=0;

function render_javascript() {
	var render_js=true;
	if(document.location.toString().indexOf("preview_page.php")>=0) {
		// previewing in check for markers=off before disabling the gallery render
		if(document.location.toString().indexOf("markers=off")==-1) {
			render_js=false;
		}
	}
	return render_js;
}

function vgallery_init() {	
	
	
	if(render_javascript()) {
		if($("#gt .content_3 img").length) {
			var html='<ul id="vgallery_container">';
			html+='<li class="arrow"><img src="cmsimages/g-previous.gif" alt="Previous" onclick="vgallery_skip(-1)"/></li>';

			var x=0;
			$("#gt .content_3 img").each(function(i){
				html+='<li style="background: url('+this.src+') no-repeat;" class="vgallery_item">';			
				html+='<img src="cmsimages/g-corner.gif" alt="" class="corner" /><a href="javascript:vgallery_load('+i+');">&nbsp;</a>';
				x++;
				html+='</li>';
			});
			vgallery_property.size=x;			


			html+='<li class="arrow" id="vgallery_next"><img src="cmsimages/g-next.gif" alt="Next" onclick="vgallery_skip(1)"/></li>';  	
			html+='</ul>';
			$("#gt .content_3").html(html);    

			$(".btn-next").click(function(){
				vgallery_skip(1);
			})
			vgallery_load(0);
		} else {
			// hide the next button
			$('#gtn').hide();
		}
	}
}

function vgallery_skip(int) {
	var new_index=parseInt(vgallery_property.current+int);
	// looping thru galleries
	if(new_index<0) {		
		new_index=parseInt(vgallery_property.size-1);
	} else if(new_index>=vgallery_property.size) {		
		new_index=0;
	}
	vgallery_load(new_index);	

}

function vgallery_load(int) {  	
	vgallery_property.current=int;
	$("li.vgallery_item").each(function(i) {

		var display_value='none';
		var html='<img src="cmsimages/g-corner.gif" alt="" class="corner" /><a href="javascript:vgallery_load('+i+');">&nbsp;</a>';
		if(i<int) {  			

		} else if(i==vgallery_property.current) {
			display_value='inline';
			html='<img src="cmsimages/g-active.gif" alt="" class="corner" />';
		} else if(i==vgallery_property.current || i<=parseInt(vgallery_property.current+vgallery_property.display_count-1)) {
			display_value='inline';
		} else {
			html='<img src="cmsimages/g-corner.gif" alt="" class="corner" /><a href="javascript:vgallery_load('+i+');">&nbsp;</a>';  			
		}  		
		$(this).css({display:display_value});
		$(this).html(html);  			
	});

	vgallery_placeholder();

	var vgallery_description='';
	$("#gm img").each(function(i){
		if(i==vgallery_property.current) {
			$(this).css({display:''});
			vgallery_description=$(this).attr("alt");  			
		} else {
			$(this).css({display:'none'});
		}
	});

	$("#gtn").html('<a href="javascript:vgallery_skip(1);" class="btn-next">Next</a>'+vgallery_description);	
}

function gall_html() {
	$("#gall_html_div").remove();
	var html='<div style="position:absolute;top:80px;left:10px;border:solid black 1px;font-size:10px;" id="gall_html_div">';
	html+='<pre>';
	html+=$(".content_3").html().replace(/</g,'&lt;');
	html+='</pre>';
	html+='</div>';
	$("body").append(html)
}

function vgallery_placeholder() {
	// remove all the placeholders
	$("li.vgallery_item_placeholder").remove();
	var vgallery_visible=$("li.vgallery_item:visible").length;
	if(vgallery_visible<vgallery_property.display_count) {
		var delta=parseInt(vgallery_property.display_count-vgallery_visible);		
		var li_bg_imgs=$(".vgallery_item");		
		var i=0;
		for(var x=0;x<delta;x++) {
			if(x==vgallery_property.size) {
				i=0;
			}
			// remove the quotes from the url, so ff can render the bg image
			var bg_url=$(li_bg_imgs)[i].style.background.replace(/\("/,'(').replace(/"\)/,')');
			$("#vgallery_next").before('<li class="vgallery_item_placeholder" style="background:'+bg_url+'"><a href="javascript:vgallery_load('+i+');">&nbsp;</a></li>');			
			i++;
		}
	}
}

// END GALLERY FUNCTIONS


// START HOMEPAGE GALLERY FUNCTIONS

var vhgallery_property={};
vhgallery_property.display_count=3;
vhgallery_property.size=0;
vhgallery_property.current=0;
vhgallery_property.on_images=[];
vhgallery_property.off_images=[];

function vhgallery_init() {		
	
	if(render_javascript()) {
		if($("#h-b img").length) {
			var html='<ul id="vhgallery_container">';
			html+='<li class="arrow"><a href="javascript:;" onclick="vhgallery_skip(-1)"><img src="cmsimages/arrow-up.gif" alt="Previous" /></a></li>';			
			$("#h-b img").each(function(i){
				if(i%2==0) {
					var index=vhgallery_property.on_images.length;										
					vhgallery_property.on_images[index]=this.src;
				} else {
					var index=Math.floor(parseInt(i/2));
					vhgallery_property.off_images[index]=this.src;
				}
			});			
			
			for(var i=0;i<vhgallery_property.on_images.length;i++) {
				html+='<li class="vhgallery_item">';			
				html+='<a href="javascript:vhgallery_load('+i+');"><img src="'+vhgallery_property.off_images[i]+'" alt="" /></a>';				
				html+='</li>';
			}			
			
			vhgallery_property.size=vhgallery_property.on_images.length;
			html+='<li class="arrow" id="vhgallery_next"><a href="javascript:;" onclick="vhgallery_skip(1)"><img src="cmsimages/arrow-down.gif" alt="Next"/></a></li>';  	
			html+='</ul>';
			$("#h-b").html(html);    
			
			// remove any white space elements
			/*var html='';
			$("#h-image img").each(function(i){		
				html+='<img src="'+this.src+'" alt="'+this.alt+'"/>';				
			});
			$("#h-image").html(html);*/
			vhgallery_load(0);
		}
	}
}

function vhgallery_skip(int) {
	var new_index=parseInt(vhgallery_property.current+int);
	// loop thru gallery images
	if(new_index<0) {
		new_index=parseInt(vhgallery_property.size-1);
	} else if(new_index>=vhgallery_property.size) {
		new_index=0;
	}
	vhgallery_load(new_index);
}

function vhgallery_load(int) {  	
	vhgallery_property.current=int;
	
	$("li.vhgallery_item").each(function(i) {

		var display_value='none';		
		if(i<int) {
		
		} else if(i==vhgallery_property.current) {						
			display_value='';
			src=vhgallery_property.on_images[i];			
		} else if(i<=parseInt(vhgallery_property.current+vhgallery_property.display_count-1)) {
			display_value='';
			src=vhgallery_property.off_images[i];			
		} else {
			
		}  		
		$(this).css({display:display_value});
		$(this).find('img').attr('src',src);			
	});

	vhgallery_placeholder();
	
	if( int == 2 || int == 1 || int == 3 ){
		$("#h-content").addClass("thinner");
		$("#h-image").addClass("wider");
	} else {
		$("#h-content").removeClass("thinner");
		$("#h-image").removeClass("wider");
	}
	
	$("#h-content > div").each(function(i){		
		var display_value='none';
		if(i==vhgallery_property.current) {
			var display_value='';
		}
		$(this).css({display:display_value});
	});
	
	$("#h-image > div").each(function(i){		
		var display_value='none';
		if(i==vhgallery_property.current) {
			var display_value='';
		}
		$(this).css({display:display_value});
	});
	
	if( int == 0 ){
		$("#h-image").hide();
	} else {
		$("#h-image").show();
	}

}

function vhgallery_placeholder() {
	// remove all the placeholders
	$("li.vhgallery_item_placeholder").remove();
	var vhgallery_visible=$("li.vhgallery_item:visible").length;
	if(vhgallery_visible<vhgallery_property.display_count) {
		var delta=parseInt(vhgallery_property.display_count-vhgallery_visible);
		var i=0;
		for(var x=0;x<delta;x++) {
			if(x==vhgallery_property.size) {
				i=0;
			}			
			$("#vhgallery_next").before('<li class="vhgallery_item_placeholder"><a href="javascript:vhgallery_load('+i+');"><img src="'+vhgallery_property.off_images[i]+'" alt="" /></a></li>');
			i++;
		}
		
		
		
		/*
		
		
var li_bg_imgs=$(".vgallery_item");		
var i=0;
for(var x=0;x<delta;x++) {
	if(x==vgallery_property.size) {
		i=0;
	}
	// remove the quotes from the url, so ff can render the bg image
	var bg_url=$(li_bg_imgs)[i].style.background.replace(/\("/,'(').replace(/"\)/,')');
	$("#vgallery_next").before('<li class="vgallery_item_placeholder" style="background:'+bg_url+'"><a href="javascript:vgallery_load('+i+');">&nbsp;</a></li>');			
	i++;
}		
		
		
		
		
		*/
		
	}
	
	//gall_html();
}

// END HOMEPAGE GALLERY FUNCTIONS 
