
/*
Script Name: Full Featured Javascript Browser/OS detection
Authors: Harald Hope, Tapio Markula, Websites: http://techpatterns.com/
http://www.nic.fi/~tapio1/Teaching/index1.php3
Script Source URI: http://techpatterns.com/downloads/javascript_browser_detection.php
Version 4.2.4
Copyright (C) 29 June 2007

This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt

Coding conventions:
http://cvs.sourceforge.net/viewcvs.py/phpbb/phpBB2/docs/codingstandards.htm?rev=1.3
*/

/*************************************************************
Full version, use it if you are pushing css to its functional limits, and/or are using 
specialized javascript.

Remember, always use method or object testing as your first choice, for example, if ( dom ) { statement; };

This browser detection includes all possibilities I think for most browsers.
Let me know if you find an error or a failure to properly detect, or if there
is a relevant browser that has special needs for detection at our tech forum:
http://techpatterns.com/forums/forum-11.html
The main script is separated from the initial netscape 4 detection due to certain bugs in
netscape 4 when it comes to unknown things like d.getElementById. The variable declarations
of course are made first to make sure that all the variables are global through the page, 
otherwise a javascript error will occur because you are trying to use an undeclared variable.

We test for both browser type (ie, op, or moz/netscape > 6) and version number, then place 
the version number into a variable which can be tested for < or > values, such as 
if (moz && nu> 1.1){....statement....;}
This seems quite reliable, especially for Opera and Mozilla, where there is no other
easy way to get the actual version number.

For more in depth discussion of css and browser issues go to:
http://www.nic.fi/~tapio1/Teaching/DynamicMenusb.php#detections
http://www.nic.fi/~tapio1/Teaching/FAQ.php3

***************************************************************/
//initialization, browser, os detection
var d, dom, nu = '', brow = '', ie, ie4, ie5, ie5x, ie6, ie7, ie8;
var ns4, moz, moz_rv_sub, release_date = '', moz_brow, moz_brow_nu = '', moz_brow_nu_sub = '', rv_full = '';
var mac, win, old, lin, ie5mac, ie5xwin, konq, saf, op, op4, op5, op6, op7;

d = document;
n = navigator;
nav = n.appVersion;
nan = n.appName;
nua = n.userAgent;
old = (nav.substring(0, 1) < 4);
mac = (nav.indexOf('Mac') != -1);
win = (((nav.indexOf('Win') != -1) || (nav.indexOf('NT') != -1)) && !mac) ? true : false;
lin = (nua.indexOf('Linux') != -1);
// begin primary dom/ns4 test
// this is the most important test on the page
if (!document.layers) {
    dom = (d.getElementById) ? d.getElementById : false;
}
else {
    dom = false;
    ns4 = true; // only netscape 4 supports document layers
}
// end main dom/ns4 test

op = (nua.indexOf('Opera') != -1);
saf = (nua.indexOf('Safari') != -1);
konq = (!saf && (nua.indexOf('Konqueror') != -1)) ? true : false;
moz = ((!saf && !konq) && (nua.indexOf('Gecko') != -1)) ? true : false;
ie = ((nua.indexOf('MSIE') != -1) && !op);
if (op) {
    str_pos = nua.indexOf('Opera');
    nu = nua.substr((str_pos + 6), 4);
    brow = 'Opera';
}
else if (saf) {
    str_pos = nua.indexOf('Safari');
    nu = nua.substr((str_pos + 7), 5);
    brow = 'Safari';
}
else if (konq) {
    str_pos = nua.indexOf('Konqueror');
    nu = nua.substr((str_pos + 10), 3);
    brow = 'Konqueror';
}
// this part is complicated a bit, don't mess with it unless you understand regular expressions
// note, for most comparisons that are practical, compare the 3 digit rv nubmer, that is the output
// placed into 'nu'.
else if (moz) {
    // regular expression pattern that will be used to extract main version/rv numbers
    pattern = /[(); \n]/;
    // moz type array, add to this if you need to
    moz_types = new Array('Firebird', 'Phoenix', 'Firefox', 'Iceweasel', 'Galeon', 'K-Meleon', 'Camino', 'Epiphany', 'Netscape6', 'Netscape', 'MultiZilla', 'Gecko Debian', 'rv');
    rv_pos = nua.indexOf('rv'); // find 'rv' position in nua string
    rv_full = nua.substr(rv_pos + 3, 6); // cut out maximum size it can be, eg: 1.8a2, 1.0.0 etc
    // search for occurance of any of characters in pattern, if found get position of that character
    rv_slice = (rv_full.search(pattern) != -1) ? rv_full.search(pattern) : '';
    //check to make sure there was a result, if not do  nothing
    // otherwise slice out the part that you want if there is a slice position
    (rv_slice) ? rv_full = rv_full.substr(0, rv_slice) : '';
    // this is the working id number, 3 digits, you'd use this for 
    // number comparison, like if nu >= 1.3 do something
    nu = rv_full.substr(0, 3);
    for (i = 0; i < moz_types.length; i++) {
        if (nua.indexOf(moz_types[i]) != -1) {
            moz_brow = moz_types[i];
            break;
        }
    }
    if (moz_brow)// if it was found in the array
    {
        str_pos = nua.indexOf(moz_brow); // extract string position
        moz_brow_nu = nua.substr((str_pos + moz_brow.length + 1), 3); // slice out working number, 3 digit
        // if you got it, use it, else use nu
        moz_brow_nu = (isNaN(moz_brow_nu)) ? moz_brow_nu = nu : moz_brow_nu;
        moz_brow_nu_sub = nua.substr((str_pos + moz_brow.length + 1), 8);
        // this makes sure that it's only the id number
        sub_nu_slice = (moz_brow_nu_sub.search(pattern) != -1) ? moz_brow_nu_sub.search(pattern) : '';
        //check to make sure there was a result, if not do  nothing
        (sub_nu_slice) ? moz_brow_nu_sub = moz_brow_nu_sub.substr(0, sub_nu_slice) : '';
    }
    if (moz_brow == 'Netscape6') {
        moz_brow = 'Netscape';
    }
    else if (moz_brow == 'rv' || moz_brow == '')// default value if no other gecko name fit
    {
        moz_brow = 'Mozilla';
    }
    if (!moz_brow_nu)// use rv number if nothing else is available
    {
        moz_brow_nu = nu;
        moz_brow_nu_sub = nu;
    }
    if (n.productSub) {
        release_date = n.productSub;
    }
}
else if (ie) {
    str_pos = nua.indexOf('MSIE');
    nu = nua.substr((str_pos + 5), 3);
    brow = 'Microsoft Internet Explorer';
}
// default to navigator app name
else {
    brow = nan;
}
op5 = (op && (nu.substring(0, 1) == 5));
op6 = (op && (nu.substring(0, 1) == 6));
op7 = (op && (nu.substring(0, 1) == 7));
op8 = (op && (nu.substring(0, 1) == 8));
op9 = (op && (nu.substring(0, 1) == 9));
ie4 = (ie && !dom);
ie5 = (ie && (nu.substring(0, 1) == 5));
ie6 = (ie && (nu.substring(0, 1) == 6));
ie7 = (ie && (nu.substring(0, 1) == 7));
ie8 = (ie && (nu.substring(0, 1) == 8));
// default to get number from navigator app version.
if (!nu) {
    nu = nav.substring(0, 1);
}
/*ie5x tests only for functionavlity. dom or ie5x would be default settings. 
Opera will register true in this test if set to identify as IE 5*/
ie5x = (d.all && dom);
ie5mac = (mac && ie5);
ie5xwin = (win && ie5x);

/********************************************************
here is a sample use of the browser detector, it would load a browser specific stylesheet
for certain unsupported or improperly supported mac ie 5 css styles. The depth variable
is used so that the javascript library file can be used from anywhere in the website, you simply
insert the depth of the file like this, 
...
<head>
<title>Browser information Page</title>

<meta http-equiv = "Content-Type" content = "text/html; charset = iso-8859-1" />
<link rel = "stylesheet" type = "text/css" href = "css/main.css" />
<script type = "text/javascript" src = "/js/browser_detection.js"> </script>
<script type = "text/javascript>browser_css( ); </script>
</head>

in the head of the web page after the js file is loaded.
Or if you are always referring your site to the root, you wouldn't need that
and could delete the depth variable and just use the absolute path to the root.

function browser_css( ) {
d = document;
if ( ie5mac ) {
d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ie5mac.css" />');
}
else if ( document.layers ){
d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ns4x.css" />');
}
else if ( ie4 ){
d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/ie4.css" />');
}
else if ( moz && ( nu < 1 ) ){
d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/moz_pre1-0.css" />');
}
else {
d.write('<link rel = "stylesheet" type = "text\/css" href = "/css/moz5.css" />');
}
}
********************************************************/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//shows/hides an id
function showhide(myId) {
	if (document.getElementById) {
		var state = document.getElementById(myId).style.visibility;
		if (state == 'visible') {
			hideId(myId);
			//return false;
		} else {
			showId(myId);
			//return false;
		}
	} else {
		;//return true;
	}
}

//hides an id
function hideId(myId) {
	if (document.getElementById) {
		document.getElementById(myId).style.visibility = 'hidden';
		if (myId == "searchPopup") setCookie("searchWinVis", "hidden", 1);
	}
}

//shows an id
function showId(myId) {
	if (document.getElementById) {
		document.getElementById(myId).style.visibility = 'visible';
	}
}



function showText1(whichSection, whichHeading, whichOne, doPointer) {
    if (doPointer) document.getElementById("pointerImage").className = pointerPositionArray[whichOne];
	var index;
	for (var i=0; i<elementsArray.length; i++) {
		if (elementsIdsArray[i].indexOf(whichSection + "-") == 0) elementsArray[i].style.visibility = 'hidden';
		if (elementsIdsArray[i] == (whichSection + "-" + whichHeading)) index = i;
	}
	elementsArray[index].style.visibility = 'visible';
}

var clientNumsArray = [];
clientNumsArray[0] = "";
clientNumsArray[1] = "1";
clientNumsArray[2] = "2";
clientNumsArray[3] = "3";
clientNumsArray[4] = "4";

function showText(whichOne) {
	
	document.getElementById("block1").style.visibility = 'hidden';
	document.getElementById("block2").style.visibility = 'hidden';
	document.getElementById("block3").style.visibility = 'hidden';
	
	document.getElementById("text4").style.visibility = 'hidden';
	document.getElementById("text1").style.visibility = 'hidden';
	document.getElementById("text2").style.visibility = 'hidden';
	document.getElementById("text3").style.visibility = 'hidden';

	
	MM_swapImage('mainImage','','images/home-client-' + clientNumsArray[whichOne] + '-big.jpg',1);
	MM_swapImage('clientImage' + whichOne,'','images/home-clients-' + clientNumsArray[4] + '.jpg',1);
	
	document.getElementById("text" + clientNumsArray[whichOne]).style.visibility = 'visible';
	document.getElementById("clientTitle" + whichOne).innerHTML = clientTitlesArray[clientNumsArray[4]];
	
	var previous = clientNumsArray[whichOne];
	clientNumsArray[whichOne] = clientNumsArray[4];
	clientNumsArray[4] = previous;
	
	
	//showState();
}

var insideNumsArray = [];
insideNumsArray[0] = "";
insideNumsArray[1] = "1";
insideNumsArray[2] = "2";
insideNumsArray[3] = "3";
insideNumsArray[4] = "4";

function showText2(whichOne) {

    //document.getElementById("block1").style.visibility = 'hidden';
    //document.getElementById("block2").style.visibility = 'hidden';
    //document.getElementById("block3").style.visibility = 'hidden';
    //document.getElementById("block4").style.visibility = 'hidden';

    document.getElementById("text1").style.visibility = 'hidden';
    document.getElementById("text2").style.visibility = 'hidden';
    document.getElementById("text3").style.visibility = 'hidden';
    document.getElementById("text4").style.visibility = 'hidden';

    document.getElementById("text" + insideNumsArray[whichOne]).style.visibility = 'visible';
    //if (whichOne > 1) {
        document.getElementById("sectionTitle" + whichOne).innerHTML = insideTitlesArray[insideNumsArray[1]];
    //} else {
        //for (i = 0; i < 5; i++) {
            //if (insideNumsArray[i] == 1) {
               // document.getElementById("sectionTitle" + i).innerHTML = insideTitlesArray[insideNumsArray[i]];
            //}
        //}
    //}

    var previous = insideNumsArray[whichOne];
    insideNumsArray[whichOne] = insideNumsArray[1];
    insideNumsArray[1] = previous;

    //showState();
}

function showText3(whichOne) {

    document.getElementById("text1").style.visibility = 'hidden';
    document.getElementById("text2").style.visibility = 'hidden';
    document.getElementById("text3").style.visibility = 'hidden';
    document.getElementById("text4").style.visibility = 'hidden';

    document.getElementById("text" + whichOne).style.visibility = 'visible';
    insideNumsArray[1] = whichOne;

    if (whichOne == 1) {
        document.getElementById("sectionTitle2").innerHTML = insideTitlesArray[2];
        document.getElementById("sectionTitle3").innerHTML = insideTitlesArray[3];
        document.getElementById("sectionTitle4").innerHTML = insideTitlesArray[4];
        insideNumsArray[2] = "2";
        insideNumsArray[3] = "3";
        insideNumsArray[4] = "4";
    } else if (whichOne == 2) {
        document.getElementById("sectionTitle2").innerHTML = insideTitlesArray[1];
        document.getElementById("sectionTitle3").innerHTML = insideTitlesArray[3];
        document.getElementById("sectionTitle4").innerHTML = insideTitlesArray[4];
        insideNumsArray[2] = "1";
        insideNumsArray[3] = "3";
        insideNumsArray[4] = "4";
    } else if (whichOne == 3) {
        document.getElementById("sectionTitle2").innerHTML = insideTitlesArray[2];
        document.getElementById("sectionTitle3").innerHTML = insideTitlesArray[1];
        document.getElementById("sectionTitle4").innerHTML = insideTitlesArray[4];
        insideNumsArray[2] = "2";
        insideNumsArray[3] = "1";
        insideNumsArray[4] = "4";
    } else if (whichOne == 4) {
        document.getElementById("sectionTitle2").innerHTML = insideTitlesArray[2];
        document.getElementById("sectionTitle3").innerHTML = insideTitlesArray[3];
        document.getElementById("sectionTitle4").innerHTML = insideTitlesArray[1];
        insideNumsArray[2] = "2";
        insideNumsArray[3] = "3";
        insideNumsArray[4] = "1";
    }
}

function showState() {
    alert(insideNumsArray);
}

function showText8(whichOne) {

    //document.getElementById("leftBox1").style.visibility = 'hidden';
    //document.getElementById("leftBox2").style.visibility = 'hidden';
    //document.getElementById("leftBox3").style.visibility = 'hidden';

    document.getElementById("text1").style.visibility = 'hidden';
    document.getElementById("text2").style.visibility = 'hidden';
    document.getElementById("text3").style.visibility = 'hidden';

    if (whichOne != 1) document.getElementById("mainImage").style.visibility = 'visible';
    else document.getElementById("mainImage").style.visibility = 'hidden';
    MM_swapImage('mainImage', '', 'images/home-client-' + whichOne + '-big.jpg', 1);
    MM_swapImage('clientImage' + whichOne, '', 'images/home-clients-' + whichOne + '.jpg', 1);

    if (whichOne == 1) document.getElementById("leftBox1").style.background = 'url(images/home-left-top-blue.jpg)';
    else document.getElementById("leftBox1").style.background = 'url(images/home-left-top.jpg)';
    if (whichOne == 2) document.getElementById("leftBox2").style.background = 'url(images/home-left-middle-blue.jpg)';
    else document.getElementById("leftBox2").style.background = 'url(images/home-left-middle.jpg)';
    if (whichOne == 3) document.getElementById("leftBox3").style.background = 'url(images/home-left-bottom-blue.jpg)';
    else document.getElementById("leftBox3").style.background = 'url(images/home-left-bottom.jpg)';
    document.getElementById("text" + whichOne).style.visibility = 'visible';
    document.getElementById("clientTitle" + whichOne).innerHTML = clientTitlesArray[whichOne];

    //var previous = clientNumsArray[whichOne];
    //clientNumsArray[whichOne] = clientNumsArray[4];
    //clientNumsArray[4] = previous;


    //showState();
}

function showNews(whichOne) {
    $("span.neat").addClass("ohmy").hide("slow");
    //$(this).hide();
    $('.jq-runCode').show();
    $('.newsText1a').show();
    $("span.neat2").addClass("ohmy").hide("slow");
    //$(this).hide();
    $('.jq-runCode3').show();
    $('.newsText2a').show();
    var obj;
    for (i = 1; i < 4; i++) {
        obj = document.getElementById("newsText" + i);
        if (obj != null) {
            if (whichOne == i) {
                document.getElementById("newsArrow" + whichOne).style.visibility = 'visible';
                obj.style.display = 'block';
            } else {
                document.getElementById("newsArrow" + i).style.visibility = 'hidden';
                obj.style.display = 'none';
            }
        }
    }
    
    return false;
}

var currentClient = 1;
var currentClientName = "";
var currentDept = "Digital";
var numOfClientImgs;
var numOfClients;

var clientsDigitalArray = [];
clientsDigitalArray[0] = "HML Holdings PLC:3";
clientsDigitalArray[1] = "Open Out:1";
clientsDigitalArray[2] = "Dudley Developments:1";
clientsDigitalArray[3] = "The Plough, Coton:1";
clientsDigitalArray[4] = "Stilo Nuovo:1";
clientsDigitalArray[5] = "Aviva St Helens Tower:1";
clientsDigitalArray[6] = "Redmayne Arnold and Harris:2";
clientsDigitalArray[7] = "Computerlinks:1";

var clientsDesignArray = [];
clientsDesignArray[0] = "Internet Watch Foundation:4";
clientsDesignArray[1] = "HML Holdings PLC:1";
clientsDesignArray[2] = "Dudley Developments:4";
clientsDesignArray[3] = "Girton College:4";
clientsDesignArray[4] = "Open Out:1";
clientsDesignArray[5] = "Serco Group - ER Consultants:1";
clientsDesignArray[6] = "Stilo Nuovo:4";
clientsDesignArray[7] = "The Plough, Coton:2";
clientsDesignArray[8] = "Convergys:3";
clientsDesignArray[9] = "Computerlinks:3";

var clientsAdvertisingArray = [];
clientsAdvertisingArray[0] = "The Plough, Coton:4";
clientsAdvertisingArray[1] = "HML Holdings PLC:1";
clientsAdvertisingArray[2] = "Dudley Developments:4";
clientsAdvertisingArray[3] = "Open Out:2";
clientsAdvertisingArray[4] = "Stilo Nuovo:2";
clientsAdvertisingArray[5] = "Belvisi:2";

function getClientName(clientStrIn) {
    var index = clientStrIn.indexOf(":");
    return clientStrIn.substring(0, index);
}

function getFileClientName(clientStrIn) {
    var clientString = clientStrIn.replace(/ /g, "-");
    clientString = clientString.replace(/,/g, "");
    return clientString;
}

function getNumOfClientImages(clientStrIn) {
    var index = clientStrIn.indexOf(":");
    return clientStrIn.substring(index + 1, clientStrIn.length);
}

function changeImage(whichOne) {
    if (numOfClientImgs < whichOne) return;
    //document.getElementById('mainImage').src = "/images/clients/" + getFileClientName(currentClientName) + "/" + currentDept + "/" + getFileClientName(currentClientName) + whichOne + ".jpg";
    //rel = "lightbox[stilo]"
    //<a href="" rel="lightbox[brownstone]"><img id="mainImage" src="images/stilo.jpg" alt="Brownstone work" /></a>
    
    //document.getElementById('mainImage').innerHTML = "<a href='/images/clients/" + getFileClientName(currentClientName) + "/" + currentDept + "/" + getFileClientName(currentClientName) + whichOne + "b.jpg' rel='lightbox' title='" + currentClientName + "'><img src='/images/clients/" + getFileClientName(currentClientName) + "/" + currentDept + "/" + getFileClientName(currentClientName) + whichOne + ".jpg' alt='Brownstone work' /></a>";
    clearImages();
    //alert(currentClientName);
    document.getElementById(getFileClientName(currentClientName) + whichOne).style.visibility = 'visible';
}

function clearImages() {
    for (var i = 0; i < numOfClientImgs; i++) {
        document.getElementById(getFileClientName(currentClientName) + (i + 1)).style.visibility = 'hidden';
    }
}

function changeClient(whichOne, isUp) {
    
    //alert(whichOne);
    if (whichOne == -1) {
        //get param or 1
        var clientParam = gup('client');
        if (clientParam == "") whichOne = 1;
        else whichOne = clientParam;
    } else {
        whichOne = currentClient;
        if (isUp) whichOne++;
        else whichOne--;
        if (whichOne == numOfClients + 1) whichOne = 1;
        if (whichOne == 0) whichOne = numOfClients;
        clearImages();
    }
    currentClient = whichOne;
    //alert(currentClient);
    if (currentDept == "Digital") {
        currentClientName = getClientName(clientsDigitalArray[whichOne - 1]);
        numOfClients = clientsDigitalArray.length;
        numOfClientImgs = getNumOfClientImages(clientsDigitalArray[whichOne - 1]);
        //alert(currentClientName);
        //alert(getNumOfClientImages(clientsDigitalArray[whichOne - 1]));
    } else if (currentDept == "Design") {
        currentClientName = getClientName(clientsDesignArray[whichOne - 1]);
        numOfClients = clientsDesignArray.length;
        numOfClientImgs = getNumOfClientImages(clientsDesignArray[whichOne - 1]);
    } else if (currentDept == "Advertising") {
        currentClientName = getClientName(clientsAdvertisingArray[whichOne - 1]);
        numOfClients = clientsAdvertisingArray.length;
        numOfClientImgs = getNumOfClientImages(clientsAdvertisingArray[whichOne - 1]);
    }
    //alert(currentDept);
    doClientImgBoxes(whichOne);
    doClientTextBoxes(whichOne);
    changeImage(1);
} 

function doClientImgBoxes(whichOne) {
    //var b1 = document.getElementById('block1');
    var b1 = document.getElementById('block2');
    var b2 = document.getElementById('block3');
    var b3 = document.getElementById('block4');
    //alert(b2.onclick);
    if (currentDept == "Digital") {
        numOfClientImgs = getNumOfClientImages(clientsDigitalArray[whichOne - 1]);
    } else if (currentDept == "Design") {
        numOfClientImgs = getNumOfClientImages(clientsDesignArray[whichOne - 1]);
    } else if (currentDept == "Advertising") {
        numOfClientImgs = getNumOfClientImages(clientsAdvertisingArray[whichOne - 1]);
    }
    //alert(numOfClientImgs);
    b1.className = 'oneBlock';
    b2.className = 'twoBlock';
    b3.className = 'threeBlock';
    b1.onmouseover = function(){ this.className = 'oneBlockUp' };
    b2.onmouseover = function(){ this.className='twoBlockUp'};
    b3.onmouseover = function(){ this.className='threeBlockUp'};
    b1.onmouseout = function(){ this.className = 'oneBlock' };
    //alert(b1.onmouseout);
    b2.onmouseout = function(){ this.className = 'twoBlock' };
    b3.onmouseout = function(){ this.className = 'threeBlock' };
    if (numOfClientImgs == 1) {
        b2.className = 'noBlock';
        b3.className = 'noBlock';
        b2.onmouseover = function() { this.className = 'noBlock' };
        b3.onmouseover = function() { this.className = 'noBlock' };
        b2.onmouseout = function() { this.className = 'noBlock' };
        b3.onmouseout = function() { this.className = 'noBlock' };
    } else if (numOfClientImgs == 2) {
        b3.className = 'noBlock';
        b3.onmouseover = function() { this.className = 'noBlock' };
        b3.onmouseout = function() { this.className = 'noBlock' };
    } 
    
    /*b1.style.background = "#CADB2A";
    b2.style.background = "#CADB2A";
    b3.style.background = "#CADB2A";
    b4.style.background = "#CADB2A";
    if (numOfClientImgs == 1) {
        b2.style.background = "#555";
        b3.style.background = "#555";
        b4.style.background = "#555";
    } else if (numOfClientImgs == 2) {
        b3.style.background = "#555";
        b4.style.background = "#555";
    } else if (numOfClientImgs == 3) {
        b4.style.background = "#555";
    }*/
    currentClient = whichOne;
}

function getFromCurrentDeptArray(index) {
    if (currentDept == "Digital") {
        return clientsDigitalArray[index - 1];
    } else if (currentDept == "Design") {
        return clientsDesignArray[index - 1];
    } else if (currentDept == "Advertising") {
        return clientsAdvertisingArray[index - 1];
    }
}

function getLengthOfCurrentDeptArray() {
    if (currentDept == "Digital") {
        return clientsDigitalArray.length;
    } else if (currentDept == "Design") {
        return clientsDesignArray.length;
    } else if (currentDept == "Advertising") {
        return clientsAdvertisingArray.length;
    }
}

function doClientTextBoxes(whichOne) {
    for (var i = 1; i < getLengthOfCurrentDeptArray() + 1; i++) {
        document.getElementById('rightText' + i.toString()).style.left = "-10000px";
    }
    var currentClientStr = currentClient + '';
    document.getElementById('rightText' + currentClientStr).style.left = "700px";
    document.getElementById('rightTitle').innerHTML = "700px";
    document.getElementById('rightTitle').innerHTML = getFromCurrentDeptArray(whichOne).substring(0, getFromCurrentDeptArray(whichOne).indexOf(":"));
//    if (currentDept == "Digital") {
//        document.getElementById('rightTitle').innerHTML = clientsDigitalArray[whichOne - 1].substring(0, clientsDigitalArray[whichOne - 1].indexOf(":"));
//    } else if (currentDept == "Design") {
//        document.getElementById('rightTitle').innerHTML = clientsDesignArray[whichOne - 1].substring(0, clientsDesignArray[whichOne - 1].indexOf(":"));
//    } else if (currentDept == "Advertising") {
//        document.getElementById('rightTitle').innerHTML = clientsAdvertisingArray[whichOne - 1].substring(0, clientsAdvertisingArray[whichOne - 1].indexOf(":"));
//    }
}

/*function showTestimonial(whichOne) {
    hideId('testimonial1');
    hideId('testimonial2');
    hideId('testimonial3');
    hideId('testimonial4');
    hideId('testimonial5');
    if (whichOne == 1) {
        showId('testimonial1');
    } else if (whichOne == 2) {
        showId('testimonial2');
    } else if (whichOne == 3) {
        showId('testimonial3');
    } else if (whichOne == 4) {
        showId('testimonial4');
    } else if (whichOne == 5) {
        showId('testimonial5');
    }
}*/
var currentDiv = '1';

function showTestimonial(whichOne) {
    //document.getElementById(whichOne).style.visibility = "visible";
    hideContent(currentDiv);
    showContent(whichOne);
    currentDiv = whichOne;
}

function showContent(divName) {
    $('#' + divName).css('opacity', 0);
    $('#' + divName).css('visibility', 'visible');
    //$('.container').css('height', '880px');
    $('#' + divName).animate({ opacity: 1 }, 1000);
}
function hideContent(divName) {
    $('#' + divName).animate({ opacity: 0 }, 1000, function() {
        $('' + divName).css('visibility', 'hidden');
    });
    //document.location.href = '#Top';
}

function clearTextbox1() {
    var tb = document.getElementById('requirements');
    if (tb.value == 'Enter a brief description of your requirements') {
        tb.value = '';
    }
}
function clearTextbox2() {
    var tb = document.getElementById('emailaddress');
    if (tb.value == 'Please enter your email address') {
        tb.value = '';
    }
}
function clearTextbox10() {
    var tb = document.getElementById('emailaddress2');
    if (tb.value == 'Enter your email address') {
        tb.value = '';
    }
}
function clearTextbox11() {
    var tb = document.getElementById('emailaddress3');
    if (tb.value == 'Enter your email address') {
        tb.value = '';
    }
}
function clearTextbox12() {
    var tb = document.getElementById('emailaddress4');
    if (tb.value == 'Enter your email address') {
        tb.value = '';
    }
}
function clearTextbox13() {
    var tb = document.getElementById('websiteaddress');
    if (tb.value == 'Enter your website address') {
        tb.value = '';
    }
}
function clearContactTextbox1() {
    var tb = document.getElementById('fullname');
    if (tb.value == 'Enter your name') {
        tb.value = '';
    }
}
function clearContactTextbox2() {
    var tb = document.getElementById('emailaddress');
    if (tb.value == 'Enter your email address') {
        tb.value = '';
    }
}
function clearContactTextbox3() {
    var tb = document.getElementById('comments');
    if (tb.value == 'Add your message here') {
        tb.value = '';
    }
}

function hideFeaturedClients() {
    hideId('featuredClient1');
    hideId('featuredClient2');
    //hideId('featuredClient3');
    //hideId('featuredClient4');
    //hideId('featuredClient5');
    //hideId('featuredClient6');
}

$(document).ready(function() {

    //move the image in pixel
    var move = -15;

    //zoom percentage, 1.2 =120%
    var zoom = 1;

    //On mouse over those thumbnail
    $('.zitem').hover(function() {

        //Set the width and height according to the zoom percentage
        width = $('.zitem').width();// * zoom;
        height = $('.zitem').height();// * zoom;

        //Move and zoom the image
        //$(this).find('img').stop(false, true).animate({ 'width': width, 'height': height, 'top': move, 'left': move }, { duration: 200 });

        //Display the caption
        $(this).find('div.caption').stop(false, true).fadeIn(200);
    },
	function() {
	    //Reset the image
	    //$(this).find('img').stop(false, true).animate({ 'width': $('.zitem').width(), 'height': $('.zitem').height(), 'top': '0', 'left': '0' }, { duration: 100 });

	    //Hide the caption
	    $(this).find('div.caption').stop(false, true).fadeOut(200);
	});

});


function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}



jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
}; ;



var tbar = "";

; (function($) {
    $(document).ready(function() {
    if (!ie) {
    //$.get('/sharebar/value/profile_sharetool', function(data) {
    $('#homePanel').css({ opacity: 0 });
    $('#valueLink').click(function() {
        $('#homePanel').animate({ opacity: 1 }, 300);
    });
    $('#valueCloseLink').click(function() {
        $('#homePanel').animate({ opacity: 0 }, 300);
    });
    
        if (true) {
            var url = window.location.href;
            var host = window.location.hostname;
            var title = $('title').text();

            //get rid of the "| CSS Creator" from end of title.
            var titlearr = title.split('|');
            title = titlearr[0];

            title = escape(title);

//            var twit = 'http://twitter.com/home?status=' + title + '%20' + url;
//            var facebook = 'http://www.facebook.com/sharer.php?u=' + url
//            var digg = 'http://digg.com/submit?phase=2&url=' + url + '&amp;title=' + title;
//            var stumbleupon = 'http://stumbleupon.com/submit?url=' + url + '&amp;title=' + title;
//            var buzz = 'http://www.google.com/reader/link?url=' + url + '&amp;title=' + title + '&amp;srcURL=' + host;
//            var delicious = 'http://del.icio.us/post?url=' + url + '&amp;title=' + title;

//              tbar = '<div id="statusPanel"><span>Share<br /><a href="#min" id="minimize" title="Minimize"> <img src="/images/minimize.gif" border="0"></a></span><div id="sicons">';
//            //var tbar = '<div id="socializethis"><span>Share<br /><a href="#min" id="minimize" title="Minimize"> <img src="/sites/all/themes/csscr_six/images/minimize.png"></a></span><div id="sicons">';
//                tbar += '<a href="' + twit + '" id="twit" title="Share on twitter"><img src="images/twitter.png"  alt="Share on Twitter" width="32" height="32" /></a>';
//                tbar += '<a href="' + facebook + '" id="facebook" title="Share on Facebook"><img src="images/facebook.png"  alt="Share on facebook" width="32" height="32" /></a>';
//                tbar += '<a href="' + digg + '" id="digg" title="Share on Digg"><img src="images/digg.png"  alt="Share on Digg" width="32" height="32" /></a>';
//                tbar += '<a href="' + stumbleupon + '" id="stumbleupon" title="Share on Stumbleupon"><img src="images/stumbleupon.png"  alt="Share on Stumbleupon" width="32" height="32" /></a>';
//                tbar += '<a href="' + delicious + '" id="delicious" title="Share on Del.icio.us"><img src="images/delicious.png"  alt="Share on Delicious" width="32" height="32" /></a>';
//                tbar += '<a href="' + buzz + '" id="buzz" title="Share on Buzz"><img src="images/google-buzz.png"  alt="Share on Buzz" width="32" height="32" /></a>';
//                tbar += '</div></div>';

                        //tbar = '<div id="statusPanel"><span>Share<br /><a href="#min" id="minimize" title="Minimize"> <img src="/images/minimize.gif" border="0"></a></span>';
            //tbar += '<div id="connectStatusLink"><a href="javascript:showId(\'FBConnectPanel\');" id="fbConnectButton" title="Connect to Facebook for maximum points"><img src="/images/FB-Connect-Status.gif" border="0"></a></div></div>';
                        //tbar += '';
            tbar = '<div id="statusPanel"><span>Share/Print<br /><a href="#min" id="minimize" title="Minimize"> <img src="/images/minimize.gif" border="0"></a></span>';
            //tbar += '<div id="connectStatusLink"><div class="addthis_toolbox addthis_default_style"><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4c73ed877a02e8b4" class="addthis_button_compact">Share</a><span class="addthis_separator">|</span><a class="addthis_button_facebook"></a><a class="addthis_button_myspace"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c73ed877a02e8b4"></script>';

            //tbar += '<div class="addthis_toolbox addthis_pill_combo"><a class="addthis_button_tweet" tw:count="horizontal"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact">Share</a></div>';
            tbar += '<div class="addthis_toolbox addthis_default_style"><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=brownstone" class="addthis_button_compact"></a><span class="addthis_separator">|</span><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_myspace"></a><a class="addthis_button_google"></a><a class="addthis_button_digg"></a><a class="addthis_button_stumbleupon"></a><a class="addthis_button_delicious"></a><a class="addthis_button_email"></a><a class="addthis_button_print"></a></div>';

            // Add the share tool bar.
            $('body').append(tbar);

            $('#statusPanel').css({ opacity: .7 });
            // hover.
            $('#statusPanel').bind('mouseenter', function() {
                $(this).animate({ height: '35px', width: '340px', opacity: 1 }, 300);
                $('#statusPanel img').css('display', 'inline');
            });
            //leave
            $('#statusPanel').bind('mouseleave', function() {
                $(this).animate({ opacity: .7 }, 300);
            });
            // Click minimize
            $('#statusPanel #minimize').click(function() {
                $('#statusPanel').animate({ height: '15px', width: '70px', opacity: .7 }, 300);
                $('#statusPanel img').css('display', 'none');
                $.cookie('minshare', '1');
                return false;
            });
            // Click fbConnectButton
            //$('#statusPanel #fbConnectButton').click(function() {
            //showId('FBConnectPanel');
            //return false;
            //});
            if ($.cookie('minshare') == 1) {
                $('#statusPanel').css({ height: '15px', width: '70px', opacity: .7 });
                $('#statusPanel img').css('display', 'none');
            }
        }
        //});
        }
    });
})(jQuery); ;

