
var current_page_href = '';
var current_page_link = '';
var ie_update = false;
var first_ie_update = true;
var image_window = null;

var page_titles = new Array();

page_titles['home'] = '';
page_titles['admissions'] = 'Admissions';
page_titles['animation'] = 'Animation';
page_titles['apply_now'] = 'Apply Now';
page_titles['cinema_tv'] = 'Cinema-Telivision';
page_titles['contact_us'] = 'Contact Us';
page_titles['deans_welcome'] = 'Dean\'s Welcome';
page_titles['financial_aid'] = 'Financial Aid';
page_titles['journalism'] = 'Journalism';
page_titles['majors'] = 'Majors';
page_titles['theatre'] = 'Theatre';

var open_image = function(imghref, ttl, width, height) {
	if(image_window) image_window.close();
	image_window=window.open(imghref,'name','height='+height+',width='+width+'scrollbars=false,tollbar=false,menubar=false,location=false,directories=false');
	image_window.document.write('<html><head><title>'+ttl+'</title></head><body style="margin: 0px; padding: 0px"><img src="'+imghref+'"></body></html>');	
	return false;
}

var doPageChange = function(nL, hD) {
	if(!hD) hD = null;
	current_page(nL);	
	if(f_header) f_header.updateCurrentLink(nL);
	return false;
}


var init = function() {

	dhtmlHistory.initialize();
	dhtmlHistory.addListener(doPageChange);
	
	var initialLocation = dhtmlHistory.getCurrentLocation();
	if(!initialLocation || initialLocation == null) initialLocation = 'home';
	
	current_page(initialLocation);
}

var load_page = function(p) {
	dhtmlHistory.add(p);
	do_load_page(p);
	return false;	
}

var shrink_header = function() {
	$('header').style.height="355px";
	if(f_header) f_header.style.height="355px";
}

var grow_header = function() {
	$('header').style.height="590px";
	if(f_header) f_header.style.height="590px";
}

var do_load_page = function( p_link, autoup ) {
	
	if(!autoup) autoup = false;
	
	if(p_link == current_page_link) return false;
		
	p_href = 'content_'+p_link+'.html';
	current_page_href = p_href;
	current_page_link = p_link;
	
	close_content();

	return false;
}

var close_content = function(aF) {
	if(!aF) aF = set_content;
	if(aF == 'null') aF = null;
	
	new Effect.Opacity('content', { 
		duration:0.3, 
    	transition: Effect.Transitions.linear, 
    	from: 1.0, to: 0.0 ,
    	afterFinish: aF
    });
}

var set_content = function(obj) {
	
	//if(current_page_href != 'content_home.html') {
	//	shrink_header();	
	//} 
		
	new Ajax.Request(current_page_href, {
		method: 'get',
		asynchronous: false,
		onSuccess: function(transport) {
			$('content').innerHTML = transport.responseText;	
			open_content();
		}
	});

}

var open_content = function() {
	new Effect.Opacity('content', { 
		duration:0.3, 
    	transition: Effect.Transitions.linear, 
    	from: 0.0, to: 0.9999 ,
    	delay: 0.5
    });
        
    if($('feature_text')) {	
		var mfo = new SWFObject("movies/regent_marque.swf", "f_feature_text", "968", "25", "8");
		mfo.addParam("scale", "noscale");
		mfo.addParam("quality", "high");
		mfo.addParam("bgcolor", "1D233F");
		mfo.write("feature_text");	
	}
}

var current_page = function(p) {
	
	if(p && current_page_link != p) {
		load_page(p, true);	
	}
}
