var hpFeaturesCycle=-1;
var homepageNewsList=new Array();
var homepageEventsList=new Array();
//$(document).ready(function() {
	//if($.browser.msie && $.browser.version < 7){homepageFeatures_cycle();}else{homepageFeatures();}
	//homepageProfiles();
//});
if(typeof window.getElement != 'function'){
	function getElement(id){if(document.getElementById){getElement = function(id){ return document.getElementById(id); }}else if(document.all){getElement = function(id){ return document.all[id]; };}else if(document.layers){getElement = function(id){ return document.layers[id]; };}else{getElement = function() { return null; }}return getElement(id);}
}
function getContributionImgSrc(obj){
	if(obj.length > 0){
		tmpObj=obj.split('src="');
		if(tmpObj.length > 0){
			tmpObj1=tmpObj[1].split('"');
			return tmpObj1[0];
		}else{return '';}
	}else{return '';}
}
function getContributionImgAlt(obj){
	if(obj.length > 0){
		tmpObj=obj.split('alt="');
		if(tmpObj.length > 0){
			tmpObj1=tmpObj[1].split('"');
			return tmpObj1[0];
		}else{return '';}
	}else{return '';}
}
//features
function homepageFeature(img,title,subtitle,teaser){this.img=img;this.title=title;this.subtitle=subtitle;this.teaser=teaser;}
function homepageFeatures() {
	if(homepageFeaturesList !== undefined){
		hpFeaturesCycle++;
		if(hpFeaturesCycle == homepageFeaturesList.length) hpFeaturesCycle=0;
		$('#hp-hero').css("background-image","url('"+getContributionImgSrc(homepageFeaturesList[hpFeaturesCycle].img)+"')");
		$("#hp-hero_title").html(homepageFeaturesList[hpFeaturesCycle].title+' <label>'+homepageFeaturesList[hpFeaturesCycle].subtitle+'</label>');
		$("#hp-hero_teaser").html(homepageFeaturesList[hpFeaturesCycle].teaser);
		$("#hp-hero").fadeTo(1000,1).fadeTo(5000, 1).fadeTo(1000,0);
		setTimeout(homepageFeatures,7100);
	}
}
// for ie6
function homepageFeatures_cycle(){
	if(homepageFeaturesList !== undefined){
		hpFeaturesCycle++;
		if(hpFeaturesCycle == homepageFeaturesList.length) hpFeaturesCycle=0;
		if(homepageFeaturesList[hpFeaturesCycle].img != null || homepageFeaturesList[hpFeaturesCycle].img !== undefined){
			getElement('hp-hero').style.backgroundImage = 'url('+getContributionImgSrc(homepageFeaturesList[hpFeaturesCycle].img)+')';
			getElement('hp-hero_title').innerHTML = homepageFeaturesList[hpFeaturesCycle].title+' <label>'+homepageFeaturesList[hpFeaturesCycle].subtitle+'</label>';
			getElement('hp-hero_teaser').innerHTML = homepageFeaturesList[hpFeaturesCycle].teaser;
			window.setTimeout('homepageFeatures_cycle();',7100);
		}
	}
}
//voices
function homepageProfile(profileType,img,imgW,imgH,fname,lname,teaser,bckgrnd){this.profileType=profileType;this.img=img;this.imgW=imgW;this.imgH=imgH;this.fname=fname;this.lname=lname;this.teaser=teaser;this.bckgrnd=bckgrnd;}
function homepageProfiles() {
	if(homepageProfilesList !== undefined){
		var ranNum = Math.floor(Math.random()*(homepageProfilesList.length));
		//alert(ranNum);
		if(homepageProfilesList[ranNum] !== undefined){
			var title='';
			switch(homepageProfilesList[ranNum].profileType){
				case 'Alumni':
					title='Alumni Voice:';break;
				case 'Student':
					title='Student:';break;
				default:
					title='';
			}
			//if(homepageProfilesList[ranNum].bckgrnd != null || homepageProfilesList[ranNum].bckgrnd !== undefined)
				//$("#sidebar").css("background-image","url('"+getContributionImgSrc(homepageProfilesList[ranNum].bckgrnd)+"')");
			if(homepageProfilesList[ranNum].img != null || homepageProfilesList[ranNum].img !== undefined){
				if(!isNaN(homepageProfilesList[ranNum].imgW) && Number(homepageProfilesList[ranNum].imgW) != 0){
					//var tmpLeft = Math.floor(((220 - Number(homepageProfilesList[ranNum].imgW))/2)+25);
					//$("#sidebar_thumb").css("left",tmpLeft+'px');
				}
				$("#sidebar_thumb").attr({src:getContributionImgSrc(homepageProfilesList[ranNum].img),alt:"'"+getContributionImgAlt(homepageProfilesList[ranNum].img)+"'"});
			}
			$("#sidebar_title").html(title+'  <label>'+homepageProfilesList[ranNum].fname+' '+homepageProfilesList[ranNum].lname+'</label>');
			$("#sidebar_teaser").html(homepageProfilesList[ranNum].teaser);
			$("#sidebar").fadeIn(2000);
		}
	}
}
//News
function homepageNews(title,teaser){this.title=title;this.teaser=teaser;}
function homepageNewsDisplay(newsNumber){
	myReturn = '<ul class="events"><li><h3>'+homepageNewsList[newsNumber].title+'</h3>'+homepageNewsList[newsNumber].teaser+'</li></ul>';
	return myReturn;
}
//Events
function homepageEvent(title,teaser){this.title=title;this.teaser=teaser;}
function homepageEventsDisplay(headerTxt){
	myReturn='';
	if(homepageEventsList.length != 0){
		myReturn=headerTxt;
		myReturn+='<ul class="events">';
		if(homepageEventsList.length < 1){
			for(var n=0;n<homepageEventsList.length;n++){
				myReturn += '<li><h3>'+homepageEventsList[n].title+'</h3>'+homepageEventsList[n].teaser+'</li>';
			}
		}else{
			myReturn += '<li><h3>'+homepageEventsList[n].title+'</h3>'+homepageEventsList[n].teaser+'</li>';
		}
		myReturn += '</ul>';
	}else{myReturn='<br />';}
	return myReturn;
}

