$(function(){
	 var divider = false;
				
				//set current page
				
				$("#global_nav img").each(function(){
												  if($(this).attr('alt') =='current')
												  {
														var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-4);
														var imgSrc = srcArray+"_over"+".jpg";
														$(this).attr("src",imgSrc);
												  }
												}
										 )
				
				
				// implment mouse out and mouse over effect on 
				$("#global_nav img").mouseover(function(){
														
															if($(this).attr('src') !='images/nav_divider.jpg' && $(this).attr('alt')!='current') // divider
															{
																
																var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-4);
																var imgSrc = srcArray+"_over"+".jpg";
														
																
																$(this).attr("src",imgSrc);
															}
												})
				 										 
				 
				   
				  $("#global_nav img").mouseout(function(){
														
														 
														 if($(this).attr('src') !='images/nav_divider.jpg' && $(this).attr('alt')!='current') // divider
														 {
																
																
																var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-9);
																var imgSrc = srcArray+".jpg"
																
																
																$(this).attr("src",imgSrc);
																
														 }
												})




				// set service menu control
				
				
					
				$("#services_nav img").each(function(){
												  if($(this).attr('alt') =='current')
												  {
														var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-4);
														var imgSrc = srcArray+"_over"+".jpg";
														$(this).attr("src",imgSrc);
												  }
												}
										 )
				
				
				// implment mouse out and mouse over effect on 
				$("#services_nav img").mouseover(function(){
														
				if($(this).attr('src') !='images/nav_services_blue_hdr.jpg' && $(this).attr('src') !='images/nav_services_blue_bottom.jpg' && $(this).attr('alt')!='current') // divider
															{
																
																var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-4);
																var imgSrc = srcArray+"_over"+".jpg";
														
																
																$(this).attr("src",imgSrc);
															}
												})
				 										 
				 
				   
				  $("#services_nav img").mouseout(function(){
														
														 
				if($(this).attr('src') !='images/nav_services_blue_hdr.jpg' && $(this).attr('src') !='images/nav_services_blue_bottom.jpg' && $(this).attr('alt')!='current') // divider
														 {
																
																
																var srcArray = $(this).attr('src').substring(0,$(this).attr('src').length-9);
																var imgSrc = srcArray+".jpg"
																
																
																$(this).attr("src",imgSrc);
																
														 }
												})



})

function showLoginOpportunity(type,obj)
{
	if(type =='show')
	{			
			// set up the image
			//$('#popupImage').attr('src','images/'+img)
		var position = getObjPosition(obj);
		position.x = position.x-130;
		position.y = position.y+10;
	
	$('#loginContainer').css('top',position.y+"px").css('left',position.x+"px");
		
		
		$('#loginContainer').show('slow');
		
	}
	if(type=='hide')
	{
		$('#loginContainer').hide('slow');
	}
}

function getObjPosition(e)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
		
		
		
	return {x:posx,y:posy}

}

function login()
{
	if($('#username').val()=='' || $('#password').val()=='')
	{
		$("#err_msg").html("Invalid username or password");
		return;
	}
	
	$.post("login.php",{username:$("#username").val(),password:$("#password").val()},function(data){
		
			
			if(data.trim() =='pass')
			window.location = "http://www.intergroupfacility.com/customer/clients/main.php" 
			else
			$("#err_msg").html("Invalid username or password");
	
	})
	
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

