//JS (mostly JQuery) for front page and template
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
   
   if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
	   var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:block;margin-left:auto;margin-right:auto;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}


function orientBackgroundPosRight(){
	if(window.innerWidth > 1024 || document.documentElement.clientWidth > 1024){
		$("#pictureFullArea").css("background-position", "right");	
	}else{
		$("#pictureFullArea").css("background-position", "left");
	}
}

$(document).ready(
	function(){
		orientBackgroundPosRight();
		var banner = document.getElementById("banner");
		fixPNG(banner);
		
		$(".initiallyHidden").css("display", "none");		  
		
		$(window).resize(function(){
			orientBackgroundPosRight();				  
		});
		
		
		
		$(".expandableContent h1").click(
			function(){
				$(this).siblings().toggle("fast");
				/*
				if($(this).children("span.expansionMarker").text() == "+"){
					$(this).children("span.expansionMarker").text("-");
				}else{
					$(this).children("span.expansionMarker").text("+");
				}
				*/
				if($(this).children("a").children("span.expansionMarker").text() == "+"){
					$(this).children("a").children("span.expansionMarker").text("-");
				}else{
					$(this).children("a").children("span.expansionMarker").text("+");
				}
				
				//alert($(this).children("a").children("span.expansionMarker").next().text);
				
				//alert($(this).children("a").lastChild.value);
				
				/*
				if(getCookie("")){
					
				}
				*/
				
				/*
				if(document.cookie.length > 0){
					
				}
				
				//Let's make our cookie expire in 1000 days.
				var expirationDate = new Date();
				expirationDate.setDate(expirationDate.getDate + 1000);*/
			}
		);
		
		$("#photo1").mouseover(
			function(){
				$("#pictureInfoText").text("The iconic Sample Gates have served as Indiana University's welcoming front door to the world since 1987.");
				$("#mainPhoto").attr("src", "images/main image.jpg");
			}
		);
		
		$("#photo2").mouseover(
			function(){
				$("#pictureInfoText").text("A statue immortalizes Herman B Wells, Indiana University's beloved Chancellor of the University and eleventh President.");
				$("#mainPhoto").attr("src", "images/main image 2.jpg");
				
			}
		);
		
		$("#photo3").mouseover(
			function(){
				$("#pictureInfoText").text("Indiana Arc, created by sculptor Charles O. Perry in 1995, adorns the front lawn of the IU Art Museum.");
				$("#mainPhoto").attr("src", "images/main image 3.jpg");
			}
		);
		
		$("#photo4").mouseover(
			function(){
				$("#pictureInfoText").text("The carving above the entrance to Franklin Hall reads \"A good book is the precious lifeblood of a master-spirit.\"");
				$("#mainPhoto").attr("src", "images/main image 4.jpg");
			}
		);
	}
	
);