var newsbaron = true;
var newstoggle;

//jquery
$(document).ready(function(){
    
	//image rollover script
	attachRollOverEvent = function(imageId){
		$(imageId).mouseover( function(){ $(this).attr("src", $(this).attr("src").split('.gif').join('-mo.gif')) } );
		$(imageId).mouseout( function(){ $(this).attr("src", $(this).attr("src").split('-mo.gif').join('.gif')) } );
	}
	attachRollOverEvent("img.rollover");

	//function to hide all submenus
	function hideall() {
		$("#submenu_services").hide();
		$("#submenu_work").hide();
		$("#submenu_people").hide();
	}
		
	//nav menu services
	$("#a_services").bind("mouseenter",function(){
		hideall();
		$("#submenu_services").show();
    });
	$("#a_services").bind("mouseleave",function(){
		$("#submenu_services").hide();
    });
	$("#submenu_services").hide();

	//nav menu ourwork
	
	/*--
	$("#a_work").bind("mouseenter",function(){
		hideall();
		$("#submenu_work").show();
    });
	$("#a_work").bind("mouseleave",function(){
		$("#submenu_work").hide();
    });
	$("#submenu_work").hide();
	
	$("#a_industry").bind("mouseenter",function(){
		$("#submenu_industry").show();
    });
	$("#a_industry").bind("mouseleave",function(){
		$("#submenu_industry").hide();
    });
	$("#submenu_industry").hide();
	--*/
	
	//nav menu people
	$("#a_people").bind("mouseenter",function(){
		hideall();
		$("#submenu_people").show();
    });
	$("#a_people").bind("mouseleave",function(){
		$("#submenu_people").hide();
    });
	$("#submenu_people").hide();
	
	
	//back button for project pages
	$("#backtoworklisting").click(function() {
		if (history.length==1) {
			window.location.href="";
		} else {
			window.history.back();
		}
	});
	
	

});


//function defined to preload images
jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) jQuery("<img>").attr("src", arguments[i]);
}

//function to get query variable;
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}

//function news hide / show / toggle
function newstoggle() {
	if (newsbaron) {
		$('#newscontrol').css("backgroundPosition","0px -15px");
		$('#a_newsbar').text("more updates");
		newsbaron = false;
	} else {
		$('#newscontrol').css("backgroundPosition","0px 0px");
		$('#a_newsbar').text("hide updates");
		newsbaron = true;
	}
}
function news_close() {
	newsbaron = true;
	newstoggle();
	$('#newsbar').hide();
}
function news_launch() {
	newsbaron = false;
	newstoggle();
	$('#newsbar').slideOut('normal');
}	

