
var question_string = "test";
var category_string = "test";

$(document).ready(function() {
	
	//--------------------------------------display random spotlight
//	var randomnumber=Math.floor(Math.random()*6) // to 3 spolights
	
	//randomnumber = randomnumber + 1;
	
	//$("#ecard" + randomnumber).attr("class", "");
		
	
	
//	$("li.ipf-parent ul").append("<li class='closing'></li>");
	
//-------------------------------------main nav hover-------------------------------------------------
	
	var url = window.location.href;
	
	/*if(url.indexOf("http://graduate.lmu.edu/apply") != -1) //we are under apply category
	{
		$("#pageid64031 div a").addClass("selected");
	}
	else if(url.indexOf("http://graduate.lmu.edu/overview") != -1) //we are under Overview category
	{
		$("#pageid64032 div a").addClass("selected");
	}
	else if(url.indexOf("http://graduate.lmu.edu/programs") != -1) //we are under Programs category
	{
		$("#pageid64033 div a").addClass("selected");
	}
	else if(url.indexOf("http://graduate.lmu.edu/resources") != -1) //we are under Resources category
	{
		$("#pageid64034 div a").addClass("selected");
	}
	else if(url.indexOf("http://graduate.lmu.edu/visit") != -1) //we are under Visit category
	{
		$("#pageid64035 div a").addClass("selected");
	}
	else if(url.indexOf("http://graduate.lmu.edu/contact") != -1) //we are under contact category
	{
		$("#pageid64588 div a").addClass("selected");
	}
	*/
	
	//main nav 1
	$("#main_nav1").hover(
		function () {
			var url = window.location.href;
			
			//if(url.indexOf("http://graduate.lmu.edu/apply") != -1) //we are under apply category
			$("#main_nav1 div a#parentlink1").removeClass("parent");	
			$("#main_nav1 div a#parentlink1").addClass("selected");
			$("#main_nav1 ul ").slideDown();
			
			
      }, 
      	function () {	
			
			$("#main_nav1 div a#parentlink1").removeClass("selected");	
			$("#main_nav1 div a#parentlink1").addClass("parent");
			$("#main_nav1 ul ").hide();
			
      }
    );
	
	//main nav 2
	$("#main_nav2").hover(
		function () {
			var url = window.location.href;
			
			$("#main_nav2 div a#parentlink2").removeClass("parent");	
			$("#main_nav2 div a#parentlink2").addClass("selected");
			
      }, 
      	function () {	
			$("#main_nav2 div a#parentlink2").removeClass("selected");	
			$("#main_nav2 div a#parentlink2").addClass("parent");
		}
    );
	
	//Main Nav 3
	$("#main_nav3").hover(
		function () {
			var url = window.location.href;
			
			$("#main_nav3 div a#parentlink3").removeClass("parent");	
			$("#main_nav3 div a#parentlink3").addClass("selected");
			
      }, 
      	function () {	
			$("#main_nav3 div a#parentlink3").removeClass("selected");	
			$("#main_nav3 div a#parentlink3").addClass("parent");
			
      }
    );
	
	//Main Nav 4
	$("#main_nav4 ").hover(
		function () {
			$("#main_nav4 div a#parentlink4").removeClass("parent");	
			$("#main_nav4 div a#parentlink4").addClass("selected");
      }, 
      	function () {	
			$("#main_nav4 div a#parentlink4").removeClass("selected");	
			$("#main_nav4 div a#parentlink4").addClass("parent");
      }
    );
	
	//Main Nav 5
	$("#main_nav5 ").hover(
		function () {
			var url = window.location.href;
			
			$("#main_nav5 div a#parentlink5").removeClass("parent");	
			$("#main_nav5 div a#parentlink5").addClass("selected");
			
      }, 
      	function () {	
			$("#main_nav5 div a#parentlink5").removeClass("selected");	
			$("#main_nav5 div a#parentlink5").addClass("parent");
			
      }
    );
	
	
	//------------------------------------------------------FAQ open answer feature--------------------------------------------
	
	//big cursor
	$("#cursor_left").hover(
	  function () {
		//alert($(this));  
		$(this).css("background-position", "0 -35px");
      },
      function () {
		$(this).css("background-position", "0 0");
      }
    );
	
	$("#cursor_right").hover(
	  function () {
		//alert($(this));  
		$(this).css("background-position", "0 -35px");
      },
      function () {
		$(this).css("background-position", "0 0");
      }
    );
	
	
	
	$(".small_nav_left a").hover(
	  function () {
		//alert($(this));  
		$(this).css("background-position", "0 -35px");
      },
      function () {
		$(this).css("background-position", "0 0");
      }
    );
	
	$(".small_nav_right a").hover(
	  function () {
		//alert($(this));  
		$(this).css("background-position", "0 -35px");
      },
      function () {
		$(this).css("background-position", "0 0");
      }
    );
	
	
	$("#dim_light").click(
	  function () {
		//alert($(this));  
		browser = $.browser.browser();
		if( $("#dim_text").html() == 'lower light')
		{
			$("#main_nav").css("z-index", 200);	
			$("#dim_text").html("raise light");	
			
			
			if($.browser.msie()) 
				$("#dim_light_screen_ie").css({opacity: 0, display: "block"}).animate({opacity: 0.8},500);
			else
				$("#dim_light_screen").fadeIn(500);
			
			
		}
		else
		{
				
			if($.browser.msie()) 
				$("#dim_light_screen_ie").fadeOut(500);
			else
				$("#dim_light_screen").fadeOut(500);
			
			
			$("#dim_text").html("lower light");	
			$("#main_nav").css("z-index", 6000);
		}
	  }
    );
	
	
	$("#dim_light").hover(
	  function () {
		//alert($(this));  
		$(this).css("background-position", "0 -34px");
      },
      function () {
		$(this).css("background-position", "0 0");
      }
    );
	
/*
	 var hideDelay = 200;  
	  var currentID;
	  var hideTimer = null;
	
	  // One instance that's reused to show info for the current person
	  var container = $('<div class="tooltip_container">'
		  + '<div class="tooltip">'
	   
		  + '   <div id="personPopupContent"></div>'
	   
		  + '</div>'
		  + '</div>');
	
	  $('body').append(container);
	
	  $('.video_thumbnail').live('mouseover', function()
	  {
		 
		  
		  var vid = $(this).attr('rel')
	
		  // If no guid in url rel tag, don't popup blank
		  if (vid == '')
			  return;
	
		  if (hideTimer)
			  clearTimeout(hideTimer);
	
		  var pos = $(this).offset();
		  var width = $(this).width();
		  container.css({
			  left: (pos.left + width - 100) + 'px',
			  top: (pos.top + 50) + 'px'
		  });
	
		  $('#personPopupContent').html('&nbsp;');
	
		  $.ajax({
			  type: 'GET',
			  url: 'video_tooltip_cb.php',
			  data: 'vid=' + vid,
			  success: function(data)
			  {
				  // Verify that we're pointed to a page that returned the expected results.
				  
	
				  // Verify requested person is this person since we could have multiple ajax
				  // requests out if the server is taking a while.
				  if (data.indexOf("title" + vid) > 0)
				  {                  
					  var text = $(data).html();
					  //alert(text);
					  $('#personPopupContent').html(text);
				  }
			  }
		  });
	
		  container.fadeIn();
	  });
	
	  $('.video_thumbnail').live('mouseout', function()
	  {
		  if (hideTimer)
			  clearTimeout(hideTimer);
		  hideTimer = setTimeout(function()
		  {
			  container.css('display', 'none');
		  }, hideDelay);
	  });
	
	  // Allow mouse over of details without hiding details
	  $('.tooltip_container').mouseover(function()
	  {
		  if (hideTimer)
			  clearTimeout(hideTimer);
	  });
	
	  // Hide after mouseout
	  $('.tooltip_container').mouseout(function()
	  {
		  if (hideTimer)
			  clearTimeout(hideTimer);
		  hideTimer = setTimeout(function()
		  {
			  container.css('display', 'none');
		  }, hideDelay);
	  });
*/
	
});// end doc ready


function createXMLHttpRequest() {
    try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {}
    try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}
    try {return new XMLHttpRequest();} catch(e) {}
    return null;
}//end of function 

function postAndFetch(url, content, handler, area_id, cid) 
{
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

   /*if(area_id != "")
   {
   		var indicator = document.getElementById(area_id);
		indicator.innerHTML="<div><img src='images/indicator.gif'></div>";
   }*/
   
   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
            handler(xmlhttp.responseText, area_id, url, cid);
        }
    };

    xmlhttp.open('POST', url, true);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 

	function generalHandler(Text, area_id, url, cid)
	{
		var content = Text
		
		$("."+area_id + " .items").html(content); 
		
		var scrollers = $("div." + area_id).scrollable({onSeek: 'getmore'+cid, size: 3}); 
        scrollers.reload(); 
		
	//	postAndFetch(url + '&mode=1','',reloadToolTip, 'tooltip_container'+cid, cid);
	
	}//end of function
	
	/*
	function reloadToolTip(Text, area_id, url, cid)
	{
		var content = Text
		$("#"+area_id).html(content); 
		
		
		$(".scrollable"+cid +" .items img").live("mouseover", function() { 
			id = $(this).attr("id")
			id_number =  id.substr(5);
				$(this).tooltip({ 
					tip: '#tooltip' + id_number, 
					position: 'bottom center',
					effect: 'slide'
	
				}); 
					}); 

	}
	*/
	/****************************************************tooltip AJAX*******************************************************************/
	
	
	
	var jkmegamenu={

effectduration: 300, //duration of animation, in milliseconds
delaytimer: 200, //delay after mouseout before menu should be hidden, in milliseconds

//No need to edit beyond here
megamenulabels: [],
megamenus: [], //array to contain each block menu instances
zIndexVal: 1000, //starting z-index value for drop down menu
$shimobj: null,

addshim:function($){
	$(document.body).append('<IFRAME id="outlineiframeshim" src="'+(location.protocol=="https:"? 'blank.htm' : 'about:blank')+'" style="display:none; left:0; top:0; z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
	this.$shimobj=$("#outlineiframeshim")
},

alignmenu:function($, e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $anchor=megamenu.$anchorobj
	var $menu=megamenu.$menuobj
	var menuleft=($(window).width()-(megamenu.offsetx-$(document).scrollLeft())>megamenu.actualwidth)? megamenu.offsetx : megamenu.offsetx-megamenu.actualwidth+megamenu.anchorwidth //get x coord of menu
	//var menutop=($(window).height()-(megamenu.offsety-$(document).scrollTop()+megamenu.anchorheight)>megamenu.actualheight)? megamenu.offsety+megamenu.anchorheight : megamenu.offsety-megamenu.actualheight
	var menutop=megamenu.offsety+megamenu.anchorheight  //get y coord of menu
	$menu.css({left:menuleft+"px", top:menutop+"px"})
	this.$shimobj.css({width:megamenu.actualwidth+"px", height:megamenu.actualheight+"px", left:menuleft+"px", top:menutop+"px", display:"block"})
},

showmenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $menu=megamenu.$menuobj
	var $menuinner=megamenu.$menuinner
	if ($menu.css("display")=="none"){
		this.alignmenu(jQuery, e, megamenu_pos)
		$menu.css("z-index", ++this.zIndexVal)
		$menu.show(this.effectduration, function(){
			$menuinner.css('visibility', 'visible')
		})
	}
	else if ($menu.css("display")=="block" && e.type=="click"){ //if menu is hidden and this is a "click" event (versus "mouseout")
		this.hidemenu(e, megamenu_pos)
	}
	return false
},

hidemenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $menu=megamenu.$menuobj
	var $menuinner=megamenu.$menuinner
	$menuinner.css('visibility', 'hidden')
	this.$shimobj.css({display:"none", left:0, top:0})
	$menu.hide(this.effectduration)
},

definemenu:function(anchorid, menuid, revealtype){
	this.megamenulabels.push([anchorid, menuid, revealtype])
},

render:function($){
	for (var i=0, labels=this.megamenulabels[i]; i<this.megamenulabels.length; i++, labels=this.megamenulabels[i]){
		if ($('#'+labels[0]).length!=1 || $('#'+labels[1]).length!=1) //if one of the two elements are NOT defined, exist
			return
		this.megamenus.push({$anchorobj:$("#"+labels[0]), $menuobj:$("#"+labels[1]), $menuinner:$("#"+labels[1]).children('ul:first-child'), revealtype:labels[2], hidetimer:null})
		var megamenu=this.megamenus[i]	
		megamenu.$anchorobj.add(megamenu.$menuobj).attr("_megamenupos", i+"pos") //remember index of this drop down menu
		megamenu.actualwidth=megamenu.$menuobj.outerWidth()
		megamenu.actualheight=megamenu.$menuobj.outerHeight()
		megamenu.offsetx=megamenu.$anchorobj.offset().left
		megamenu.offsety=megamenu.$anchorobj.offset().top
		megamenu.anchorwidth=megamenu.$anchorobj.outerWidth()
		megamenu.anchorheight=megamenu.$anchorobj.outerHeight()
		$(document.body).append(megamenu.$menuobj) //move drop down menu to end of document
		megamenu.$menuobj.css("z-index", ++this.zIndexVal).hide()
		megamenu.$menuinner.css("visibility", "hidden")
		megamenu.$anchorobj.bind(megamenu.revealtype=="click"? "click" : "mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
			return jkmegamenu.showmenu(e, parseInt(this.getAttribute("_megamenupos")))
		})
		megamenu.$anchorobj.bind("mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			if (e.relatedTarget!=menuinfo.$menuobj.get(0) && $(e.relatedTarget).parents("#"+menuinfo.$menuobj.get(0).id).length==0){ //check that mouse hasn't moved into menu object
				menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
					jkmegamenu.hidemenu(e, parseInt(menuinfo.$menuobj.get(0).getAttribute("_megamenupos")))
				}, jkmegamenu.delaytimer)
			}
		})
		megamenu.$menuobj.bind("mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
		})
		megamenu.$menuobj.bind("click mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
				jkmegamenu.hidemenu(e, parseInt(menuinfo.$menuobj.get(0).getAttribute("_megamenupos")))
			}, jkmegamenu.delaytimer)
		})
	} //end for loop
	if(/Safari/i.test(navigator.userAgent)){ //if Safari
		$(window).bind("resize load", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]
				var $anchorisimg=(megamenu.$anchorobj.children().length==1 && megamenu.$anchorobj.children().eq(0).is('img'))? megamenu.$anchorobj.children().eq(0) : null
				if ($anchorisimg){ //if anchor is an image link, get offsets and dimensions of image itself, instead of parent A
					megamenu.offsetx=$anchorisimg.offset().left
					megamenu.offsety=$anchorisimg.offset().top
					megamenu.anchorwidth=$anchorisimg.width()
					megamenu.anchorheight=$anchorisimg.height()
				}
			}
		})
	}
	else{
		$(window).bind("resize", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]	
				megamenu.offsetx=megamenu.$anchorobj.offset().left
				megamenu.offsety=megamenu.$anchorobj.offset().top
			}
		})
	}
	jkmegamenu.addshim($)
}

}

jQuery(document).ready(function($){
	jkmegamenu.render($)
})
	
