$(document).ready(function(){

	$('div#left_column ul li a').click(function(){
		$('div#left_column ul li a').removeClass('active_sub');
		$(this).addClass('active_sub');
	});
	
	$('div#left_column ul li a#all').addClass('active_sub');
	
	
	 // Default Form Values
				
				$("#login input:text, #login input:password").focus(function() {
					defaultval = $(this).attr("value");
					this.value = '';
				});
				$("#login input:text, #login input:password").blur(function() {
					if (this.value == '') {
						this.value = defaultval;
					}
				});
});

function define_links(link_id){
	var className = 'a.' + link_id;
	
	if(link_id == 'all'){
		$('div.links_list a').removeClass('deactivated');
	} else {
		$('div.links_list a').addClass('deactivated');
		
		if($('div.links_list a').hasClass(link_id)){
			$(className).removeClass('deactivated');
		}
		
		$('div.links_list a.deactivated').click(function(){
			return false;							   
		});
	}
}

function fadeIn(div, link_id){
	var obj = document.getElementById('black_bg');
	var idName = '#' + link_id;
	
	if($(idName).hasClass('deactivated')){
		return false;
	} else {
		obj.style.display = 'block';
		obj.style.height = '1045px';
		obj = document.getElementById(div);
		obj.style.top = 50 + scrollOffset() + 'px';
		$('div#black_bg').fadeTo('slow', 0.8);
		setTimeout('showDiv("' + div + '")', 1000);
	}
}

function fadeOut(div){
	var obj = document.getElementById(div);
	
	obj.style.display = 'none';
	$('div#black_bg').fadeTo('slow', 0.05);
	$('div#black_bg').fadeOut('slow', function(){
		obj = document.getElementById('black_bg');
		obj.style.height = '0px';
   	    obj.style.display = 'none';
	});
}

function showDiv(div){
	var obj = document.getElementById(div);
	
	obj.style.display = 'block';
	setTimeout('setBgsize()', 500);
}

function setBgsize(){
	var obj = document.getElementById('black_bg');
	
	obj.style.height = '1085px';
}

function sizes(type){
	if( window.innerHeight && window.scrollMaxY ){ // Firefox
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else {
		if( document.body.scrollHeight > document.body.offsetHeight ){ // all but Explorer Mac
			pageWidth = document.body.scrollWidth;
			pageHeight = document.body.scrollHeight;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari 
			pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		    pageHeight = document.body.offsetHeight + document.body.offsetTop; 
		}
	}
	
	if(type==0)
		return pageWidth;
	else
		return pageHeight;
}

function scrollOffset(){
	var x,y;
	
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body){ // all other Explorers
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}	
	
	return y;
}

function loadAJAX(pageUrl, link_id){
	$.ajax({
		url: 'directory/' + pageUrl + '.php',
		success: function(msg){
			document.getElementById('ajax_container').innerHTML = msg;
			fadeIn('popup_1', link_id);
		}
	});
}
