﻿var ie55up = (document.all && document.getElementById)?(true):(false);

function toggleImg(o) {
	var src=o.src;
	return o.src=src.replace(toggleImg.rx,toggleImg.rx.test(src) && RegExp.$1 ? "$2" : "_$2");
}
toggleImg.rx=/(_?)(\.[a-z]{3})$/i;

function fixBorder(){
	var o = document.getElementById("relatedContent");
	var c = document.getElementById("content");
	if (o && c){

		o.style.height = (c.scrollHeight-40) + "px";
	}
}


function showCaseStudy(cid){
	var oWrap = document.getElementById("caseStudy");
	var oBox = document.getElementById("caseStudyBox");


	if(oWrap && oBox){
		oBox.innerHTML = "";
		if (cid>0){
			oWrap.style.display = "block";
			oBox.style.display = "block";
			document.getElementById("caseStudyBox").style.background = "none";
			oWrap.style.top = document.documentElement.scrollTop + "px";

			oBox.style.width = "100px";
			oBox.style.height = "50px";

			scaleElement('caseStudyBox', 680, 400 , 1.25,1.27, cid );

		}else{
			oWrap.style.display = "none";
			oBox.style.display = "none";
		}
	}

}

function scaleElement(id,w,h, fx, fh,cid){
	var e = document.getElementById(id);
	var ended = true;

	if (parseInt(e.style.width)<w){
		e.style.width = parseInt(parseInt(e.style.width)*fx) + "px";
		ended = false;
	}
	if (parseInt(e.style.height)<h){
		e.style.height = parseInt(parseInt(e.style.height)*fh) + "px";
		ended = false;
	}
	if (parseInt(e.style.width)>w){
		e.style.width = w + "px";
	}
	if (parseInt(e.style.height)>h){
		e.style.height = h + "px";

		var oXml = new Browser.XML.HTTP();
		oXml.open("GET.html", "case_study2370.html?companyId="+cid,true);
		 oXml.onreadystatechange=function() {
		  if (oXml.readyState==4) {
			document.getElementById("caseStudyBox").innerHTML = oXml.responseText;
			document.getElementById("caseStudyBox").style.backgroundColor = "#ffffff";

		  }
		 }
		 oXml.send(null);


	}
	if(!ended){
		setTimeout("scaleElement('"+id+"',"+w+","+h+","+fx+","+fh+","+cid +")",10 );
	}
}

var bgColors =		["#ffffff","#FBFBFB","#FAFAFA","#F8F8F8","#F6F6F6","#F4F4F4","#F2F2F2","#F1F1F1","#EFEFEF","#EDEDED"];
var buttonsBgColors =	["#C4C2BF","#D7C2A3","#DABC8E","#DDB67A","#E1AF66","#E4A952","#E7A33D","#EA9D29","#EE9714","#F19100"];
var sideBgColors =	["#ffffff","#F9D399","#F7BD66","#F4A733","#F19100"];
var linkColors =		["#949494","#A5A5A5","#C7C7C7","#E9E9E9","#FFFFFF"];


function fade(e,isFadeout,fadeType){
	var t = 10;
	if (fadeType==0){
		m = bgColors.length;
	}else if (fadeType==1){
		m = sideBgColors.length;
	}else if (fadeType==2){
		m = linkColors.length;
	}else{
		m = buttonsBgColors.length;
		t = 60;
	}

	if (!isFadeout){
		setNextColor(e,0,m-1,fadeType, t);
	}else{
		setNextColor(e,m-1,0,fadeType, t);
	}
}

function setNextColor(e,n,final,fadeType, t){
	if (fadeType==0){
		e.style.backgroundColor = bgColors[n];
	}else if (fadeType==1){
		e.style.backgroundColor = sideBgColors[n];
		e.style.color = linkColors[n];
	}else if (fadeType==2){
		e.style.backgroundColor = sideBgColors[n];
		e.style.color = linkColors[n];
	}else if (fadeType==3){
		e.style.backgroundColor = buttonsBgColors[n];
	}
	if (n!=final){
		setTimeout(function(){setNextColor(e,(final>0)?(++n):(--n),final,fadeType)} , t );
	}
}


var visibleLayers = 0;
function showLayer(oId,noTrans){
	visibleLayers++;
	var o = document.getElementById(oId);
	if (o){
		if (!noTrans && ie55up && o.filters){
			if (o.filters.length>0){
				doTrans(oId, 100);
			}
		}else{
			o.style.visibility = "visible";
		}



	}
}

function doTrans(oId , endVal ) {
	var o = document.getElementById(oId);
	if (o){
		if (o.filters[0].opacity < 90){
			o.filters[0].opacity = parseInt (o.filters[0].opacity) + 5;
			setTimeout (function(){doTrans(oId,endVal)} , 10);
		}else{

			//o.filters[0].opacity = 30;
			//o.style.filter = [0].opacity = endVal;
			o.className = "";
		}



	}
}


function showAllLayers(){
	if (Browser.Opera){
		if (document.getElementById("HPbuildup"))document.getElementById("HPbuildup").style.display = "none";
		if (document.getElementById("mainLogo"))document.getElementById("mainLogo").style.visibility = "visible";
		document.body.style.backgroundImage = "url(images/top_background.gif)";

	}
	if (visibleLayers==0){
		showLayer("portfolioHolder");
		showLayer("toolbar");
		showLayer("newsHolder");
		showLayer("slogenHolder",true);
		showLayer("teamHolder");
		showLayer("imagesHolder",true);
	}

}

function autoOpenHp(){
	setTimeout ("showAllLayers()",  5000);
}



DOM.Event ("load",fixBorder);

/*********************funcs.js*/
function Text() {}

if (!Array.prototype.push) {Array.prototype.push=function () {for (var iArg=0;iArg<arguments.length;iArg++) this[this.length]=arguments[iArg];return this.length;}}
Array.prototype.indexOf=function (v) {var i=0;while (i<this.length && this[i]!=v) i++;return i==this.length ? -1 : i;}
Array.prototype.remove=function (iIndex) {if (iIndex<0 || iIndex>=this.length) return;for (var i=iIndex+1;i<this.length;i++) this[i-1]=this[i];this.length--;return this;}
String.prototype.ToRX=function () {return this.replace(/(\(|\)|\{|\}|\[|\]|\:|\^|\$|\!|\=|\+|\*|\/|\,|\-|\||\?)/g,"\\$1");}
Object.prototype.Hash=function (funcs) {var s="\n";for (var i in this) {if (typeof this[i]=="function" && !funcs) continue;s+=i+"\t\t"+this[i]+"\n";}return s;}

function QS() {}
QS.Init=function () {this.Length=0;this.Data=[];var qs=location.href.split("?")[1],item;if (!qs) return;qs=qs.split("&");for (var i=0;i<qs.length;i++) {item=qs[i].split("=");item[1]=unescape(item[1]) || "";this.Data[item[0].toLowerCase()]=item[1];this.Data[i]=new QS.Item(item[0],item[1]);this.Length++;}}
QS.Get=function (item) {return this.Data[(item+"").toLowerCase()];}
QS.Item=function (name,value) {this.Name=name;this.Value=value;}
QS.Item.prototype.toString=function () {return this.Name+"="+this.Value;}
QS.Add=function () {var a;if (typeof arguments[0]=="string" && arguments[1]!=undefined) a=[new this.Item(arguments[0],arguments[1])];else if (arguments[0] instanceof Array) a=arguments[0];else a=arguments;var qs="",hash="",rxQS,item,value;if (/\?([^#]*)(#.*)?$/.test(location.href)) {qs=RegExp.$1;hash=RegExp.$2;}for (var i=0;i<a.length;i++) {if (!(a[i] instanceof QS.Item)) continue;item=a[i].Name;value=a[i].Value;rxQS=new RegExp("(^|&)"+item.ToRX()+"=?[^\&#]*(&|$)");qs=rxQS.test(qs) ? qs.replace(rxQS,"$1"+item+"="+value+"$2") : qs+(qs ? "&" : "")+item+"="+value;}location.href="?"+qs+hash;}

function Cookies() {}
Cookies.Get=function (name) {if (DOM.doc.cookie && new RegExp("\\b"+name+"=([^;]*)").test(DOM.doc.cookie)) return unescape(RegExp.$1);}
Cookies.Set=function (name,value) {var d=new Date();d.setTime(d.getTime()+365*24*3600*1000);DOM.doc.cookie=name+"="+escape(value)+"; expires="+d.toGMTString();/*path=/; */}
Cookies.Del=function (name) {if (this.Get(name)) DOM.doc.cookie=name+"=; expires=Thu, 01-Jan-70 00:00:01 UTC";}

Text.Pad=function (s,n) {n=n || 2;return "000000000000000000000".substr(0,n-(""+s).length)+s;}
Text.Escape=function (str,html) { if (typeof str=="string" && str.length) {if (!html) {str=str.replace(/>/g,"&gt;").replace(/</g,"&lt;");}else {str=str.replace(/\r?\n/g,"<br/>");}str=str.replace(/"/g,"&quot;").replace(/'/g,"&#39;");}return str;}
QS.Init();

function copy(s) {
	if (window.clipboardData) clipboardData.setData("Text",s);
}

