/**
*   Javascript Helper Functions for RobInscapes.com
*/

/**
* Global Vars
*/
var cur_section = "about";

/**
* Effects
*/

function showDiv(id) {
	var d1 = $(id);
	d1.style.display = 'block';
}

function loadNav(reqsec) {
	if(reqsec != false) {
		var past_cur = $('nav_'+cur_section);
		past_cur.src = past_cur.src.replace(/_over.jpg/, ".jpg");
		var cur = $('nav_'+reqsec);
		cur.src = cur.src.replace(/.jpg/, "_over.jpg");
	}
	Effect.BlindDown('nav_id', { duration: 1.0 });
	setTimeout("loadContent("+reqsec+");", 1000);
}

function loadContent(reqsec) {
	if(reqsec != false) {
		loadPage(reqsec);
	} else {
		loadAbout();
	}
}

function navOver(section_img) {
	if(!section_img.id.match('_over') && !section_img.id.match(cur_section)) {
		section_img.src = section_img.src.replace(/.jpg/, "_over.jpg");
	} 
}

function navOff(section_img) {
	if(!section_img.id.match(cur_section)) {
		section_img.src = section_img.src.replace(/_over.jpg/, ".jpg");
	}
}

/** 
* Navigation
*/

function loadPage(page) {
	if(page != cur_section) {
		var func, content, services;
		past_cur = $('nav_'+cur_section);
		past_cur.src = past_cur.src.replace(/_over.jpg/, ".jpg");
		cur_section = page;
		
		
		if($("content_id").style.display != "none") {
			Effect.Fade('content_id', { duration: 0.5 });
		} else if($("services_div").style.display != "none") { 
			Effect.Fade('services_div', { duration: 0.5 });
		}
		if(page != "services") {
			func = "contentHelper('"+page+"')";
		} else {
			func = "getServiceDiv()";
		}
		setTimeout(func, 600);	
	}
}

function loadPageHelper() {
	Effect.Appear('content_id', { duration: 1.5 });
}

function loadAbout() {
	var func = "contentHelper('about')";
	setTimeout(func, 0);	
	Effect.Appear('content_id', { duration: 0.5 });
}

function contentHelper(page) {
	var pars = 'func='+page;
	getContent(pars);
	setTimeout("loadPageHelper();", 500);
}

function loadGallery() {
	var content = $('content_id');
	content.innerHTML = 'gallery';
	Effect.Appear('content_id', { duration: 0.5 });
}

function getServiceDiv() {
	var sc = $('services_div');
//	sc.style.display = "block";
	Effect.Appear('services_div', { duration: 0.5 });
}

function loadContact() {
	var content = $('content_id');
	content.innerHTML = 'contact';
	Effect.Appear('content_id', { duration: 0.5 });
}

function getContent(pars) {
	var url = '/index.php';
	var myAjax = new Ajax.Updater(
		'content_id', 
		url, 
		{
			method: 'get', 
			parameters: pars
		});
	return;
}