window.name = "main_win";

//ROLLOVER IMAGE IDs
var rollover_id = new Array;
rollover_id.push('nav_whatwedo, 96, 25');
rollover_id.push('nav_whoweare, 89, 25');
rollover_id.push('nav_casestudies, 95, 25');
rollover_id.push('nav_events, 63, 25');
rollover_id.push('nav_clients, 66, 25');
rollover_id.push('nav_media, 51, 25');
rollover_id.push('nav_newsletter, 140, 40');
rollover_id.push('nav_contact, 140, 40');

//IMAGES PATH
var img_path = "/images/";

//CREATES ROLLOVER EFFECTS AND PRELOADS UPON PAGE LOAD
window.onload = function()
{
	the_location_temp = new String(window.location);
	the_location = the_location_temp.split("/");
	the_nav_on = the_location[3];
	
	for(i = 0; i < rollover_id.length; i++)
	{
		var img_specs = rollover_id[i].split(",");
		if(img_specs[0] == "nav_" + the_location[3])
		{
			rollover_id.splice(i, 1);
		}
	}
	
	for(i = 0; i < rollover_id.length; i++)
	{
		var img_specs = rollover_id[i].split(",");
		var file_ext_temp = document.images[img_specs[0]].src.split(".");
		var file_ext = file_ext_temp[file_ext_temp.length - 1]
		
		//creates rollover events
		document.images[img_specs[0]].onmouseover = function()
	  {
		  swap_image(this.id, this.id + '_ro.' + file_ext);
	  }
		
		//creates rollout events
		document.images[img_specs[0]].onmouseout = function()
	  {
		  swap_image(this.id, this.id + '.' + file_ext);
	  }
		
		//preloads rollover image
		var temp_name = 'pic' + i;
    temp_name = new Image(img_specs[1],img_specs[2]); 
    temp_name.src = img_path + this.id + '_ro.' + file_ext;
	}
	
	  //checks to see if this is the page we are on and swaps for rolloever
		if(the_nav_on.indexOf(the_nav_on) != -1)
		{
			if(the_location[3] != "")
			{
				swap_image("nav_" + the_location[3], "nav_" + the_location[3] + '_ro.' + file_ext);
			}
		}
}

function swap_image(the_id, the_src)
{
	document.images[the_id].src = img_path + the_src;
}

//gets year for copyright
var today = new Date();
var current_year = today.getFullYear();

//--- OPEN AND RESIZE WINDOW ---//
function openWindow(websiteAddress, newWindowName, desiredWidth, desiredHeight, isResizeable)
{
	var height = window.screen.availHeight;
	var width = window.screen.availWidth;
	var leftPoint = parseInt(width / 2) - parseInt(desiredWidth / 2);
	var topPoint = parseInt(height / 2) - parseInt(desiredHeight / 2);
	
	windowOptions = "width=" + desiredWidth + ", height=" + desiredHeight + ", " + "menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=" + isResizeable + ", top=" + topPoint + ", left=" + leftPoint;
	new_window = window.open(websiteAddress, newWindowName, windowOptions);
	
	new_window.focus();
}



