//
//	EMERSON COLLEGE
//		ADMISSIONS PORTAL
//			JAVASCRIPT FILE - UNDERGRAD - MAIN PAGE
//
//		VERSION 0.0.1
//

var src_root = "../images_v1/undergrad/main/";

var quoteAlts = new Array;
	quoteAlts[0] = "Who are you?";
	quoteAlts[1] = "To Come...";
	quoteAlts[2] = "to come...";
	quoteAlts[3] = "to come...";
	quoteAlts[4] = "to come...";
	quoteAlts[5] = "to come...";
	quoteAlts[6] = "to come...";
	quoteAlts[7] = "to come...";
	quoteAlts[8] = "to come...";

function changeImage(locater) {
	// Clear for bottom nav
	navbar_popdown();
	// Change Click-image to over-version
	element("ug_main_box" + locater).src = src_root + "ug_main_box" + locater + "_over.png";
	// Change Quote image to over-version (with ALT tag change)
	element("ug_main_quote").src = src_root + "ug_main_quote_" + locater + ".png";
	element("ug_main_quote").alt = quoteAlts[locater];
}

function resetImage() {
	for (var looper=1; looper < 9; looper++) {
		element("ug_main_box" + looper).src = src_root + "ug_main_box" + looper + ".png";
	}
	element("ug_main_quote").src = src_root + "ug_main_quote_" + 0 + ".png";
	element("ug_main_quote").alt = quoteAlts[0];
}

function imagePreloader() {
     // counter
     var i = 1;

     // create object
     imageObj = new Image();

     // start preloading
     for(i=1; i<=10; i++) {
          imageObj.src = src_root + "ug_main_box" + i + "_over.png";
		  imageObj.src = src_root + "ug_main_quote_" + i + ".png";
     }
}

function navbar_popup(type) {
	navbar_popdown();
	element("area_mainbody_footer_" + type).style.display = "block";
}

function navbar_popdown() {
	if (element("area_mainbody_footer_deadlines") != null) {
		element("area_mainbody_footer_deadlines").style.display = "none";
		element("area_mainbody_footer_visit").style.display = "none";
		element("area_mainbody_footer_news").style.display = "none";
	}
}

function loadFlashTitle_ug(admissionUrl,imagesUrl) {
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(hasRightVersion) {  // if we've detected an acceptable version
		var oeTags = '<div id="area_mainbody_flash_ug"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'width="800" height="360"'
		+ 'codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<param name="movie" value="' + admissionUrl + 'templates/swf/undergrad.swf" />'
		+ '<param name="menu" value="false" />'
		+ '<param name="quality" value="best" />'
		+ '<param name="bgcolor" value="#f6dc61" />'
		+ '<embed src="' + admissionUrl + 'templates/swf/undergrad.swf" menu="false" quality="best" wmode="transparent" bgcolor="#f6dc61" '
		+ 'width="800" height="360" name="admission" align="middle"'
		+ 'play="true"'
		+ 'loop="false"'
		+ 'quality="high"'
		+ 'allowScriptAccess="sameDomain"'
		+ 'type="application/x-shockwave-flash"'
		+ 'pluginspage="https://www.adobe.com/go/getflashplayer">'
		+ '<\/EMBED>'
		+ '<\/OBJECT></div>';
		document.write(oeTags);   // embed the flash movie
	} else {
		document.write('<div id="area_mainbody_textonly_ug">						<div id="area_ug_quote">							');
		document.write('<img src="' + imagesUrl + 'undergrad/main/ug_main_quote_0.png" alt="What\'');
		document.write('s your path?" name="ug_main_quote" width="305" height="239" border="0" id="');
		document.write('ug_main_quote" title="" />						</div>						<div id="area_ug_box_1">				');
		document.write('			<a href="/admission/undergraduate/academics/institute.cfm">							<img ');
		document.write('src="' + imagesUrl + 'undergrad/main/ug_main_box1.png" alt="Liberal Arts ');
		document.write('&amp; Interdisciplinary Studies" name="ug_main_box1" width="114" height="13');
		document.write('8" border="0" id="ug_main_box1" title="" /></a>						</div>						<div id=');
		document.write('"area_ug_box_2">							<a href="/admission/undergraduate/academics/csd.cfm');
		document.write('">							<img src="' + imagesUrl + 'undergrad/main/ug_main_box2.png" alt');
		document.write('="Communication Sciences &amp; Disorders" name="ug_main_box2" width="114" h');
		document.write('eight="138" border="0" id="ug_main_box2" title="" /></a>						</div>					');
		document.write('	<div id="area_ug_box_3">							<a href="/admission/undergraduate/academic');
		document.write('s/journalism.cfm">							<img src="' + imagesUrl + 'undergrad/main/ug_ma');
		document.write('in_box3.png" alt="Journalism" name="ug_main_box3" width="114" height="138" ');
		document.write('border="0" id="ug_main_box3" title="" /></a>						</div>						<div id="ar');
		document.write('ea_ug_box_4">							<a href="/admission/undergraduate/academics/mkt.cfm">');
		document.write('							<img src="' + imagesUrl + 'undergrad/main/ug_main_box4.png" alt="M');
		document.write('arketing Communication" name="ug_main_box4" width="114" height="138" border');
		document.write('="0" id="ug_main_box4" title="" /></a>						</div>						<div id="area_ug_');
		document.write('box_5">							<a href="/admission/undergraduate/academics/opc.cfm">						');
		document.write('	<img src="' + imagesUrl + 'undergrad/main/ug_main_box5.png" alt="Organiz');
		document.write('ational &amp; Political Communication" name="ug_main_box5" width="114" heig');
		document.write('ht="138" border="0" id="ug_main_box5" title="" /></a>						</div>						<d');
		document.write('iv id="area_ug_box_6">							<a href="/admission/undergraduate/academics/p');
		document.write('erforming_arts.cfm">							<img src="' + imagesUrl + 'undergrad/main/ug_');
		document.write('main_box6.png" alt="Performing Arts" name="ug_main_box6" width="114" height');
		document.write('="138" border="0" id="ug_main_box6" title="" /></a>						</div>						<div');
		document.write(' id="area_ug_box_7">							<a href="/admission/undergraduate/academics/vis');
		document.write('ual_and_media_arts.cfm">							<img src="' + imagesUrl + 'undergrad/main');
		document.write('/ug_main_box7.png" alt="Visual &amp; Media Arts" name="ug_main_box7" width=');
		document.write('"114" height="138" border="0" id="ug_main_box7" title="" /></a>						</div');
		document.write('>						<div id="area_ug_box_8">							<a href="/admission/undergraduate/a');
		document.write('cademics/wlp.cfm">							<img src="' + imagesUrl + 'undergrad/main/ug_ma');
		document.write('in_box8.png" alt="Writing, Literature, &amp; Publishing" name="ug_main_box8');
		document.write('" width="114" height="138" border="0" id="ug_main_box8" title="" /></a>			');
		document.write('			</div>					</div>');
	}
	
}



// shows tabs for step-by-step
// this function predicated on the link name being the same as the tab name + _link
function showDivTab(divName, thisDivName) {
	// loop from 1-20
	for (var i = 1; i <= 20; i++) {
		//get the corresponding name of the link container
		var linkP = divName + i + '_link';
		// if there is a matching tab hide it and set its corresponding link bgcolor to white; otherwise break
		if (document.getElementById(divName+i)) { 
			document.getElementById(divName+i).className = 'tabHide';
			document.getElementById(linkP).style.backgroundColor = '#FFFFFF';
			document.getElementById(linkP).style.borderBottom = "thin solid #808080";
			document.getElementById(linkP).style.borderTop = "none";
			document.getElementById(linkP).style.borderLeft = "none";
			document.getElementById(linkP).style.borderRight = "none";
		}	else {
			break;
		}
	}
	//show selected tab and set bgcolor and borders of active tab
	document.getElementById(thisDivName).className = 'tabView';
	document.getElementById(thisDivName + '_link').style.backgroundColor = '#EAEAEA';
	document.getElementById(thisDivName + '_link').style.borderTop = "thin solid #808080";
	document.getElementById(thisDivName + '_link').style.borderLeft = "thin solid #808080";
	document.getElementById(thisDivName + '_link').style.borderRight = "thin solid #808080";
	document.getElementById(thisDivName + '_link').style.borderBottom = "none";
	
}