$(document).ready(
		function(){			
			//$('#slideshow1').cycle('fade');
			
			if(document.getElementById('post-cycle')){
				$('#post-cycle').cycle({ fx: 'fade', timeout: 6000, speed: 1000 });
			}
			
			$('#maplink').click(function(){
				if($(this).attr("behavior") == "map") {
					$(this).attr("behavior", "photo");
					$(this).css("background", "url('/wp-content/square.php?src=photos/" + $(this).attr("rel") + "&type=mapthumb')");
					$(this).find("#tracing").html("view photo");	
					$('#post-map').css("z-index", "999");
					$('#post-map').css("visibility", "visible");
				} else {
					$(this).attr("behavior", "map");
					$(this).css("background", "url('/wp-content/themes/grid_focus_public/images/mapicon.png')");
					$(this).find("#tracing").html("view map");	
					$('#post-map').css("z-index", "-1");
					$('#post-map').css("visibility", "hidden");
				}
			});
			
			$('#breaking').newsticker();
			
			if(document.getElementById("departments")) {
				var links = document.getElementById("departments").getElementsByTagName("li");
				var image = document.getElementById("dept_img");
			}
			
			var search = document.getElementById("s");
				
			if(search.addEventListener) {
			    search.addEventListener('focus',function () {
					search.style.color = "#000";
					search.select();
			    },false);
			} else {
			    search.attachEvent('onfocus',function () {
					search.style.color = "#000";
					search.select();
			    })
			}
			
			var iVer = parseInt(navigator.appVersion); 
			var sName = navigator.appName;
			
			if(document.getElementById("departments_list")) {
				var dept_links = document.getElementById("departments_list").getElementsByTagName("a");
			
			
				for(var i = 0; i < dept_links.length; i++) {
					var first = dept_links[i].innerHTML.substr(0,1);
				
					if(first == "0" || first == "1") {
						var second = dept_links[i].innerHTML.substr(0,2);
						var img_array = dept_imgs[Number(second)];
						var name = dept_links[i].innerHTML.split(" ")[1];
				
						setDeptMouseover(dept_links[i], name.toUpperCase(), img_array);
					}
				}
			}
	});

var lastMarker;

function setDeptMouseover(dept_link, name, img_array) {
	$(dept_link).mouseover(function() {
		var rand_no = Math.random();
		rand_no = rand_no * img_array.length;
		rand_no = Math.ceil(rand_no);
		rand_no--;
	
	    $("#dept_img").attr('src', "/wp-content/DEPT-PHOTOS/" + name + "/" + img_array[rand_no]);
	    //alert("/wp-content/DEPT-PHOTOS/" + name + "/" + img_array[rand_no]);
	});
}

function createMarker(point, number, html, blue) {
	var map_marker = new GMarker(point);
	
	GEvent.addListener(map_marker, "click", function() {
	  if(typeof(lastMarker) == "object") lastMarker.setImage("/wp-content/themes/grid_focus_public/images/marker.png");
	  map_marker.openInfoWindowHtml(html);
	  map_marker.setImage("/wp-content/themes/grid_focus_public/images/marker-blue.png");
	  lastMarker = map_marker;
	});
	
	map.addOverlay(map_marker);
	
	if(blue == true) {
		map_marker.setImage("/wp-content/themes/grid_focus_public/images/marker-blue.png");
		lastMarker = map_marker;
	}
}