
// CSS  HELLLO
if (client.engine == 'msie')   { document.writeln('<link href="css/msie.css"   rel="stylesheet" type="text/css" media="all" />'); }
if (client.os == 'mac')        { document.writeln('<link href="css/mac.css"    rel="stylesheet" type="text/css" media="all" />'); }
if (client.engine == 'webkit') { document.writeln('<link href="css/webkit.css" rel="stylesheet" type="text/css" media="all" />'); }
//

function init(){ // initialization function, called from body onload event

			
			var arr = $('OgilvyDigitalInnovation1572464').getElementsByClassName('headline');
			
			for (i=0;i<arr.length;i++) {
			
				arr[i].getElementsByTagName('a')[0].href = 'http://innovation.ogilvy.com/';
				
				var today = new Date()
				var month = today.getMonth() + 1
				var day = today.getDate()
				var year = new String() 
				year = today.getFullYear().toString()
				var s = "/"
				
				
				arr[i].innerHTML = arr[i].innerHTML + " - " + month + s + day + s + year.substring(2) + "";
				
			}
			
}


function ron(x){
	
	document.images[x].src = eval('nav_' +x+ '_on.src');
}

function roff(x){
	document.images[x].src = eval('nav_' +x+ '.src');
}


var nav_home = new Image();
nav_home.src = "images/nav_btn_home.gif";
var nav_home_on = new Image();
nav_home_on.src = "images/nav_btn_home-over.gif";

var nav_whatisverge = new Image();
nav_whatisverge.src = "images/nav_btn_whatisverge.gif";
var nav_whatisverge_on = new Image();
nav_whatisverge_on.src = "images/nav_btn_whatisverge-over.gif";

var nav_whospeaks = new Image();
nav_whospeaks.src = "images/nav_btn_whospeaks.gif";
var nav_whospeaks_on = new Image();
nav_whospeaks_on.src = "images/nav_btn_whospeaks-over.gif";

var nav_vergeworldwide = new Image();
nav_vergeworldwide.src = "images/nav_btn_vergeworldwide.gif";
var nav_vergeworldwide_on = new Image();
nav_vergeworldwide_on.src = "images/nav_btn_vergeworldwide-over.gif";

var nav_verge2008 = new Image();
nav_verge2008.src = "images/nav_btn_verge2008.gif";
var nav_verge2008_on = new Image();
nav_verge2008_on.src = "images/nav_btn_verge2008-over.gif";


var nav_contact = new Image();
nav_contact.src = "images/nav_contact.gif";
var nav_contact_on = new Image();
nav_contact_on.src = "images/nav_contact-over.gif";

var nav_glossary = new Image();
nav_glossary.src = "images/nav_glossary.gif";
var nav_glossary_on = new Image();
nav_glossary_on.src = "images/nav_glossary-over.gif";



///////////////////////////////////////////////////////////////////////////



function trackPage() {
	// handle atlas tracking
		if (typeof(atlasTrackUrl) != 'undefined') {
			var atlasTrackPixel                  = document.createElement('iframe');
				atlasTrackPixel.style.width      = atlasTrackPixel.style.height = '1px';
				atlasTrackPixel.style.visibility = 'hidden';
				atlasTrackPixel                  = document.body.appendChild(atlasTrackPixel);
				atlasTrackPixel.src              = atlasTrackUrl;
		}
	// handle google tracking
		if (typeof(_uacct)            != 'undefined' &&
			typeof(_udn)              != 'undefined' &&
			typeof(_ulink)            != 'undefined' &&
			typeof(urchinTracker_arg) != 'undefined' &&
			typeof(urchinTracker)     != 'undefined'   )
		{ urchinTracker(urchinTracker_arg); }
}

//===============[ cookie handling ]================================================//

function bakeCookie(name, days){ //writes a cookie once the site is viewed
	var date = new Date();
	if(!days) days = 30;
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "expires=" + date.toGMTString();
	document.cookie = name + "=?viewed=1; " + expires + "; path=/"; // viewed=1 is a parameter flash looks for to either show an intro or not
}
function eatCookie(name){ // read cookie and return the first parameter it finds, has to be viewed=1 or viewed=0
	var ArrCookies = document.cookie.split(';');
	for(var i = 0; i<ArrCookies.length; i++){
		if(ArrCookies[i].indexOf(name) != -1){
			ArrCookies[i] = leftTrim(ArrCookies[i]);
			return ArrCookies[i].substring(name.length+1, ArrCookies[i].length);
		}
	}
	return "";
}
function trashCookie(name){	bakeCookie(name,-1); } // deletes the cookie

//===============[ insert flash ]=====================================================//

function loadFlash(arg){ //uses swfHandler.js to load flash
	if(arg == 1){ //loads front page intro
		//var intro = eatCookie('flashintro');
		var myMovie = swf.movie('shell.swf', 950, 480, 7, getObj('noswf').cloneNode(true));
		myMovie.setParam('wmode','opaque');
		myMovie.setParam('bgcolor','#000000');
		myMovie = getObj("swfBody").appendChild(myMovie);
	}

}
function loadFlashMovie(){
	getObj('swfBodyToBe').style.visibility = 'hidden';
	var placeholder = document.createElement('DIV');
	placeholder.style.display = 'none';
	placeholder.id = 'placeholder';
	placeholder.innerHTML = getObj('swfBodyToBe').innerHTML;
	document.body.appendChild(placeholder);
	getObj('swfBodyToBe').innerHTML = '';
	getObj('swfBodyToBe').className = 'innerBlack';

	var myMovie = swf.movie('flash/video3.swf', 400, 300, 7, getObj('noswf'));
	myMovie.setParam('bgcolor','#000000');
	myMovie.setParam('width','400');
	myMovie.setParam('height','300');
	myMovie = getObj("swfBodyToBe").appendChild(myMovie);
	setTimeout("getObj('swfBodyToBe').style.visibility = 'visible'", 100);
}
//===============[ general utilities ]================================================//

function getObj(name){ // returns an object with a specified id tag (name)
	if(document.getElementById) this.obj = document.getElementById(name);
	else if(document.all) this.obj = document.all[name];
	return this.obj;
}
function getElementsByClass(val){ // returns an array of objects with specified class name (val)
	var all = document.all || document.getElementsByTagName('*');
	var arr = [];
	for(var k = 0; k < all.length; k++)
		if(all[k].className == val) arr[arr.length] = all[k];
	return arr;
}
function realPreviousSibling(node){ // returns previous sibling of an object (node), cross-browser
	var t = node.previousSibling;
	while(t.nodeType != 1) t = t.previousSibling;
	return t;
}
function realFirstChild(node){ // returns first child node of an object (node), cross-browser
	var t = node.childNodes;
	if(document.all) return t[0];
	else return t[1];
}
function leftTrim(s){ // trims off whitespaces from a string
	while (s.substring(0,1) == ' ') s = s.substring(1, s.length); return s;
}

function showPage(num){ // 
	getObj("page" + curr_page).style.display = "none";
	getObj("page" + num).style.display = "block";
	curr_page = num;
}
function prepPrint(){ // loads a css file for print version of the page
	document.writeln('<link href="/css/print.css" rel="stylesheet" type="text/css" media="all" />');
	version = "print";
}

// create menu click handler function
function menuClick(thisObj) {
	var thisValue = thisObj.getAttribute('value');
	if (thisValue.indexOf('javascript:') == 0) {
		eval(thisValue.split('javascript:')[1])
	} else {
		document.location.href = thisValue;
	}
}

//===============[ Flash functions ]========================================================//
function closeFlash(){
	getObj('swfBodyToBe').className = 'inner';
	getObj('swfBodyToBe').innerHTML = getObj('placeholder').innerHTML;
}

