function gotoLink(whichURL){
	window.location=whichURL;
}
function flickrFeed(setID,maxItems) {
	maxItemsDefault=15;
	if (maxItems!="" && maxItems!=null && maxItems<maxItemsDefault){
		maxItemsDefault=maxItems;
	}
	if (maxItemsDefault==1){
		$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=7fd6f5d6f34cb9df66504be6c798c023&photoset_id='+setID+'&per_page=1&format=json&jsoncallback=?', displayImage);
	}
	else {
		$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=7fd6f5d6f34cb9df66504be6c798c023&photoset_id='+setID+'&per_page='+maxItemsDefault+'&format=json&jsoncallback=?', displayImages);
	}
	
	//For Single Image
	function displayImage(data) {
		picCounter=0;
		var htmlLarge = '';
		var htmlThumbs = '';
		$.each(data.photoset.photo, function(i,photo){
			var source = 'http://farm'+photo.farm+'.static.flickr.com/'+photo.server+'/'+photo.id+'_'+photo.secret+'_m.jpg';
			var sourceLarge = source.replace('_m', '_b');
                htmlLarge+='<img class="flickrImg" src="'+ source +'" alt="" />';
                htmlLarge+='<p>'+ photo.title +'</p>';
			picCounter++;
		});
		$('.flickrPhoto').append(htmlLarge);
	};


	//For Multiple Images
	function displayImages(data) {
		totalPics=0;
		picCounter=0;
		var htmlLarge = '';
		var htmlThumbs = '';
		$.each(data.photoset.photo, function(i,photo){
			totalPics++;
		});
		$.each(data.photoset.photo, function(i,photo){
			var source = 'http://farm'+photo.farm+'.static.flickr.com/'+photo.server+'/'+photo.id+'_'+photo.secret+'_m.jpg';
			var sourceLarge = source.replace('_m', '_b');
			htmlLarge+='<div class="flickrContent" id="flickImg'+(picCounter+1)+'">';
			htmlLarge+='<img alt="" src="'+ source +'"/>';
			htmlLarge+='<p>'+ photo.title +'</p>';
			htmlLarge+='</div>';
		
			htmlThumbs+='<li><a href="#" onclick="flickrSwitch('+(picCounter+1)+','+totalPics+'); return false;"><img alt="'+ photo.title +'" src="'+ source +'"/></a></li>';
			picCounter++;
		});
		$('.flickrSlider').append(htmlLarge+'<ul class="jcarousel-skin-tango" id="flickrcarousel">'+htmlThumbs+'</ul>');
		jQuery('#flickrcarousel').jcarousel();
	};
	
	
};














function flickrFeedGateway(setID,maxItems) {
	maxItemsDefault=15;
	if (maxItems!="" && maxItems!=null && maxItems<maxItemsDefault){
		maxItemsDefault=maxItems;
	}

	$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=7fd6f5d6f34cb9df66504be6c798c023&photoset_id='+setID+'&per_page='+maxItemsDefault+'&format=json&jsoncallback=?', displayImagesGateway);



	//For Multiple Images
	function displayImagesGateway(data) {
		totalPics=0;
		picCounter=0;
		var htmlLarge = '';
		var htmlThumbs = '';
		$.each(data.photoset.photo, function(i,photo){
			totalPics++;
		});
		$.each(data.photoset.photo, function(i,photo){
			var source = 'http://farm'+photo.farm+'.static.flickr.com/'+photo.server+'/'+photo.id+'_'+photo.secret+'_m.jpg';
			var sourceLarge = source.replace('_m', '_b');
			htmlLarge+='<div class="mediaContent flickrThumb" id="mediaImg'+(picCounter+1)+'">';
			htmlLarge+='<a href="#"><img alt="" src="'+ source +'"/></a>';
			htmlLarge+='<p>'+ photo.title +'</p>';
			htmlLarge+='</div>';
			
			

			
			
		
			htmlThumbs+='<li><a href="#" onclick="mediaSwitch('+(picCounter+1)+','+totalPics+'); return false;"><img alt="'+ photo.title +'" src="'+ source +'"/></a></li>';
			picCounter++;
		});
		$('.Gallery').append(htmlLarge+'<ul class="jcarousel-skin-tango" id="mediaSlider">'+htmlThumbs+'</ul>');
		jQuery('#mediaSlider').jcarousel();
	};
	
	
};






//Function to set matching heights (to the max height) of all elements with a matching class name.

function setEqualHeight (element){
    var maxValue = undefined;
    $(element).each(function(){
        var val = parseInt($(this).height());
        if (maxValue === undefined || maxValue < val) {
            maxValue = val;
        }
    });
    $(element).each(function(){
        $(this).css("height",maxValue);
    });
}


(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);


function gatewayTabs(id,numTabs) {
    var i = 1;
    for (i = 1; i <= numTabs; i++) {
        document.getElementById('tab' + i.toString()).style.background = "url('/_site_support/images/alumniTabBg.jpg') repeat-x scroll 0 0 transparent";
		document.getElementById('tab' + i).style.color = "#7D7D7D";
        document.getElementById('tabContent' + i.toString()).style.display = "none";
    }
        document.getElementById('tab' + id.toString()).style.background = "#fff";
		document.getElementById('tab' + id).style.color = "#363636";
        document.getElementById('tabContent' + id).style.display = "block";
}

/*
function homeFeature(id) {
	document.getElementById('fNav1').style.background = "url('images/tabClarksonOverview.png') no-repeat center center";
	document.getElementById('fNav2').style.background = "url('images/tabMeetClarkson.png') no-repeat center center";
	document.getElementById('fNav3').style.background = "url('images/tabBrowseTheCampus.png') no-repeat center center";
	document.getElementById('homeSlider1').style.display = "none";
	document.getElementById('homeSlider2').style.display = "none";
	document.getElementById('homeSlider3').style.display = "none";
	document.getElementById('homeSlider' + id).style.display = "block";
	document.getElementById('fNav').style.background = "url('images/homeFNavBg.png') no-repeat scroll right top transparent";
	document.getElementById('fCon').style.background = "url('images/homeFeatureBg.png') no-repeat scroll 0 0 transparent";
	if(id == 1){
		document.getElementById('fNav1').style.background = "url('images/tabClarksonOverview_on.png') no-repeat center center";
		document.getElementById('notesOpen').style.display = "none";
		document.getElementById('notes').style.display = "block";
	}
	else if(id == 2){
		document.getElementById('fNav2').style.background = "url('images/tabMeetClarkson_on.png') no-repeat center center";
		document.getElementById('notesOpen').style.display = "none";
		document.getElementById('notes').style.display = "block";
	}
	else if(id == 3){
		document.getElementById('fNav3').style.background = "url('images/tabBrowseTheCampus_on.png') no-repeat center center";
		document.getElementById('fNav').style.background = "url('images/homeFNavBg2.png') no-repeat scroll right top transparent";
		document.getElementById('fCon').style.background = "none"
		document.getElementById('notesOpen').style.display = "none";
		document.getElementById('notes').style.display = "none";
	}
}
*/

function flickrSwitch(id,totalPics) {
	var numberOfSlides = totalPics;
    var i = 1;
    for (i = 1; i <= numberOfSlides; i++) {
        var contentElement = document.getElementById('flickImg' + i.toString());
		if(contentElement != null){
			contentElement.style.display = "none";
		}
    }
    var chosenElement = document.getElementById('flickImg' + id);
	if(chosenElement != null){
		chosenElement.style.display = "block";
	}
}

function mediaSwitch(id) {
	numberOfSlides = $(".flickrThumb").size();
    var i = 1;
    for (i = 1; i <= numberOfSlides; i++) {
        var contentElement = document.getElementById('mediaImg' + i.toString());
		if(contentElement != null){
			contentElement.style.display = "none";
		}
    }
    var chosenElement = document.getElementById('mediaImg' + id);
	if(chosenElement != null){
		chosenElement.style.display = "block";
	}
}

function openQuickLinks(){
	if(document.getElementById('quicklinksList').style.display == "block"){
		document.getElementById('quicklinksList').style.display = "none";
		document.getElementById('quickLinks').style.top = "25px";
	}
	else{
		document.getElementById('quicklinksList').style.display = "none";
		document.getElementById('quicklinksList').style.display = "block";
		document.getElementById('quickLinks').style.top = "90px";
	}
}

function hideQuickLinks(id){
	var selectStatus = document.getElementById("quicklinksList");
	if(id == 1){
		selectStatus.style.display = "none";
		document.getElementById('quickLinks').style.top = "25px";
	}
	else{
		selectStatus.style.display = "block";
		document.getElementById('quickLinks').style.top = "90px";
	}
}

function leftTab(whichImage){
	if(document.getElementById("notes").style.display == "block"){
		document.getElementById("notesOpen").style.display = "block";
		document.getElementById("notes").style.display = "none";
		runGat('Background Image Information Tab',whichImage);
	}
	else if (document.getElementById("notes").style.display == "none"){
		document.getElementById("notesOpen").style.display = "none";
		document.getElementById("notes").style.display = "block";
		runGat('Background Image Information Tab - Close',whichImage);
	}
	else {
		document.getElementById("notesOpen").style.display = "block";
		document.getElementById("notes").style.display = "none";
		runGat('Background Image Information Tab',whichImage);
	}
}

function newsDropDown(id){
	if(document.getElementById("sortOptions" + id).style.display == "none"){
		document.getElementById("sortButton" + id).style.background = "url('/_site_support/images/newsFilterLinkOpen.jpg') no-repeat scroll 0 0 transparent";	
		document.getElementById("sortOptions" + id).style.display = "block";
	}
	else{
		document.getElementById("sortButton" + id).style.background = "url('/_site_support/images/newsFilterLink.jpg') no-repeat scroll 0 0 transparent";	
		document.getElementById("sortOptions" + id).style.display = "none";
	}
}

var currentBgImg = 1;
function browseCampus(id){
	//when id == 0 view previous slide
	//when id == 1 view next slide
	var totalBgImages = document.getElementById("totalBgImages").value;
	if(id == 0){
		if(currentBgImg == 1){
			document.getElementById("campusImage").src = document.getElementById("bgImage" + totalBgImages).value;
			document.getElementById("bgCaption").innerHTML = document.getElementById("bgCaption" + totalBgImages).value;
			currentBgImg = totalBgImages;
		}
		else{
			currentBgImg = currentBgImg - 1;
			document.getElementById("campusImage").src = document.getElementById("bgImage" + currentBgImg).value;
			document.getElementById("bgCaption").innerHTML = document.getElementById("bgCaption" + currentBgImg).value;
		}
	}
	else if(id == 1){
		if(currentBgImg == totalBgImages){
			currentBgImg = 1;
			document.getElementById("campusImage").src = document.getElementById("bgImage" + currentBgImg).value;
			document.getElementById("bgCaption").innerHTML = document.getElementById("bgCaption" + currentBgImg).value;
		}
		else{
			currentBgImg = currentBgImg + 1;
			document.getElementById("campusImage").src = document.getElementById("bgImage" + currentBgImg).value;
			document.getElementById("bgCaption").innerHTML = document.getElementById("bgCaption" + currentBgImg).value;
		}
	}
}


function dd(id){
	ddClose();
	document.getElementById("drop" + id).style.display = "block";
}

function ddClose(){
	var i = 1;
    for (i = 1; i <= 6; i++) {
        document.getElementById('drop' + i.toString()).style.display = "none";
    }
}

	$(document).ready(function() {
		$('.hideUntilLoaded').removeClass("hideUntilLoaded");
		setEqualHeight($("#homeSubContent .admissionSub ul li h3"));

	});
	
/*Random BG and Notes (Background Info)*/
$(document).ready(function() {
	var bgCount = $("#totalBgImages").val();
		var rand = Math.random();
		rand = Math.ceil(rand * bgCount);
		var randPath = $("#bgImage"+rand).val();
		$("#campusImage").attr("src", randPath);
		var randCaption = $("#bgCaption"+rand).val();
		var randCredit = $("#bgCredit"+rand).val();
		//$("#notesOpen").html(rand+"<p>"+randCaption+"</p><p><em>photo credit: "+randCredit+"</em></p><div class='close'><a href='#' onclick='leftTab(); return false;'></a></div>");
		
$('#notes').html('<a href="#" onclick="leftTab(\''+randPath+'\'); return false;"><img src="/_site_support/images/tab.png"/></a>');


		$('#notesOpen').html('<!--'+rand+'--><p>'+randCaption+'</p><a target="_blank" onclick="runGat(\'Background Image Large View\',\''+randPath+'\');" class="viewLarge" href="'+randPath+'">View Image</a><p><em>photo credit: '+randCredit+'</em></p><div class="close"><a href="#" onclick="leftTab(\''+randPath+'\'); return false;"></a></div>');
		

		
		
		$("#bgCaption").html(randCaption);
		
		
	/* Adds an onclick event to every anchor within divs with an ID of "footer". */
	$('#footer a').click(function() {
		/* Sample of the script that will be called.  Confirm should be commented out... this is just for testing purposes. */
		/* confirm('Runs function:  _trackEvent(\'footer\', \'action\',\'' + this.title + '\',\'\')');*/
		/* Actual function call.*/
		/* Example:  _trackEvent(category, action, opt_label, opt_value)  */
		/* _trackEvent('footer','action???',this.title,'optional value'); */
		recordOutboundLink(this, 'Footer Content', this.href);
	});
	/* Adds an onclick event to every li/anchor within divs with an class of "social". */
	$('.social li a').click(function() {
		recordOutboundLink(this, 'Social Media', this.href);
	});
	/* Adds an onclick event to every anchor within divs with an id of "socialmedia_main". */
	$('#socialmedia_main a').click(function() {
		recordOutboundLink(this, 'Social Media Page', this.href);
	});
	/* Adds an onclick event to every ul/li/anchor within divs with an ID of "quickLinksList". */
	$('#quicklinksList ul li a').click(function() {
		recordOutboundLink(this, 'Quicklinks', this.href);
	});

	if ($(".print a")){
		$(".print a").attr("href","javascript:printVersion()");
	}	
	
});


function printVersion(){
	if ($(".contentArea")){
	    var now = new Date();
	    var txtYear = now.getFullYear();
	    newwindow=window.open("","","toolbar=no,status=no,width=610,height=400,location=no,scrollbars=yes,menubar=yes,resizable=yes");
	    newdocument=newwindow.document;
	    newdocument.write('<html><head><style>a,a:hover,a:visited,a:link { color: #000000; text-decoration: none; } .links { display: none; } .logo {}</style></head><body>');
	    newdocument.write('<img alt="Clarkson University Logo" class="logo logoPrint" src="/_site_support/images/logo_print.gif" />');
	    if ($(".title h1")){
	        newdocument.write('<h1>'+$(".title h1").html()+'</h1>');
	    }
        newdocument.write('<div class="contentArea">'+$(".contentArea").html()+'</div>');
    	newdocument.write('<div class="footer">&copy;'+txtYear+' Clarkson University</div></body></html>');
    	newdocument.close();
	}
	else {window.print();}
}

