nav = new Object();

nav.highlight = function(object, id, type)
{
	
	if (type == "over")
	{
		if (object.className != "highlight_menu")
		{
			object.className = "highlight_menu";
		}
	}
	else
	{
		if (id != display.page_current)
		{
			object.className = "unhighlight_menu";
		}
	}
	
	return true;
}

display= new Object();

display.html = function(url)
{
	ajax.get(url, "display.write");
}

display.write = function (html)
{
	
	if (html)
	{
		document.getElementById('html').innerHTML = html;
		document.getElementById(display.page_current+'_links').style.display = 'block';
	}
}

display.page = function(id, url)
{
	
	if (id != display.page_current)
	{	
		display.page_current = id;
		
		document.getElementById('html').innerHTML = "<div class=\"preloader\"><img src=\"/graphics/loader.gif\"/><br/>Please wait, loading..</div>";
		display.html(url);
		
		display.page[id] = true;	
		
		for (var page in display.pages)
		{
			if (
				document.getElementById(page) 
			)
			{
				if (page != display.page_current)
				{
					document.getElementById(page).className = 'unhighlight_menu';
					document.getElementById(page+'_links').style.display = 'none';
					document.getElementById(page+'_img').src = '/graphics/nav/'+page+'.png';
				}
				else
				{
					document.getElementById(page+'_links').style.display = 'block';
					document.getElementById(page+'_img').src = '/graphics/nav/'+page+'_select.png';
					
				}
			}
		}		
		
	}
	else
	{
		document.getElementById('html').innerHTML = "<div class=\"preloader\"><img src=\"/graphics/loader.gif\"/><br/>Please wait, loading..</div>";
		display.html(url);
	}	
}


display.sub_page = function(url)
{
	document.getElementById('html').innerHTML = "<div class=\"preloader\"><img src=\"/graphics/loader.gif\"/><br/>Please wait, loading..</div>";
	display.html(url);
}

display.blog_posts = function(url)
{
	document.getElementById('blog_links').innerHTML = "<div class=\"preloader_small\"><img src=\"/graphics/loader.gif\"/><br/>Please wait, loading..</div>";
	display.blog_posts_html(url);
}


display.blog_posts_html = function(url)
{
	ajax.get(url, "display.blog_posts_write");
}

display.blog_posts_write = function (html)
{
	if (html)
	{
		document.getElementById('blog_links').innerHTML = html;
	}
}

display.pages = new Array();


var loader = new Image;
loader.src = "/graphics/loader.gif";


display.post_comment = function(id)
{
        formvalid.add("name", "Name", "alphanumeric", 1);
        formvalid.add("email", "Email Address", "email", 1);
        formvalid.add("title", "Title", "alphanumeric", 1);
        formvalid.add("comment", "Comment", "anything", 1);
		
		formvalid.post_vars = new Array();
		formvalid.post_vars['md5'] = escape(document.getElementById('comment_md5').value);
		formvalid.post_vars['name'] = escape(document.getElementById('comment_name').value);
		formvalid.post_vars['email'] = escape(document.getElementById('comment_email').value);
		formvalid.post_vars['title'] = escape(document.getElementById('comment_title').value);
		formvalid.post_vars['comment'] = escape(document.getElementById('comment_msg').value);
		
        formvalid.validate("comment", "ajax.post('/XML/Blog/ID/"+id+"', 'display.write', formvalid.post_vars)");
}
	


display.post_licensed = function()
{
		
		formvalid.add("type", "Subject", "alphanumeric", 0);
        formvalid.add("msg[name]", "Name", "alphanumeric", 1);
        formvalid.add("msg[date_day]", "Birth Date", "numeric", 1);
        formvalid.add("msg[date_month]", "Birth Month", "numeric", 1);
        formvalid.add("msg[date_year]", "Birth Year", "numeric", 1);
		formvalid.add("msg[email]", "Email Address", "email", 1);        
		formvalid.add("msg[phone]", "Phone", "alphanumeric", 0);        
        formvalid.add("msg[resident]", "Residence", "alphanumeric", 0);
		
	formvalid.validate("contact", "ajax.post('/XML/Contact', 'display.post_contact_html', formvalid.vars)");
}


display.post_trainee = function()
{
		
		formvalid.add("type", "Subject", "alphanumeric", 0);
        formvalid.add("msg[name]", "Name", "alphanumeric", 1);
        formvalid.add("msg[date_day]", "Birth Date", "numeric", 1);
        formvalid.add("msg[date_month]", "Birth Month", "numeric", 1);
        formvalid.add("msg[date_year]", "Birth Year", "numeric", 1);
		formvalid.add("msg[email]", "Email Address", "email", 1);
		formvalid.add("msg[phone]", "Phone", "alphanumeric", 0);        
        formvalid.add("msg[resident]", "Residence", "alphanumeric", 0);
		formvalid.add("msg[experience]", "Experience", "alphanumeric", 0);        
        
        formvalid.validate("contact", "ajax.post('/XML/Contact', 'display.post_contact_html', formvalid.vars)");
}

display.post_contact_html = function (html)
{
	if (html)
	{
		document.getElementById('form').innerHTML = html;
	}
	else if (!preload)
	{
		document.getElementById('form').innerHTML = "<div class=\"preloader\" style=\"padding-bottom: 10px; padding-top: 10px\"><img src=\"/graphics/loader.gif\"/><br/>Please wait, sending..</div>";
		var preload = true;
	}
}
