// prevent site from being framed in any other site
if (window != top) top.location.href = location.href;

$(document).ready(function(){
	
	gapi.plusone.render("plusone-pg", {"annotation": "none", "size": "small"} ); 
	
	// Sub Nav stuff
	
	var $subnav = $('#subNav');
	var height = 200;
	var subStat = false;
	var currId = "";
	
	// keep subnav open if mouseover any opf the below
	$('#header, #subNav').mouseover(function () {
		stopClose();
	});
	
	// cleanup empty subnavs
	$("#subNav ul:empty").remove();
	
	// main drop down
	$('#mainNav li .drop').live("click", function () {
		
		$('#mainNav li').removeClass('onState');
		$(this).parent().addClass('onState');
								 
		stopClose();
		var id = $(this).parent().attr("id");
		
		if(currId != id){
			$("#subNav ul").hide();
		}		
		
		if(navigator.appName == "Netscape"){
			
			if(subStat == false){
				// if already open keep the height for FF etc...
				$('#subNav').css("height",height);
				$('#subNav').slideDown(250, function(){
					$("#sub_close").stop().slideDown('fast').show();				
				});
				subStat = true;
			} else {
				// slide menu down and show sub nav for FF etc...
				$('#subNav').slideDown(250, function(){
					$("#sub_close").slideDown('fast').show();				
				});
				subStat = true;
			}
		} else {
			// resets height for IE to re-animate smoothly
			if(subStat == false){
				$('#subNav').css("height",0);
				$("#sub_close").hide();
			}
			
			// show sub menu for IE
			if($("#subNav:not(visible)")){					
				$subnav.stop().show().animate(
					{ height : height }, 
					{ 
						duration: 250, 
						complete: function(){
							$("#sub_close").stop().slideDown('fast').show();
						} 
					}
				);
			}
			subStat = true;
		}
		
		// reveal the sub menu links
		if(subStat == true){

			if(currId != id){	
				// hide the banner if the subnav links begins a second column
				var uls = $(".sub_" + id).length;
				if(uls > 1){
					$("#banner_cont, #subnav_banner").hide();
				} else {
					$("#banner_cont, #subnav_banner").show();
				}
				// show sub nav links		
				$(".sub_" + id).slideDown('fast').show();
			}
			
		}

		currId = id;
		return false;
	});
	
	function closeSubNav(){
		stopClose();
		//ot = 0;
		$("#sub_close").fadeOut('fast', function(){
			$subnav.stop().slideUp(250, function(){
				subStat = false;
			});
		});
		$('#mainNav li').removeClass("onState");
	}
	
	$('#mainNav li').hover(function(){
		$('#mainNav li').removeClass('onState');				
		if($(this).hasClass("hover")){
			$(this).removeClass("hover");
			$("#"+currId).addClass("onState");
			$(".drop").remove();
		} else {
			$(this).addClass("hover").addClass("onState");
			var liend = $(this).position().left + $(this).outerWidth()/2-20;
			$(this).append("<div class='drop' style='left:"+liend+"px'></div>");
		}
	});
	
	$('#sub_close').hover(
		function(){
			$(this).css("background-position", "-20px 0");
		},
		function(){
			$(this).css("background-position", "0 0");
		}
	);
	
	$("#sub_close").click(function(){
		closeSubNav();
		stopClose();
	});
	
	var t;
	
	function startClose(){
		t=setTimeout(closeSubNav,1000);
	}
	
	function stopClose(){
		clearTimeout(t);
	}

	$("#subNav, #sub_nav_logo").live('mouseenter',function(){
		stopClose();
		//ot = 0;
	});
	
	$("#slide_wrap").live('mouseenter',function(){
		startClose();
		//ot = 0;
	});
	
	$("#content").live('mouseenter',function(){
		closeSubNav();
		stopClose();
	});
	
	// Banner stuff
	var ban_vCurrent = 0;
	var ban_vTotal = 0;
	var ban_vDuration = 10000;
	var ban_intInterval = 0;
	var ban_vGo = 1;
	var ban_vIsPause = false;
	var ban_tmp = 20;
	var ban_title;
	var ban_w = $(window).width();
	
	$(window).resize(function(){
		$(".solution_nav").fadeOut();
		ban_w = $(window).width();	
		$(".ban_slide").css("width", $(window).width());
		$(".ban_slide").eq(ban_vCurrent).next().css("left", $(window).width());
		$(".ban_slide").eq(ban_vCurrent).next().next().css("left", $(window).width()+ban_w);
		$(".ban_slide h2, .ban_slide span").css("left", ($(window).width()/2-$(".ban_slide h2").outerWidth(true)+10) + "px");
		$(".ban_slide img").css("left", $(window).width()/2 + "px");
		
		if($("#slide_content").length !== 0){
			var slc_left = $("#slide_content").offset().left;
			$("#sub_" + currId).css("left", slc_left+"px");			
		}
		
	});
	
	ban_vTotal = $(".ban_slides").children().size() -1;
	$(".ban_info").text($(".ban_slide").attr("title"));	
	ban_intInterval = setInterval(ban_fnLoop, ban_vDuration);
			
	$("#ban_object").find(".ban_slide").each(function(i) { 
		ban_tmp = ((i - 1)*ban_w) - ((ban_vCurrent -1)*ban_w);
		$(this).animate({"left": ban_tmp+"px"}, 1000);
	});
		
	function ban_fnChange(){
		clearInterval(ban_intInterval);
		ban_intInterval = setInterval(ban_fnLoop, ban_vDuration);
		ban_fnLoop();
	}
	
	$(".slide_nav li").addClass("sn_off");
	$(".slide_nav li:first").addClass("sn_on");
	
	function ban_fnLoop(){
		if(ban_vGo == 1){
			ban_vCurrent == ban_vTotal ? ban_vCurrent = 0 : ban_vCurrent++;
		} else {
			ban_vCurrent == 0 ? ban_vCurrent = ban_vTotal : ban_vCurrent--;
		}
		$("#ban_object").find(".ban_slide").each(function(i) { 
					
			if(i == ban_vCurrent){
				ban_title = $(this).attr("title");
				$(".ban_info").animate({ opacity: 'hide', "left": "-50px"}, 250,function(){
					$(".ban_info").text(ban_title).animate({ opacity: 'show', "left": "0px"}, 1000);
				});
				
				$(".slide_nav li").removeClass("sn_on");
				$(".slide_nav li").eq(ban_vCurrent).addClass("sn_on");
			} 
			
			//Horizontal Scrolling
			ban_tmp = ((i - 1)*ban_w) - ((ban_vCurrent -1)*ban_w);
			$(this).animate({"left": ban_tmp+"px"}, 1000);
		});
	}
	
	$(".slide_nav li").click(function(){
		var sCur = $(this).index();
		ban_vCurrent = sCur-1;
		ban_fnChange();
	});
	
	// backgrounds need to be named with numbers like this (banner-slide1.jpg)
	// the png in the directory is for the foreground image
	
	$(".ban_slide").each(function(i){
		//$(this).css("background-image", "url(/images/banner-slides/banner-slide"+(i+1)+".jpg)");
		$(this).css("background-position", "center");
	});
	
	// position big text in banner
	$(".ban_slide h2, .ban_slide span").css("left", ($(window).width()/2-$(".ban_slide h2").outerWidth(true)) + "px");
	$(".ban_slide img").css("left", $(window).width()/2 + "px");
	
	
	// animate slide texts
	if($("#slide_content").length !== 0){
		var txtwid = $(".slc_txt").outerWidth();
		var imgwid = $(".slc_img").outerWidth();
		$(".slc_txt").css({"left": - $(window).width() + txtwid+"px"});
		$(".slc_img").css({"left": $(window).width() - imgwid+"px"});
		$(".slc_txt").show().animate({"left": 0+"px"}, 700, function(){ $(".quote_box").fadeIn(500); });
		$(".slc_img").show().animate({"left": 0+"px"}, 700);

		if($(".slc_img img").length == 0){
			$(".slc_txt").css("width","100%");
		}
	}
	
	// add style for press releases if they have a table in them
	if($("#press-releases-nav").length > 0){
		$("#content table td").css({"border":"1px solid #DFDFDF", "padding":"2px 6px 2px 6px" });
	}
	
	// set trail to close state
	var trail = $("#trail").outerWidth()-28;
	$("#trail").css("left", -trail+"px");
	
	$("#trail").hover(
		function(){ 					   
			$("#trail").stop().animate({"left": 0+"px"}, 250);	
			$("#trail").addClass("topen");
		},
		function(){
			$("#trail").stop().animate({"left": -trail+"px"}, 250);
			$("#trail").removeClass("topen");
		}
	);
	
	$(".child:visible ul li:last a").hover(
		function(){
			$(this).css("border-bottom","1px solid transparent");
		},
		function(){
			$(this).css("border-bottom","1px solid transparent");
		}
	);
	
	$('input#stay_logged').change(function () {     
		if($(this).attr("checked")){         
			$(this).val("1");        
			return;     
		}     
		$(this).val("0");   
	});
	
	$("#cancel").live('click', function(){ 
		var path = window.location.pathname;
		$('#prof_cont').load(path + ' #prof_cont'); 
	});
	
	$(window).scroll(function() {
		closeSubNav();
		if( $(document).scrollTop() == 0 && $(".toplink").length > 0)
			setTimeout(function(){
				$(".toplink").remove();
			}, 1000);
	});
	
	function scrollToTop(){
		$('html, body').animate({ scrollTop: 0 }, 1000);
	}

	// password show hide
	$("#change_password").live('click, focus', function(){ 
			$(this).remove();
			$("#user_password").val("").show().focus();
			$("#user_password2").val("");
			$(".pass2").slideDown("fast");
		}
	);

	$("#user_password").live('blur', function(){ 
			if($("#user_password").val() == ""){
				$.get( "/js/dynamic_js.php", { v: "passwordchange" }, function(data) { 
					$("#user_password").before("<input name='change_password' type='text' class='ptext' id='change_password' value='"+data+"' />");
				} );
				$(".pass2").slideUp("fast"); 
				$(this).slideUp("fast");
			}
		}
	);
	
	// profile show hide specific nav
	$(".pcheck2").each(function(){
		var cval = $(this).val();
		if($(this).attr("checked") && cval == "ProductCenter"){	
			$("."+cval).slideDown("fast");
		} else {
			$("."+cval).slideUp("fast");
		}
	});
	
	$(".pcheck2").live('click', function(){ 
		var cval = $(this).val();
		if($(this).attr("checked")){
			$("."+cval).slideDown("fast");
		} else {
			$("."+cval).slideUp("fast");
		}
	});
	
	
	// re-number
	function updateNums(sec){
	var n=1;
		$("#"+sec+" .ppara .nums").each(function(){
			$(this).text(" #"+n);
			n++;
		});
		setTimeout(function(){
			if(sec == "ctrids")
				$("#"+sec+" .ptext2:last").prev().focus();	
			else
				$("#"+sec+" .ptext2:last").focus();
		},100);
		
	}
	
	// fix issue with style in non-IE browsers
	if(navigator.appName == "Netscape"){
		$(".fbutton_inline").css({"margin":"0px 5px 0px 0px","height":"16px"});
		$(".fbutton_inline.subtract").css("margin-left","35px");
	}
	
	// add to a form
	$('.add').live("click",function(){
		if($(this).parent().find('input').val()){
			$(this).parent().clone(false).insertAfter($(this).parent()).removeClass("first").find('input').removeClass("error2").addClass("ptext2").val("");
			var sec = $(this).parent().parent().attr("id");
			updateNums(sec);
		}
	});
	
	// remove from a form
	$('.subtract').live("click",function(){
		var sec = $(this).parent().parent().attr("id");
		if($("#"+sec+" .nums").length > 1){
			$(this).parent().remove();
		}
	});
	
	// return to top of page
	$(".toplink").live("click",function(){
		scrollToTop();
		$(this).remove();
	});
	
	
	
	// fixed side navs
	$(window).scroll(function(){  
		
		var topStart = 278;
		var footerPos = $("#footer_wrap").position().top;
		var fm1Btm = ($('.floatMenu1').height()+100) + $('.floatMenu1').position().top;
		var fm2Btm = ($('.floatMenu2').height()+50) + $('.floatMenu2').position().top;
		
		if ($(this).scrollTop() > topStart){
			
			if(fm1Btm < footerPos)
				$('.floatMenu1').css({'position': 'fixed', 'top': '20px'});
			else
				$('.floatMenu1').css({'position': 'fixed', 'top': -(fm1Btm-footerPos)+'px'});
				
			if(fm2Btm < footerPos)
				$('.floatMenu2').css({'position': 'fixed', 'top': '20px'});
			else
				$('.floatMenu2').css({'position': 'fixed', 'top': -(fm2Btm-footerPos)+'px'});
				
		} else {
			$('.floatMenu1, .floatMenu2').css({'position': 'relative', 'top':'0px'});
		}
	});
	
	var fullurl = "";
	$(".more").click(function(){
		fullurl = $(this).attr("fullurl");
	});
	
	// css changes based on browser
	if(navigator.appName == "Netscape"){
		$(".fbutton_inline, .fbutton_inline:hover").css("padding","5px 10px 4px 10px");
	}
	
	// disallow the sp_chedck field be prefilled by auto complete
	$("#sp_check").attr("autocomplete","off");
	
	// do login
	$("#login").live("click",function(){ document.login_form.submit(); });
	
	// -------------------- FORM VALIDATION ---------------------------- //
	
	// make sure something changed in the form
	var vFlag = false;
 	$('#profile input, #profile select').bind('change', function() { 
		vFlag = true;
	});

	// validate the profile form
	$('#profile').live("submit",function() {
		if(vFlag == false){
			$("#stat").hide();
			$.get( "/js/dynamic_js.php", { v: "unchanged" }, function(data) { alert(data); } );
			return false;
		}
			
		var errors = 0;
		// see if the sp_check field is filled in by a spam bot
		if($("#sp_check").val() !== ""){
			$.get( "/js/dynamic_js.php", { v: "invaliddataentered" }, function(data) { alert(data); } );
			return false;
		}
		$(".ptext:visible:not(#user_address2), .error:visible:not(#user_address2)").each(function(){
			if( !$(this).val() ) {
				$(this).removeClass("ptext").addClass('error');
				errors++;
			} else if($(this).val()) {
				$(this).removeClass('error').addClass("ptext");
			}
		});
		if(errors > 0){
			$.get( "/js/dynamic_js.php", { v: "fieldrequired" }, function(data) { alert(data); } );
			return false;
		}
	}); 
	
	// validate the newsletter form
	$('#newsletter_form').live("submit",function() {
		var errors = 0;
		// see if the sp_check field is filled in by a spam bot
		if($("#sp_check").val() !== ""){
			$.get( "/js/dynamic_js.php", { v: "invaliddataentered" }, function(data) { alert(data); } );
			return false;
		}
		
		if( !$(".ptext").val() ) {
			$(".ptext").removeClass("ptext").addClass('error');
			errors++;
		} else if($(".ptext").val()) {
			$(".ptext").removeClass('error').addClass("ptext");
		}

		if($(".chbox:checked").length == 0){
			$(".chbox").addClass('cb_error');
			errors++;
		}
		
		if(errors > 0){
			$.get( "/js/dynamic_js.php", { v: "fieldrequired" }, function(data) { alert(data); } );
			return false;
		}
	}); 
	
	// validate the initiatives form
	$('#initiatives_form').live("submit",function() {
		var errors = 0;
		
		$("textarea").each(function(){
			if( !$(this).val() ) {
				$(this).removeClass("psel2").addClass('ta_error');
				errors++;
			}  else if($(this).val()) {
				$(this).removeClass('ta_error').addClass("psel2");
			}
		});
		

		if($('.rad[type=radio]').length == 0){
			$(".rb_wrap").addClass('cb_error');
			errors++;
		}
		
		if(errors > 0){
			$.get( 
				"/js/dynamic_js.php", 
				{ v: "fieldrequired" }, 
				function(data) { 
					alert(data);
				} 
			);
			return false;
		}
	}); 
	
	// validate the forgot form
	$('#forgot_form').live("submit",function() {
		var errors = 0;
		
		if( !$(".text").val() ) {
			$(".text").addClass('error');
			errors++;
		} else if($(".text").val()) {
			$(".text").removeClass('error');
		}
		
		if(errors > 0){
			$.get( "/js/dynamic_js.php", { v: "fieldrequired" }, function(data) { alert(data); } );
			return false;
		}
	}); 
	
	// validate the upgrade form
	$('#upgrade_form, #transfer_form').live("submit",function() {
											  
		var errors = 0;
		var msg = "";
		
		if($(".error2").length > 0)
			errors++;
		
		if($(".error").length > 0)
			errors++;
		
		if( !$("#version").val() ) {
			$("#version").removeClass("ptext").addClass('error');
			msg = "fieldrequired";
			errors++;
		}
		
		if( !$("#os").val() ) {
			$("#os").removeClass("ptext").addClass('error');
			msg = "fieldrequired";
			errors++;
		}
		
		var f=0;
		$(".ptext2").each(function(){
			if($(this).val())
				f++;
		});

		if( f == 0 ) {
			$(".ptext2").addClass('error2').removeClass("ptext2");
			msg = "atleastone";
			errors++;
		}
		
		if(errors > 0){
			$.get( "/js/dynamic_js.php", { v: msg }, function(data) { alert(data); } );
			return false;
		}

	});
	
	// restore error on field
	$(".error:not(.chbox)").live("keyup",function(){
		$(this).removeClass("error").addClass("ptext");
		$("#stat").fadeOut("slow");
	});
	$(".chbox").live("click",function(){
		$(".chbox").removeClass("cb_error");
	});
	$(".error2").live("keyup",function(){
		if($(this).val() !== ""){
			$(".error2").removeClass("error2").addClass("ptext2");
		}
		$("#stat").fadeOut("slow");
	});
	$("#wheninterested").live("click",function(){
		$(".rb_wrap").removeClass("cb_error");
		$(this).addClass("rad");
		$("#stat").fadeOut("slow");
	});
	$(".ta_error").live("keyup",function(){
		if($(this).val() !== ""){
			$(this).removeClass("ta_error").addClass('psel2');
		}
	});
	
	// home page hovers
	$(".serv").hover(
		function() {
			var rel = $(this).attr("rel");
			
			// if it has already been resized than leave it alone
			if( $("#"+rel).attr("class") == "heise"){
				$("#"+rel).stop().slideDown("fast");
				return;
			}
				
			var left = $(this).position().left;
			$("#"+rel+":hidden").css({"left" : left + "px"}).slideDown("fast", 
				function(){
					var liSize = $("#"+rel+" li").height() * $("#"+rel+" li").length + 3 ;
					if(liSize < 250 ){
						$("#"+rel).animate({ height: liSize+"px" }, 500).addClass("heise");
					} else {
						$("#"+rel).addClass("heise");
					} 
				}
			);
		},
		function(){
			return;
		}
	);
	
	$(".solution_nav").hover(
		function(){
			return;
		},
		function(){
			$(".solution_nav").slideUp("fast");
		}
	);
	
	// case studies
	$(".csbg").hover(
		function(){

			$(this).find(".csinfo").animate(
				{
				marginTop: '0'
				}, 'fast'
			).css("color","#ffffff");
			
		},
		function(){

			$(this).find(".csinfo").animate(
				{
				marginTop: '80'
				}, 'fast'
			).css("color","#999999");
			
		}
	);
	
	// videos
	
	$(".mkt").click(function(){
		$(".market").show();
		$(".tutorial").hide();
		$(this).css("text-decoration","underline");
		$(".tut").css("text-decoration","none");
	});
	$(".tut").click(function(){
		$(".tutorial").show();
		$(".market").hide();
		$(this).css("text-decoration","underline");
		$(".mkt").css("text-decoration","none");
	});
	
	var csi = (200-$(".csimg").height())/2;
	$(".csimg").css("margin-top", csi + "px");
	
	// XBRL stuff
	$(".xbrl").live("click", function(){
		var id = $(this).attr("xbrl");
		$("#"+id).show();
		$("#"+id+" div").slideToggle("fast", function(){ 
			if($("#"+id+" div").is(":hidden")) { 
				$("#"+id+" div").css("display","none");
				$("#"+id).css("display","none");
			}
		});
	});
	
	// unsubscribe
	$(".unsubscribe").click(function(){
		$("[type='checkbox']").removeAttr('checked').attr("disabled","true");							 
	});
	
	// subscribe
	$(".subscribe").click(function(){
		$("[type='checkbox']").attr('checked','checked').removeAttr('disabled');							 
	});
	
	// modal
	
	$("a[rel^='softechPhoto']").prettyPhoto({
		animation_speed: 'fast', /* fast/slow/normal */
		slideshow: false, /* false OR interval time in ms */
		autoplay_slideshow: false, /* true/false */
		opacity: 0.80, /* Value between 0 and 1 */
		show_title: false, /* true/false */
		allow_resize: true, /* Resize the photos bigger than viewport. true/false */
		default_width: 500,
		default_height: 100,
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* pp_default / light_rounded / dark_rounded / light_square / dark_square / facebook */
		horizontal_padding: 20, /* The padding on each side of the picture */
		hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
		wmode: 'opaque', /* Set the flash wmode attribute */
		autoplay: true, /* Automatically start videos: True/False */
		modal: false, /* If set to true, only the close button will close the window */
		deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */
		overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
		keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
		changepicturecallback: function(){
				
				gapi.plusone.render("plusone-ol", {"annotation": "none", "href": fullurl } );
				
				if(navigator.appName == "Netscape")
					var dhei = $(".pp_fade").outerHeight() + $(".pp_details").outerHeight() + 40;
				else
					var dhei = $(".pp_fade").outerHeight();
					
				$(".pp_content").css("height",dhei+"px");
				$(".pp_pic_holder").center();
				$(".plvid:not(.link)").click(function(){
					$.prettyPhoto.changePage('next');
					$.prettyPhoto.stopSlideshow();
					return false;
				});
				
				// to fix unloading error in IE9 with flash movies
				$(".pp_close, .pp_overlay").click(function(){
				  if(document.getElementById('mediaIframe') != undefined) { document.getElementById('mediaIframe').src = '/media/clear.html' }
				});
				
			}, /* Called everytime an item is shown/changed */
			callback: function(){ lastHash = ""; }, /* Called when prettyPhoto is closed */
			ie6_fallback: true,
			/*markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<p class="pp_description"></p><a class="pp_close" href="#">Close</a>  \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>',*/
					
			markup: '<div class="pp_pic_holder"> \
						<div class="ppt"></div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<p class="pp_description"></p> \
										<a class="pp_close" href="#">Close</a> \
										<div id="pp_full_res"></div> \
										<div class="pp_details"></div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>',
					
			gallery_markup: '<div class="pp_gallery"> \
								<a href="#" class="pp_arrow_previous">Previous</a> \
								<div> \
									<ul> \
										{gallery} \
									</ul> \
								</div> \
								<a href="#" class="pp_arrow_next">Next</a> \
							</div>',
			image_markup: '<img id="fullResImage" src="{path}" />',
			flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
			quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
			iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no" id="mediaIframe"></iframe>',
			inline_markup: '<div class="pp_inline">{content}</div>',
			custom_markup: '',
			social_tools: false /*'<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:23px;" allowTransparency="true"></iframe></div><div id="plusone-ol"></div></div>'*/ /* html or false to disable */
			
	});

});

/* put after pp_full_res if needed
<div class="pp_details"> \
											<div class="pp_nav"> \
												<a href="#" class="pp_arrow_previous">Previous</a> \
												<p class="currentTextHolder">0/0</p> \
												<a href="#" class="pp_arrow_next" del="test">Next</a> \
											</div> \
											 \
											{pp_social} \
											<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										</div> \
									*/

jQuery.fn.center = function () {     
	this.css("position","absolute");     
	this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");     
	this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");     
	return this; 
}

function slideSwitch() {
var $active = $('#banner_cont .active');
	if ( $active.length == 0 ) 
		$active = $('#banner_cont a:last');
	var $next =  $active.next().length ? $active.next() : $('#banner_cont a:first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
		.addClass('active')
	//adjust value to change the time taken to fade between images
		.animate({opacity: 1.0}, 2000, function() {
		$active.removeClass('active last-active');
	});
}

function setErr(){
	$('#profile .ptext:not(#user_email)').each(function(){
		$("#user_password").val("");
		$(this).removeClass("ptext").addClass('error');
	});
}
	
$(function() {
    //adjust value to change the interval between each image change
	setInterval( "slideSwitch()", 6000 );
});

// google tracking code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-518311-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

function sortNumber(a,b){
	return b - a;
}

function resizeContent(){
	// make both content side divs the same as the center div
	var maxHei = new Array();
	maxHei.push($("#center").height());
	maxHei.push($("#rside").height());
	maxHei.push($("#lside").height());
	maxHei.push($(".floatMenu1").height());
	maxHei.push($(".floatMenu2").height());		
	if($("#center").height() < 400){
		var nMH = maxHei.sort(sortNumber);
		//$("#lside, #rside, #center").css("height", nMH[0]+"px");
		$("#lside, #rside, #center").animate({'height': nMH[0]}, {duration: 500});
	}	
}
