$(document).ready(function(){
	MenuArray = new Array(
		{pageid:121652,hoffset:0,animate:"false"},
		{pageid:121654,hoffset:0,animate:"false"},
		{pageid:121653,hoffset:0,animate:"false"},
		{pageid:121656,hoffset:0,animate:"false"},
		{pageid:121657,hoffset:0,animate:"false"},
		{pageid:121658,hoffset:0,animate:"false"}
	);
	
	switch(pdGlobal.currentPages[0].id){
  		case 121652: GetPhotos(30122); break;
  		case 121654: GetPhotos(30123); break;
  		case 121653: GetPhotos(30124); break;
  		case 121656: GetPhotos(30125); break;
  		case 121657: GetPhotos(30126); break;
  		case 121658: GetPhotos(30127); break;
  		default: GetPhotos(30127); break;
  	}
	
	$("body").bulletin({ sid:138, gid:11303 })
	$("#nav").menu({ sid:138, settings:MenuArray, showL3s:false,currentL1:pdGlobal.currentPages[0].id, speed:0 });
	$('#search').pdSearch({showButton:true, showButtonClass:'search-box', showButtonText:''}); 
	
	//CSP sdb 042310 added this code from m.ebba to workaround IE7 not displaying fullscreen editor toolbar
	//if($.browser.msie){//m.ebbas detection method
	if((typeof clipboardData != 'undefined')&&(clipboardData.setData)){//detct for IE
                $("#footer").css("margin-left","0px");//alert('test');
		$("span.mce_fullscreen").click(function(){$("div#banner").hide();window.setTimeout('$("div#banner").show();',500);});
	}
	
		
	//hides the page tools on the custom pages, for some reason they are printing out.
	var pageArray = new Array(125267,125269,124970,124908,125346,124907,125271);
	for(var i = 0; i < pageArray.length; i++){
		if(parseInt(pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id) == parseInt(pageArray[i])){
			$("#page-tools").css("display","none");
		}
	}
	$("#GL_un_-1").mouseover(function(){
    	var p = $("TABLE.u2g").parent();
    	var l = p.css('left');
    	var nl = parseInt(l) - parseInt($('#Form1').offset().left)-12;
    	p.css('left',nl);
  	});
	
});

willow.ready(function($) {
	//annual fund
	if($(".annualFund").length > 0){
		var id = $(".annualFund").html();
		if(id.length > 0){
			$(".annualFund").html("");
			willow.getAF(id,function(data){
				$(".annualFund").annualfund(data);
			});
		}
	}
});

willow.getAF = function(id,cb){
	$.getJSON('/data/json.asp?type=af&id=' + id,function(data){
		if($.isFunction(cb)){
	    	cb.call(this, data);
	    }else{
	    	instance.log("Missing callback function for " + type);
	    }
	});
}

/*Search Functions */
function submitSearch(){
	__pdSiteSearch('', document.getElementById("search").value);
}
function SubmitOnEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13" || charCode == "26"){
		submitSearch();
		return false;
	}
}

function GetPhotos(pID,lphotos){
       $.ajax({
		type: "GET",
		url: "/xml/default.asp?sid=138&type=photoall&id="+pID,
		dataType: "xml",
		success: function(xml) {
			var totalphotos = parseInt($(xml).find('item').attr("totalphotos"));
			var randomNum = Math.floor(Math.random() * (totalphotos));
			var randCount = 0;
			$(xml).find('image').each(function(){
			    if(randCount == randomNum){
			    	//set my photo
			    	var path = $(this).find("path").text();
			    	
			    	$("#photo img").attr("src",path);
			    }
			    randCount++;
			});
			
			if($("#photo img").attr("src").length < 20){
				$("#photo img").attr("src","/ftpimages/138/podium/style523/default.jpg");
			}
			
			
			
		},
		error: function(request,tStatus,eThrown){
			//alert("Cant Get Photos");
		}
	});		
}
