var $j = jQuery.noConflict();
$j(document).ready(
	function()
	{
				
		// Toggle Single Portlet
		$j('img.toggle2').click(function()
			{
				$j(this).parent('div').next('div').slideToggle("normal");
			
				$j(this).each(function()
				{
					
					if($j(this).attr("id") == "calendarArrow")
						{
							if($j("#calendarPanel .bottom").css("display") == "none")
							{
								$j("#calendarPanel .bottom").show();
							}
							else
							{
								$j("#calendarPanel .bottom").css("display","none");
							}
						}
					else if($j(this).attr("id") == "tagArrow")
						{
							if($j("#tagPanel .bottom").css("display") == "none")
							{
								$j("#tagPanel .bottom").show();
							}
							else
							{
								$j("#tagPanel .bottom").css("display","none");
							}
						 }
					 
					 else if($j(this).attr("id") == "myLinksArrow")
						{
							if($j("#myLinks .bottom").css("display") == "none")
							{
								$j("#myLinks .bottom").show();
							}
							else
							{
								$j("#myLinks .bottom").css("display","none");
							}
						 }
					 
					 else if($j(this).attr("id") == "myCenterArrow")
						{
							if($j("#myCenter .bottom").css("display") == "none")
							{
								$j("#myCenter .bottom").show();
							}
							else
							{
								$j("#myCenter .bottom").css("display","none");
							}
						 }
						 
					  else if($j(this).attr("id") == "myCalendarArrow")
						{
							if($j("#myCalendar .bottom").css("display") == "none")
							{
								$j("#myCalendar .bottom").show();
							}
							else
							{
								$j("#myCalendar .bottom").css("display","none");
							}
						 }
						 
					   else if($j(this).attr("id") == "myMembershipsArrow")
						{
							if($j("#myMemberships .bottom").css("display") == "none")
							{
								$j("#myMemberships .bottom").show();
							}
							else
							{
								$j("#myMemberships .bottom").css("display","none");
							}
						 }
						
						else if($j(this).attr("id") == "myInCommonArrow")
						{
							if($j("#myInCommon .bottom").css("display") == "none")
							{
								$j("#myInCommon .bottom").show();
							}
							else
							{
								$j("#myInCommon .bottom").css("display","none");
							}
						 }
						 
						 else if($j(this).attr("id") == "myProfileArrow")
						{
							if($j("#myProfile .bottom").css("display") == "none")
							{
								$j("#myProfile .bottom").show();
							}
							else
							{
								$j("#myProfile .bottom").css("display","none");
							}
						 }
						 
						else if($j(this).attr("id") == "myNavArrow")
						{
							if($j("#myNav .bottom").css("display") == "none")
							{
								$j("#myNav .bottom").show();
							}
							else
							{
								$j("#myNav .bottom").css("display","none");
							}
						 }
						 
						
						else if($j(this).attr("id") == "myColleaguesArrow")
						{
							if($j("#myColleagues .bottom").css("display") == "none")
							{
								$j("#myColleagues .bottom").show();
							}
							else
							{
								$j("#myColleagues .bottom").css("display","none");
							}
						 }
					 
					 
					 
				  }); //------------------Close loop ----------------------------------------
		
				return false;
				
				
		 });//--------------Close Panel Toggle --------------------------------------------
		 
		 
		 //-----------------catalog and majors button functions-----------------------------
		 
		 var urlCareerMajor = 'http://www.tulsatech.edu/Help/Shared%20Documents/Career%20Major%20Catalog%2009-10.pdf';
		 var urlCourseCat = 'http://www.tulsatech.edu/Help/Shared%20Documents/Course_Catalog.pdf';
		 $j('#courseCatButton').click(function(){
		 		window.open(urlCourseCat);
		 });
		 $j('#careerMajorButton').click(function(){
		 		window.open(urlCareerMajor);
		 });

		 
		 
		 
		 //------------adding js functions to page load event--------------------------------
		 function addLoadEvent(func) {
      	 var oldonload = window.onload;
	       if (typeof window.onload != 'function') {
	         window.onload = func;
	       }
	       else {
	         window.onload = function() {
	           if (oldonload) {
	            oldonload();
	          }
	          func();
	        }
	      }
	    }
		 

		//----------------- Fix for top and bottom cap on submenu left nav  -----------------
		
		$j('.silverheader').mouseover(function(){
			$j('.topCap .botCap').css('display','block');

		});

	// This gets rid of the "Calendar Alt" on the calendar table------------------------------
		var calTitle = $j('#ctl00_m_g_cc00b1e5_7b2a_4727_a5f2_3a3e749cd581 table').attr("title","");
		
	// this ads round wrapper divs to calendar popup
		$j('div.balloonstyle').prepend("<div class='balloontop'></div>");
		$j('div.balloonstyle').append("<div class='balloonbot'></div>");
	
	//------------remove span and replace with div for popup calendar list -------------------
	//$j('div.balloonstyle span').replaceWith("<div class=date>" + $j('div.balloonstyle span').text() + "</div>");	
		
	
	//-----------------------------Spotlight Captions -------------Tom Pilgrim----------------------------------
			
	// Controls Drag + Drop
		$j('.panel314Hdr').mouseover(function(){$j(this).css("cursor","move");});
		$j('.panel314Hdr img').mouseover(function(){$j(this).css("cursor","pointer");});
		
		$j('.hdrB').mouseover(function(){$j(this).css("cursor","move");});
		$j('.hdrB img').mouseover(function(){$j(this).css("cursor","pointer");});

		//-------------Home Page Drag n Drop  ------------------------------------------------------------------					
		/*var sortOrder = $j('#content .col1,.col3,.col2').Sortable({
				accept:	'sortItem',
				helperclass: 'sort_placeholder',
				opacity: 0.7,
				fx:		50,
				tolerance: 'intersect',
				handle:	'.panel314Hdr',
				onStop:	function(){ var elName = $(this).get('id'); var pos = $(this).getPosition(); setPos(elName,pos); }
							
		});
		
		//--------------- MySite Profile Drag N Drop -------------------------------------------------------------------
		var sortOrder = $j('#content .col13a, .col16').Sortable({
				accept:	'sortItem',
				helperclass: 'sort_placeholder',
				opacity: 0.7,
				fx:		50,
				tolerance: 'intersect',
				handle:	'.hdrB'
				//onStop:	function(){ var elName = $(this).get('id'); var pos = $(this).getPosition(); setPos(elName,pos); }
							
		});

		//--------------- MySite Drag N Drop -------------------------------------------------------------------
		var sortOrder = $j('#content .col13,.col14,.col15').Sortable({
				accept:	'sortItem',
				helperclass: 'sort_placeholder',
				opacity: 0.7,
				fx:		50,
				tolerance: 'intersect',
				handle:	'.hdrB'
				//onStop:	function(){ var elName = $(this).get('id'); var pos = $(this).getPosition(); setPos(elName,pos); }
							
		});
*/
		function setPos(elName, pos){
			var positions = pos;
			var elementName = elName;
			var myCoordinates = JSON.encode(positions);
			
			
			var myStuff = JSON.decode(myCoordinates);
			var myCookie1 = Cookie.write(elementName,myStuff.x);
			//console.log(myCookie1);

		};
		
//************************** Cookie Handler for saving page state **********************************************
   			
		function getPage(){
		
		var calPos = Cookie.read('calendarPanel');
		//console.log(calPos);
		alert("hi");
		
		};
   
   
		
	//-----------------------Date function for master page header -----------------------------------------------------
	
	function longdate(){
		var d_names = new Array("Sunday", "Monday", "Tuesday",
		"Wednesday", "Thursday", "Friday", "Saturday");
		
		var m_names = new Array("January", "February", "March", 
		"April", "May", "June", "July", "August", "September", 
		"October", "November", "December");
		
		var d = new Date();
		var curr_day = d.getDay();
		var curr_date = d.getDate();
		var sup = "";
		if (curr_date == 1 || curr_date == 21 || curr_date ==31)
		   {
		   sup = "st";
		   }
		else if (curr_date == 2 || curr_date == 22)
		   {
		   sup = "nd";
		   }
		else if (curr_date == 3 || curr_date == 23)
		   {
		   sup = "rd";
		   }
		else
		   {
		   sup = "th";
		   }
		var curr_month = d.getMonth();
		var curr_year = d.getFullYear();
		
		document.write(d_names[curr_day] + " " + m_names[curr_month] + " " + curr_date + "<SUP>" + sup + "</SUP>" +  ", " + curr_year);
	
	};
			
	//***************************** Spotlight gallery ********************************************************	
	
	window.onload=function(){
		//document.getElementById("spotlightPanel"+Math.ceil(Math.random()*3)).style.display="block";
		
	}
	
		
	$j('#img1').click(function(){
	
		document.getElementById("spotlightPanel1").style.display="block";
		document.getElementById("spotlightPanel2").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img2').click(function(){
		
		document.getElementById("spotlightPanel2").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img3').click(function(){
		document.getElementById("spotlightPanel3").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel2").style.display="none";
	});
	
	$j('#img4').click(function(){
	
		document.getElementById("spotlightPanel1").style.display="block";
		document.getElementById("spotlightPanel2").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img5').click(function(){
		
		document.getElementById("spotlightPanel2").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img6').click(function(){
		document.getElementById("spotlightPanel3").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel2").style.display="none";
	});

	$j('#img7').click(function(){
	
		document.getElementById("spotlightPanel1").style.display="block";
		document.getElementById("spotlightPanel2").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img8').click(function(){
		
		document.getElementById("spotlightPanel2").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel3").style.display="none";
	});
	
	$j('#img9').click(function(){
		document.getElementById("spotlightPanel3").style.display="block";
		document.getElementById("spotlightPanel1").style.display="none";
		document.getElementById("spotlightPanel2").style.display="none";
	});
	
	//*************************** Start List()  for Top Nav ***************************************************
	
	function startList() {
		    if (document.all&&document.getElementById) {
			    navRoot = document.getElementById("menu");
			    for (i=0; i<navRoot.childNodes.length; i++) {
				    node = navRoot.childNodes[i];
				    if (node.nodeName=="LI") {
					    node.onmouseover=function() {
						    this.className+="over";
					    }
					    node.onmouseout=function() {
						    this.className=this.className.replace("over", "");
					    }
				    }
			    }
		    }
	    }
	//window.onload=startList; --------------------------/233/xl<>?#$T()$O@<:M!{}()<P%$}I'>{(0)}LG<43{(i=)}R}(te)I-)<M>()#:{}-----------------
	
		
	//*************************** Left Nav ***************************************************

				
			$j('#history').mouseover(function(){$j(this).removeClass('over');});
	


	//*********************************************************************************************************
	
});
