
/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

/* Really IE? You don't know index of? */
if(!Array.indexOf){
  Array.prototype.indexOf = function(obj){
   for(var i=0; i<this.length; i++){
    if(this[i]==obj){
     return i;
    }
   }
   return -1;
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function $get(n, d){
    return MM_findObj(n, d);
}
//popUp div start
var amID = "blank";
function showMe(containerId){
	if(amID != "blank"){
		hideMe(amID);	
	}
	amID = containerId;
	showContainer(containerId);
}
function showContainer(containerId){
	obj = MM_findObj(containerId);
	if (!obj) return;
	obj.style.display = 'block';
}
function hideMe(containerId){
	obj2 = MM_findObj(containerId)
	if (!obj2) return;
	obj2.style.display = 'none';
}
function hideMeOA(){
	hideMe('contentWeUnderstand');
	hideMe('contentCreativeSolutions');
	hideMe('contentPerfectDelivery');
}
//popUp div end
//popUp div start
var amIDNav = "blank";
function showNav(containerId){
	if(amIDNav != "blank"){
		hideMe(amIDNav);
	}
	amIDNav = containerId;
	showContainer(containerId);
	//hideMe('subNavCol');
}
//popUp div end
//find which div to show when the page loads start
function whatToShow(){
	if(window.location.hash == "#weUnderstand"){
		showMe('contentWeUnderstand');
		changeClass('contentWeUnderstandLink');
	}
	if(window.location.hash == "#creativeSolutions"){
		 showMe('contentCreativeSolutions');
		 changeClass('contentCreativeSolutionsLink');
	}
	if(window.location.hash == "#perfectDelivery"){
		showMe('contentPerfectDelivery');
		changeClass('contentPerfectDeliveryLink');
	}
}
function whatToShow2(){
	if(window.location.hash == "#productOverview"){
		showMe('contentProductOverview');
		changeClass('contentProductOverviewLink');
	}
	if(window.location.hash == "#capabilities"){
		 showMe('contentCapabilities');
		 changeClass('contentCapabilitiesLink');
	}
	if(window.location.hash == "#trackRecord"){
		showMe('contentTrackRecord');
		changeClass('contentTrackRecordLink');
	}
}
function whatToShow3(){
	if(window.location.hash == "#contentPurpose"){
		showMe('contentPurpose');
		changeClass('aboutOvationMainLink');
	}
	if(window.location.hash == "#contentInspiration"){
		 showMe('contentInspiration');
		 changeClass('aboutOvationOurInspirationLink');
	}
}
//find which div to show when the page loads end
//change that class then back start
var amClassId = "blank";
function changeClass(Id){
	if(amClassId != "blank"){
		changeBack(amClassId);
	}
	amClassId = Id;
	setClass(Id);
}
function setClass(Id){
	obj = MM_findObj(Id);
	if (!obj) return;
	obj.className = 'active';
}
function changeBack(Id){
	obj2 = MM_findObj(Id)
	if (!obj2) return;
	obj2.className = '';
}
//change that class then back end

function checkReplace(obj, empty){
    if(obj.innerHTML.toLowerCase() == empty.toLowerCase()){
        obj.style.display = "none";
        //more cross browser, IE thinks it's next sibling, Mozilla things is next next
        var hr = obj.nextSibling.tagName == "HR" ? obj.nextSibling : obj.nextSibling.nextSibling;
        hr.style.display = "none";
    }
}
function checkImage(obj, empty){
    if(obj.src == empty)
        obj.style.display = "none";
}
//ewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
function replaceEmpties(imageBase){
    
    checkReplace($get("pPeople"), "<strong>People |</strong> ");
    checkReplace($get("pActors"), "<strong>Actors |</strong> ");
    checkReplace($get("pQuote"), "<strong>Quote |</strong> ");
    checkReplace($get("pPlaces"), "<strong>Places |</strong> ");
    checkReplace($get("pMarks"), "<strong>Lovemarks (brands) |</strong> ");
    checkReplace($get("pBooks"), "<strong>Books |</strong> ");
    checkReplace($get("pMusic"), "<strong>Music |</strong> ");
    checkReplace($get("pArtist"), "<strong>Artist |</strong> ");
    checkReplace($get("pFoods"), "<strong>Foods |</strong> ");
    checkReplace($get("pSports"), "<strong>Sports |</strong> ");
    checkReplace($get("pTeam"), "<strong>Team |</strong> ");
    checkReplace($get("pPersonal"), "<strong>Moment in personal life |</strong> ");
    checkReplace($get("pWorld"), "<strong>Moment in world history |</strong> ");
    checkReplace($get("pRandom"), "<strong>Random thing |</strong> ");
    
    checkImage($get("photo1"), imageBase);
    checkImage($get("photo2"), imageBase);
    checkImage($get("photo3"), imageBase);
}

function firstName(name){
    var indexOfSpace = name.indexOf(" ");
    return name.substr(0, indexOfSpace);
}

function queryString(name){
    var hRef = window.location.href;
    var queryIndex = hRef.indexOf("?");
    
    if(queryIndex == -1)
        throw "URL Contains no Query Strings";           

    var urlQueries = hRef.substr(queryIndex + 1);
    var hashPos    = urlQueries.indexOf("#");
    if(hashPos > -1)
        urlQueries = urlQueries.substr(0, hashPos);
            
    var queryStrings = urlQueries.split("&");
    for(var i = 0; i < queryStrings.length; i++){
        var currentQueryParts = queryStrings[i].split("=");
        if(currentQueryParts[0] == name)
            return currentQueryParts[1];
    }
    throw "URL does not contain Query String" + name;
}

function assignButtons(which, methods){
    var btnPrev = $get("btnPrevious");
    var btnNext = $get("btnNext");        
    
    if(which.indexOf("prev") > -1){
        
        btnPrev.onclick = methods.previous;
    }
    else
        btnPrev.className = "lbutton disabled";
    
    if(which.indexOf("next") > -1){
        btnNext.className = "rbutton";
        btnNext.onclick = methods.next;
    }
    else
        btnNext.className = "rbutton disabled";
}

function assignNextPrevious(idArray){
    
	
    if(idArray.length <= 1){
        assignButtons([]);
        return;
    }
    
    var methods = {};
    var currentId = queryString("id");
    var btnPrev = $get("btnPrevious");
    var btnNext = $get("btnNext");
    
    var currentIndex = idArray.indexOf(currentId);
    
    if(currentIndex == -1){		
		btnPrev.href = "";
		btnNext.href = "";
	}
    else if(currentIndex == 0){        
        btnNext.href = window.location.href.replace(currentId, idArray[1]);
        btnNext.className = "rbutton";
		//btnPrev.href = "javascript:";
    }
    else if(currentIndex + 1 == idArray.length){
        btnPrev.href = window.location.href.replace(currentId, idArray[currentIndex - 1]);
        btnPrev.className = "lbutton";
		//btnNext.href = "";
    }
    else{
        btnNext.href = window.location.href.replace(currentId, idArray[currentIndex + 1]);
        btnNext.className = "rbutton";
        btnPrev.href = window.location.href.replace(currentId, idArray[currentIndex - 1]);
        btnPrev.className = "lbutton";
    }
}

function turnMonth(month){
    switch(month){
        case 0 : return 'Janurary';
        case 1 : return 'Feburary';
        case 2 : return 'March';
        case 3 : return 'April';
        case 4 : return 'May';
        case 5 : return 'June';
        case 6 : return 'July';
        case 7 : return 'Augest';
        case 8 : return 'September';
        case 9: return 'October';
        case 10: return 'November';
        case 11: return 'December';
    }
}
function getArticleDate(date){
    var indexOfSpace = date.indexOf(' ');
    var date = date.substr(0, indexOfSpace);
    var dateParts = date.split("/");
    var date = dateParts[1] + "/" + dateParts[0] + "/" + dateParts[2];
    
    var curDate = new Date(date);    
        
    return turnMonth(curDate.getMonth()) + " " + (curDate.getFullYear());
}
function getJobIndexDate(date){
    var curDate = new Date(date);
    
    return curDate.getDay() + "." + curDate.getMonth() + "." + curDate.getFullYear();
}
//caseStudies popup image
function showPopup(largeImageSurrId){    
	obj = MM_findObj(largeImageSurrId);
	if (!obj) return;
	obj.style.display = 'block';
	/*obj2 = MM_findObj(largeImageId);
	obj2.src = largeImageURL;*/
}
function hidePopup(largeImageSurrId){
	obj = MM_findObj(largeImageSurrId);
	if (!obj) return;
	obj.style.display = 'none';
}






