function mapEvent(id,addr,latitude,longitude,mtype) {
	if(latitude && longitude) showGeo(id,latitude,longitude,mtype);
	else showAddress(id,addr,mtype);
}

function showGeo(id,latitude,longitude,mtype) {
	var point = new GLatLng(latitude, longitude);
	if (GBrowserIsCompatible()) {
		//var mapControl = new GMapTypeControl();
		var marker = new GMarker(point);
		if(mtype == 'us') map.setCenter(new GLatLng(37.09024, -95.712891), 4);
		else if(mtype == 'state') map.setCenter(point, 6);
		else map.setCenter(point, 13);
		map.addOverlay(marker);
		//map.addControl(mapControl);
		//map.addControl(new GSmallMapControl());
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(locs[id]);
		});
	}
}

function showAddress(id,address,mtype) {
	geocoder = new GClientGeocoder();
	geocoder.getLatLng(
		address,
		function(point) {
			//console.log(address);
			//console.log(point);
			if (!point) {
				//alert(address + " not found");
				//console.log(address + " not found");
			} else {
				var marker = new GMarker(point);
				//var mapControl = new GMapTypeControl();
				if(mtype == 'us') map.setCenter(new GLatLng(37.09024, -95.712891), 4);
				else if(mtype == 'state') map.setCenter(point, 6);
				else map.setCenter(point, 13);
				map.addOverlay(marker);
				//map.addControl(mapControl);
				//map.addControl(new GSmallMapControl());
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(locs[id]);
				});
			}
		}
	);
}

	
jQuery.noConflict();
jQuery(document).ready(function($){

  var vids = {
    'allan': 'xpcFI53_JmE',
    'brian': 'wKbeJg_wHtc',
    'chris':'q1vD6-98Up8',
    'isabel':'Yb3PmyCZyZQ',
    'jeff':'KT5H0vOVgn0',
    'kate':'pzCi5hqKSXs',
    'kim':'gcMaRCEZPOs',
    'lee':'J1oh2n4iZY8',
    'lindsay':'VqWUCZuJDzs',
    'lucy':'7ea5cbKHXmw',
    'peter':'uUHq8Zgwh5o',
    'sunny':'bhUSJoAYJx0'
  }

	$('#videosacc li').addClass('closed');
	$('#videosacc li.closed').hover( function() {
	$(this).find('h2').addClass('over');
	},
	  function () {

		$(this).find('h2').removeClass();
	});
	
	$('#videosacc li.closed').live('click', function() {
		var $this = $(this);
		var id = this.getAttribute('id');
		var ytid = vids[id];

		$this.siblings()
			.removeClass()
			.addClass('closed')
			.animate({backgroundPosition: '-58px 0', width: '27px'}, 500)
			.find('.iframe').html('')
		;

		$this.animate({backgroundPosition: '0px 0px'}, { queue : false }, 500)
			.removeClass()
			.addClass('opened')
			.animate({backgroundPosition: '-30px 0', width: '626px'}, 500, function(){
			 $this.find('.iframe').html('<iframe allowfullscreen="" class="vid" frameborder="0" height="280" src="http://www.youtube.com/embed/'+ytid+'" title="YouTube video player" width="444"></iframe>')
			})
			
		;
		
	});
	
	var studentgrp = $(".content").children(".student");
        var scnt = studentgrp.length;
	var x;
         
        x = Math.floor(Math.random() * scnt);
	var $currentb = x;
	var $pic = $('#pic');
	var $bio = $('#bio');
	var $bios = [];
	var $vid = $('#vid');
	var $vids = [];
	var $students = [];
	var bioList = [];

	$('.studentpic').each(function(value) {
		$students.push($(this).html())
	});

	$('.bio').each(function(index, value){
		$bios.push($(this).html())
	});
	
	$('.ytvid').each(function(value){
		$vids.push($(this).html())
	});
	
	function switchStudent(){
		$bio.html($bios[$currentb]);
		$pic.html($students[$currentb]);
		$vid.html($vids[$currentb]);
	};
	switchStudent();

	function watchtheVideo(){
			var ytvid = $('#vid').html();
	$('#bio .watch').mousedown(function(){

		$('#pic').hide();      
		//<iframe width="640" height="360" src="http://www.youtube.com/embed/q1vD6-98Up8" frameborder="0" allowfullscreen ></iframe>
		//$('#vid').show();
		$('#vid').html('<iframe allowfullscreen="" class="vid" frameborder="0" width="640" height="360" src="http://www.youtube.com/embed/'+ytvid+'?autoplay=1" title="YouTube video player" frameborder="0" allowfullscreen ></iframe>').show();

	});
	};
	watchtheVideo();

	$('#nextbio').click(function(event){
		  event.preventDefault();

		$('#pic').show();
		$('#vid').html('').hide();
		var $maxLength = ($bios.length - 1);
		if($currentb == $maxLength){
			$currentb = 0;
			switchStudent();
			watchtheVideo();
		}else{	
			++$currentb; 
			switchStudent();
			watchtheVideo();
		};

	});
	$('#prevbio').click(function(event){
			  event.preventDefault();
	$('#pic').show();
		$('#vid').html('').hide();
		if($currentb == 0){
			$currentb = $bios.length - 1;
			switchStudent();
			watchtheVideo();
		}else{	
			--$currentb; 
			switchStudent();
			watchtheVideo();
		}
	});
	
	


	// New home page image rotator
	
	var $currentPic = 0;
	var $campus = $('#campus');
	var $picLength = ($('#campus li').length - 1);
	$('#campus .current').css({opacity:1});
	
	function switchCampuspic(){

		if($currentPic < $picLength){
			$('#campus .current').stop().removeClass('current').animate({opacity:0},500).next().addClass('current').animate({opacity:1},1000);
			++$currentPic;
		}else{	
			$currentPic = 0; 
			$('#campus .current').stop().removeClass('current').animate({opacity:0},500);
			$('#campus li').first().stop().addClass('current').animate({opacity:1},500);
		}
		
	};
	
	setInterval(function () {
		 switchCampuspic();
	}, 3500);

	//Scroll page
	$("#section-nav a, #floating-section-nav a").bind('click',function(event) {
	    var $anchor = $(this);
	    $("html, body").stop().animate({
	        scrollTop: $($anchor.attr("href")).offset().top
	    }, 1500,'easeInOutExpo');
	    event.preventDefault();
	});

  $(window).scroll(function() {
  	var scroll = $(window).scrollTop();
  	if (scroll >= 990) { 
  		//alert("here");
  		$("#floating-section-nav-container").fadeIn(300);
  	}
  	else {
  		$("#floating-section-nav-container").fadeOut(300);
  	}
  });

});

/*!
 * HTML5 Placeholder jQuery Plugin v1.8.2
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
(function(f){var e='placeholder' in document.createElement('input'),a='placeholder' in document.createElement('textarea');if(e&&a){f.fn.placeholder=function(){return this};f.fn.placeholder.input=f.fn.placeholder.textarea=true}else{f.fn.placeholder=function(){return this.filter((e?'textarea':':input')+'[placeholder]').bind('focus.placeholder',b).bind('blur.placeholder',d).trigger('blur.placeholder').end()};f.fn.placeholder.input=e;f.fn.placeholder.textarea=a}function c(h){var g={},i=/^jQuery\d+$/;f.each(h.attributes,function(k,j){if(j.specified&&!i.test(j.name)){g[j.name]=j.value}});return g}function b(){var g=f(this);if(g.val()===g.attr('placeholder')&&g.hasClass('placeholder')){if(g.data('placeholder-password')){g.hide().next().attr('id',g.removeAttr('id').data('placeholder-id')).show().focus()}else{g.val('').removeClass('placeholder')}}}function d(h){var l,k=f(this),g=k,j=this.id;if(k.val()===''){if(k.is(':password')){if(!k.data('placeholder-textinput')){try{l=k.clone().attr({type:'text'})}catch(i){l=f('<input>').attr(f.extend(c(this),{type:'text'}))}l.removeAttr('name').data('placeholder-password',true).data('placeholder-id',j).bind('focus.placeholder',b);k.data('placeholder-textinput',l).data('placeholder-id',j).before(l)}k=k.removeAttr('id').hide().prev().attr('id',j).show()}k.addClass('placeholder').val(k.attr('placeholder'))}else{k.removeClass('placeholder')}}f(function(){f('form').bind('submit.placeholder',function(){var g=f('.placeholder',this).each(b);setTimeout(function(){g.each(d)},10)})});f(window).bind('unload.placeholder',function(){f('.placeholder').val('')})}(jQuery));
jQuery(function($){ $('input, textarea').placeholder(); });




