$(document).ready( function(){
	//switch pictures
	$("#promo > ul > li > a").click( function(){
		$("#promo > ul > li > a").removeClass("on");
		$(this).addClass("on");
		return false;
	});
	
	$("#dnn_ctr365_Display_HtmlHolder").cycle({
    	timeout:4000,
    	speed:500,
    	before:onBefore,
    	pause:true,
    	next:'#next',
    	prev:'#prev'
	});
 
	function onBefore() {
		$('#desc').html(this.alt);
	}
	
	defaultTxt(".Email-Input");
	defaultTxt(".xsTxtSearch");
	
	//$(".jcalendar").jcalendar();
	
	update_translation_dropdown();
	
	if (document.getElementById("bkpk_frame")!=null)
	{
		$("body.bg").attr("style", "background:url(/Portals/_default/Skins/glcvb/images/tile1.jpg);");
	}
});

function defaultTxt(className){
	if(className == ".xsTxtSearch"){
		var strVal = "Search";
	} else {
		var strVal = "Email Address";
	}
	$(className).attr({ value: strVal }).click( function(){
		if($(this).val() == strVal){
			$(this).attr({ value: "" });
		}
		$(this).css({ color: "#000" });
	}).blur( function(){
		if($(this).val() == ""){
			$(this).css({ color: "gray" });
			$(this).attr({ value: strVal });
		}
	});
}

function translate(){
    if (window.location.hostname == "www.lansing.org" || window.location.hostname == "lansing.org")
		{
		    var _value;
            var _index = document.getElementById("translation_dropdown").selectedIndex;
            
			_value = document.getElementById("translation_dropdown")[_index].value;
			_url = window.location.href;
			window.location.href = "http://translate.google.com/translate?u=" + _url + "&hl=en&ie=UTF8&sl=en&tl=" + _value;
		}
}

function update_translation_dropdown()
{
	if (window.location.hostname != "www.lansing.org" && window.location.hostname != "lansing.org")
	{
        var _qs = gup("tl");
        var _len = document.getElementById("translation_dropdown").length;
        
        for (i=0; i<_len; i++)
	    {
		    if (document.getElementById("translation_dropdown")[i].value == _qs)
		    {
			    document.getElementById("translation_dropdown").selectedIndex = i;
			    break;
		    }
	    }
    }
    else
    {
        document.getElementById("translation_dropdown").selectedIndex = 8;
    }
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

