
// Because IE is lame
$(document).ready(function() {
 $('.category_title').mousedown(function(){$(this).addClass('category_title_active');});
 $('.category_title').mouseup(function(){$(this).removeClass('category_title_active');});
 //$('.see_more').mousedown(function(){$(this).addClass('see_more_active');});
 //$('.see_more').mouseup(function(){$(this).removeClass('see_more_active');});
 $('.see_more').mousedown(function(){$(this).attr('src','/images/see_more_hover.png');});
 $('.see_more').mouseup(function(){$(this).attr('src','/images/see_more.png');});
 //$('.back_button').mousedown(function(){$(this).attr('src','/images/back_button_hover.png');});
 //$('.back_button').mouseup(function(){$(this).attr('src','/images/back_button_hover.png');});
 //$('.back_button').mousedown(function(){$(this).addClass('back_button_active');});
 //$('.back_button').mouseup(function(){$(this).removeClass('back_button_active');});
 //$('.read_more').mousedown(function(){$(this).addClass('read_more_active');});
 //$('.read_more').mouseup(function(){$(this).removeClass('read_more_active');});
 
 // $('#gallery_arrow_left').hide();
	if(count == 1)
	{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		
		//document.getElementById('map_arrow_left').style.display = 'none';
		//$('#map_arrow_right').hide();
		
		return;
	}
	else if(count == 2)
	{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		//document.getElementById('map_arrow_left').style.display = 'none';
		//$('#map_arrow_right').hide();
		return;
	}
	else if(count == 3)
	{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		//document.getElementById('map_arrow_left').style.display = 'none';
		//$('#map_arrow_right').hide();
		
		return;
	}
	 
 // var div_node = document.getElementById('gallery_arrow_left');
 // div_node.id = 'gallery_arrow_left_hide';
 
	window.searchBoxFn = function(){
		$(this).removeClass('temp').val('').unbind('focus change', window.searchBoxFn);
	};
	$('form.search .text').each(function(){
		var me = $(this);
		if ( me.val() == '' ) {
			me.addClass('temp');
			me.val('Please enter minimum of 3 characters');
		}
	
		me.bind('focus change', window.searchBoxFn);
	
	
	
	
	});
 });
function clean(what)
{
	if(what.value == what.title)
	{
		what.value = "";
		what.style.color="black";
	}
}
function scroll_left(what,distance)
{
	scroll_stuff('left',what,distance);
}
function scroll_right(what,distance)
{
	scroll_stuff('right',what,distance);
	//alert(speed);
}

var currentPosition = null;
var currentPosition1 = 8;


function scroll_stuff(dir,what,distance)
{
	if (typeof count !== "undefined" && count)
	{
		speed = 316;
		if(distance)
		{
			speed=distance;
		}
		speed2 = 600;
		obj = $('#'+what);
		if(dir=="left")
		{
			$('#'+what).scrollTo( {top:'-=0px', left:'-='+speed}, 400 );
			currentPosition = currentPosition-1;
					
		}
		else
		{
			$('#'+what).scrollTo( {top:'-=0px', left:'+='+speed}, 400 );
			currentPosition = currentPosition+1;
			//$('#'+what).scrollTo({left:'+=316px'},400);
		}
		if(count == 1)
		{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		exit;
		}
		else if(count == 2)
		{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		exit;
		}
		else if(count == 3)
		{
		document.getElementById('gallery_arrow_left').style.display = 'none';
		$('#gallery_arrow_right').hide();
		
		exit;
		}
		if(currentPosition <= 0)
		{
			// $('#gallery_arrow_left').hide();
			var div_node = document.getElementById('gallery_arrow_left');
			if(div_node != null){
				// div_node.id = 'gallery_arrow_left_hide';
				document.getElementById('gallery_arrow_left').style.display = 'none';
				document.getElementById('gallery_arrow_left_hide').style.display = 'block';
			}
			
		}
		else
		{
			// $('#gallery_arrow_left').show();
			var div_node = document.getElementById('gallery_arrow_left_hide');
			if(div_node != null){
				// div_node.id = 'gallery_arrow_left';
				document.getElementById('gallery_arrow_left').style.display = 'block';
				document.getElementById('gallery_arrow_left_hide').style.display = 'none';
			}
			
		}
		
		if(currentPosition == count-3)
		{
			$('#gallery_arrow_right').hide();	
		}
		else
		{
			$('#gallery_arrow_right').show();	
		}
	
	}else{
		if (pcount>20)
		{   speed = 316;
			if(distance)
			{
				speed=distance;
			}
			speed2 = 600;
			obj = $('#'+what);
			if(dir=="left")
			{
				$('#'+what).scrollTo( {top:'-=0px', left:'-='+speed}, 400 );
				if(distance != "99999")
				{
					currentPosition1 = currentPosition1-8;
				}else{
					currentPosition1 = 8;
				}
				
			}
			else
			{
				$('#'+what).scrollTo( {top:'-=0px', left:'+='+speed}, 400 );
				currentPosition1 = currentPosition1+8;
				//$('#'+what).scrollTo({left:'+=316px'},400);
			}
			
			if(currentPosition1 <= 8)
			{
				
				var div_node1 = document.getElementById('map_arrow_left');
				if(div_node1 != null){
					// div_node.id = 'gallery_arrow_left_hide';
					document.getElementById('map_arrow_left').style.display = 'none';
					document.getElementById('map_arrow_left_hide').style.display = 'block';
				}
			}
			else
			{
				var div_node1 = document.getElementById('map_arrow_left_hide');
				if(div_node1 != null){
					// div_node.id = 'gallery_arrow_left';
					document.getElementById('map_arrow_left').style.display = 'block';
					document.getElementById('map_arrow_left_hide').style.display = 'none';
				}
			}
			
			var p1 = pcount-12;
			
			if(currentPosition1 > p1 && currentPosition1<(p1+8))
			{
				$('#map_arrow_right').hide();
			}
			else
			{
				$('#map_arrow_right').show();	
			}
		}
	}

}
function set_thumb(src)
{
	$('#image_display').attr("src",src);
}
function products()
{
	hide_all_menus();
	$('#product_menu').show().css("z-index","102");;
}
function hide_products()
{
	$('#product_menu').hide().css("z-index","-1");;
}
function show_options(what)
{
	$('.product_menu_subcategory').hide().css("z-index","-1");
	$('#submenu'+what).show().css("z-index","102");
}
function company()
{
	hide_all_menus();
	$('#company_menu').show().css("z-index","102");;
}
function hide_company()
{
	$('#company_menu').hide().css("z-index","-1");;
}
function services()
{
	hide_all_menus();
	$('#services_menu').show().css("z-index","102");;
}
function hide_services()
{
	$('#services_menu').hide().css("z-index","-1");;
}

function projects()
{
	hide_all_menus();
	$('#projects_menu').show().css("z-index","102");;
}
function hide_projects()
{
	$('#projects_menu').hide().css("z-index","-1");;
}

function hide_all_menus()
{
	hide_services();
	hide_products();
	hide_company();
	hide_projects();
}
