﻿/*tooltip.js*/
var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;

function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
  this.width = 150;                     // width (pixels)
  this.bgColor = "#1f3255";             // background color
  this.textFont = "Arial";      // text font family
  this.textSize = 12;                   // text font size (pixels)
  this.textColor = "#FFFFFF";           // text color
  this.border = "1px solid #0c1b38";   // border (CSS spec: size style color, e.g. "1px solid #D00000")
  this.opacity = 80;                    // opacity (0 - 100); not supported by all browsers
  this.cursorDistance = 10;              // distance from mouse cursor (pixels)

  // don't change
  this.text = '';
  this.height = 0;
  this.obj = null;
  this.active = false;

//----------------------------------------------------------------------------------------------------
// Methods
//----------------------------------------------------------------------------------------------------
  this.create = function() {
    if(!this.obj) this.init();

    var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
            (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
            (this.border ? 'border:' + this.border + '; ' : '') +
            ('padding:4px 4px; ') +
            (this.textColor ? 'color:' + this.textColor + '; ' : '');

    var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + '><tr>' +
            '<td align=center' + (s ? ' style="' + s + '"' : '') + '>' + this.text +
            '</td></tr></table>';

    if(DOM || IE) this.obj.innerHTML = t;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(x + this.width + this.cursorDistance > winX + getScrX())
      x -= this.width + this.cursorDistance;
    else x += this.cursorDistance;

    if(y + this.height + this.cursorDistance > winY + getScrY())
      y -= this.height;
    else y += this.cursorDistance;

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.zIndex = 69;
    this.active = true;
    this.obj.style.visibility = 'visible';
  }

  this.hide = function() {
    this.obj.style.zIndex = -1;
    this.active = false;
    this.obj.style.visibility = 'hidden';
  }

  this.setOpacity = function() {
    this.obj.style.opacity = this.opacity / 100;
    this.obj.style.MozOpacity = this.opacity / 100;
    this.obj.style.KhtmlOpacity = this.opacity / 100;
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
  }
}

//----------------------------------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------------------------------
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

function toolTip(text, width, opacity) {
  if(text) {
    tooltip = new TOOLTIP();
    tooltip.text = text;
    if(width) tooltip.width = width;
    if(opacity) tooltip.opacity = opacity;
    tooltip.create();
  }
  else if(tooltip) tooltip.hide();
}

//----------------------------------------------------------------------------------------------------
// Build tooltip box
//----------------------------------------------------------------------------------------------------
document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>');

//----------------------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------------------
var mouseX = mouseY = 0;
document.onmousemove = getMouseXY;
//----------------------------------------------------------------------------------------------------
/*misc.js*/
function change_to(xValue) {
  if (xValue != 0) {
	location.href = xValue;
  }
}

$(document).ready(function(){
	if (document.getElementById("bottBtm")){
		$("div#bottBtm a").click( function () {
			if ($(this).text().indexOf('en savoir plus') > -1) {
				$(this).text('\253 reduire');
				$(this).attr('title','\253 reduire');
				$('div.bottHidden').slideToggle('normal');
			} else {
				$(this).text('en savoir plus \273');
				$(this).attr('title','en savoir plus \273');
				$('div.bottHidden').slideToggle('normal');
			}
			return false;
		});
	}
	equalHeight($(".cntclmn"));

	var slideShow = $('.slideShow').slideShow({
		interval: 6
	});
	// now add logic to play/pause button
	$('.slideShow a.togglePlayback').click(function() {
		if (slideShow.isPlaying()) {
			$(this).css('backgroundPosition', '-44px -34px');
		} else {
			$(this).css('backgroundPosition', '-25px -34px');
		}
		slideShow.togglePlayback();
	});

    $(function() {
		if (document.getElementById("corpidenttbl")){
			$('#corpidenttbl a').lightBox();
		}
    });
	if (document.getElementById("clientslide")){
		$('#clientslide').cycle({
			fx: 'fade'
		});
	}
	
	//CONTENT STUFF
	$('.pdfbtn').hover(
	function () {
		$(this).attr("src","/images/design/multichannelpdf.gif"); 
	}, 
	function () {
		$(this).attr("src","/images/design/multichannelpdfactv.gif"); 
	}
	);

	if (document.getElementById("qckcallback")){

		$("#qckcallback .qckname").click( function () {
			if ($(this).val() == 'nom*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckemail").click( function () {
			if ($(this).val() == 'email*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckphone").click( function () {
			if ($(this).val() == 't\351l\351phone*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckenquiry").click( function () {
			if ($(this).val() == 'demande') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckcaptcha").click( function () {
			if ($(this).val() == 'code*') {
				$(this).val('');
			}
			return false;
		});
	}
	
	
	var ojectas = document.getElementById("PortfolioCategoryID");
		if (ojectas != null) {
		filterportfolios(ojectas);
		}
	
});

function sdopen(img,id){
	var tmpel =  document.getElementById(id);
	if (tmpel.style.display=="none" || tmpel.style.display == ""){
		img.src = "/images/design/sidebarminus.gif"
		$("#"+id).animate({height: "toggle"}, 500);
	}else{
		img.src = "/images/design/sidebarplus.gif"
		$("#"+id).animate({height: "toggle"}, 500)			
	}
}
	
function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest);
}


function openpfl (id){
for (i=0;i<aPflinks.length;i++){
	if (aPflinks[i].sID == id){
	window.open('http://'+aPflinks[i].sLink,'_blank')
	}
} 
}

function clrenquiry(txt){
	if (txt.innerHTML == "e.g. ecommerce solution"){
		txt.innerHTML = ""
	}
}

function ValidateCallback(form){
if (form.name.value=='') {alert('Entrez votre nom, s’il vous plaît'); form.name.focus(); return false}
if (form.phone.value=='') {alert('Entrez votre numéro de téléphone, s’il vous plaît'); form.phone.focus(); return false}
if (form.email.value=='') {alert('Entrez votre adresse email correcte, s’il vous plaît'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Entrez votre adresse email correcte, s’il vous plaît'); form.email.focus(); return false}
if (form.enquiry.value=='') {alert('Ajoutez votre demande, s’il vous plaît'); form.enquiry.focus(); return false}
if (form.captcha.value=='') {alert('Entrez le code de sécurité correct, s’il vous plaît'); form.captcha.focus(); return false}
}

function ValidateQuickCallback(form){
	if (form.name.value=='' || form.name.value=='nom*') {alert('Entrez votre nom, s’il vous plaît'); form.name.focus(); return false}
	if (form.email.value=='' || form.email.value=='email*') {alert('Entrez votre adresse email, s’il vous plaît'); form.email.focus(); return false}
	if (!CheckEmail(form.email.value)) {alert('L’adresse email entrée est incorrecte'); form.email.focus(); return false}
	if (form.phone.value=='' || form.phone.value=='t\351l\351phone*') {alert('Entrez votre numéro de téléphone, s’il vous plaît'); form.phone.focus(); return false}
	if (form.enquiry.value=='' || form.enquiry.value=='demande') {alert('Ajoutez votre demande, s’il vous plaît'); form.enquiry.focus(); return false}
	if (form.captcha.value=='' || form.captcha.value=='code*') {alert('Entrez le code de sécurité, s’il vous plaît'); form.captcha.focus(); return false}
}

function ValidateContact(form){
if (form.name.value=='') {alert('Entrez votre nom, s’il vous plaît'); form.name.focus(); return false}
if (form.companyname.value=='') {alert('Entrez le nome de votre entreprise, s’il vous plaît'); form.companyname.focus(); return false}
if (form.email.value=='') {alert('L’adresse email entrée est incorrecte'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('L’adresse email entrée est incorrecte'); form.email.focus(); return false}
if (form.telephone.value=='') {alert('Entrez votre numéro de téléphone, s’il vous plaît'); form.telephone.focus(); return false}
if (form.business.value=='') {alert('Indiquez le statut de votre entreprise, s’il vous plaît'); form.business.focus(); return false}
if (form.howheard.value=='') {alert('Comment nous avez-vous connu?'); form.howheard.focus(); return false}
if (form.ecommerce.checked == false && form.webdevelopment.checked == false && form.website.checked == false && form.multichannelecommerce.checked == false && form.ebaystoredesign.checked == false && form.webfulfilment.checked == false && form.other.checked == false && form.mcommerce.checked == false && form.internetmarketing.checked == false ) {alert('Indiquez le service que vous intéresse, s’il vous plaît'); form.ecommerce.focus(); return false}
if (form.message.value=='') {alert('Ajoutez la demande, s’il vous plaît'); form.message.focus(); return false}
if (form.captcha.value=='') {alert('Entrez le code de sécurité, s’il vous plaît'); form.captcha.focus(); return false}
}

function articefrml(form){
if (form.firstname.value=='') {alert('Please fill in your first name'); form.firstname.focus(); return false}
if (form.lastname.value=='') {alert('Please fill in your last name'); form.lastname.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
}

function CheckEmail(address) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)){
		return (true)
	}
		return (false)
}

function submitsearch(){
	document.fsearch.action='/search.asp?sq='+document.getElementById('search').value;
	document.fsearch.submit();
}

function searchOnSubmit(frm){
	var tmpstr = document.getElementById('search').value;
	tmpstr = tmpstr.replace(" ","_");
	frm.action = '/search.asp?sq='+tmpstr;
}
/*ajax.js*/
			var DivId;
			var status = true;
			var time = 0;
			var DepIDbefore = 0;
			var TabIDbefore = 1;
			var FirstGo = true;
			//var objektai = new Array();
			
			var tmpDivIds = new Array();
			
			function XmlHttp( ){
                this.CreateXmlHttpObject = CreateXmlHttpObject;
                this.GetUrlContent              = GetUrlContent;
                this.GetResponseText          = GetResponseText;
                this.GetReadyState              = GetReadyState;           
                this.HttpMethod = 'POST'; // default
                this.objXmlHttp = this.CreateXmlHttpObject();
            }

            // Initialize XMLHttpObject
            function CreateXmlHttpObject(){
                var xmlhttp=false;
                try {
                    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
       

            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
            }
                return xmlhttp;
            }
            var objXMLHttp =  new XmlHttp();
                   
            function GetReadyState( ){
				return this.objXmlHttp.readyState;
            }
 
            function GetResponseText( ){
                return this.objXmlHttp.responseText;
            }

			function GetResponse(){
				if (objXMLHttp!=null && objXMLHttp.GetReadyState()==4) {
				var objDivIds = new Array();
					if (objXMLHttp.GetResponseText( )!=''){
						var i = 0;
						objDivIds = objXMLHttp.GetResponseText( ).split('||');
						
						for(i=0;i<objDivIds.length;i++) {
							document.getElementById(tmpDivIds[i]).innerHTML = objDivIds[i];
							if ((i>3)&&(i<8)) {
								if (objDivIds[i] != "0") {
									document.getElementById(tmpDivIds[i]).parentNode.style.display="block";
								} else {
									document.getElementById(tmpDivIds[i]).parentNode.style.display="none";
								}
							}
							if (i>7) {
								if (objDivIds[i].length > 0) {
									//child node 5 is question mark image. please change if html is modified
									if (document.getElementById(tmpDivIds[i]).parentNode.childNodes[5]){
									document.getElementById(tmpDivIds[i]).parentNode.childNodes[5].style.display="block";}
								} else {
									//child node 5 is question mark  image. please change if html is modified
									if (document.getElementById(tmpDivIds[i]).parentNode.childNodes[5]){
									document.getElementById(tmpDivIds[i]).parentNode.childNodes[5].style.display="none";
								}
								}
							}
						}
					}
				}		
			}					
 
            // Function performs Get request to absolute url(strUrl)
            // using XmlHttp object (asynchroni)
            // Response returned into objResult element using innerHTML.
            // When state of XmlHttp object is changed - objOnReadyStateChangeFunction called
			
			function GetUrlContent( strUrl, toSend ,objOnReadyStateChangeFunction,filename){
				if (objXMLHttp.HttpMethod == "GET") {
					this.objXmlHttp.open(this.HttpMethod, strUrl, true);
	                this.objXmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=UTF-8');
				} else {
					this.objXmlHttp.open(this.HttpMethod, filename, true);
	                this.objXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	                this.objXmlHttp.setRequestHeader("Content-length", strUrl.length);
	                this.objXmlHttp.setRequestHeader("Connection", "close");
	            }
				
				if(objOnReadyStateChangeFunction){
					this.objXmlHttp.onreadystatechange=function(){
						objOnReadyStateChangeFunction();
					}
				}
				this.objXmlHttp.send(strUrl);
				status = true;
			}
           
            //This function is called when we get the data back from the server.       
            function UpdateDiv(DivId, Page, filename, method ) {
				objXMLHttp.HttpMethod = method;
				if (FirstGo==false && objXMLHttp.GetReadyState()!=4){
					UpdateDivByTimeOut(DivId, Page, filename, method);
				} else {
					FirstGo = false;
					status = false;
						tmpDivIds = DivId.split(',');
						if( Page !='' ) {
							objXMLHttp.GetUrlContent( Page, null ,GetResponse, filename);							
						}
				}
				return true;
            }			
			
			function UpdateDivByTimeOut(a, b, c, d){
				if (FirstGo == true){
				UpdateDiv(a, b, c, d);
				} else {
					if(objXMLHttp.GetReadyState()!=4 && time<2001){
					//alert(time);
					time++;				
						if (time==2001){ alert("server is not answering, please try later");}
						setTimeout('UpdateDivByTimeOut("'+a+'", "'+b+'")', 100);
					}
					if(objXMLHttp.GetReadyState()==4 && time<2001){
						UpdateDiv(a, b, c, d);
					}
				}
			}
/*portfolio.js*/
var tabObjId = "ecommerce_tab";

function doOnLoad()
{
	var cookieValue = getCookie("tabCookie");
	if (cookieValue != "" || cookieValue != null)
	{
		if (cookieValue == "1")
			toggleTab(document.getElementById("ecommerce_tab"));
		if (cookieValue == "2")
			toggleTab(document.getElementById("website_design_tab"));
		if (cookieValue == "3")
			toggleTab(document.getElementById("ebay_store_tab"));
	}
}


function toggleTab(obj)
{
	tabObjId = obj.id;
	ecommerce = document.getElementById("ecommerce_design_portfolio");
	webDesign = document.getElementById("website_design_portfolio");
	ebayStore = document.getElementById("ebay_store_design");
	
	ecommerceTab = document.getElementById("ecommerce_tab");
	webdesignTab = document.getElementById("website_design_tab");
	ebaystoreTab = document.getElementById("ebay_store_tab");
	
	if (obj.id == "ecommerce_tab")
	{
		ecommerce.style.display = "block"
		webDesign.style.display = "none"
		ebayStore.style.display = "none"
		setCookie("tabCookie", 1)		
	}
	
	if (obj.id == "website_design_tab")
	{
	
		ecommerce.style.display = "none"
		webDesign.style.display = "block"
		ebayStore.style.display = "none"
		setCookie("tabCookie", 2)
	}
	
	if (obj.id == "ebay_store_tab")
	{
		ecommerce.style.display = "none"
		webDesign.style.display = "none"
		ebayStore.style.display = "block"
		setCookie("tabCookie", 3)
	}	
	
	var portfolioTabArray = getElementsByClassName("portfolio_tab_button")

	for (i = 0; i < portfolioTabArray.length; i++)
	{
		if (obj == portfolioTabArray[i])
		{
			portfolioTabArray[i].style.color = "#ffffff";
			portfolioTabArray[i].style.background = "url(/images/design/buttons/portfolio_hover.png) no-repeat";
		} else {
			portfolioTabArray[i].style.color = "#0f1d31";
			portfolioTabArray[i].style.background = "url(/images/design/buttons/portfolio.png) no-repeat";
		}
	}
}

function tabHover(obj) 
{
	if (obj.id != tabObjId)
	{
		obj.style.background = "url(/images/design/buttons/portfolio_hover.png) no-repeat";
		obj.style.color = "#ffffff"
	}
}

function tabOut(obj) 
{
	if (obj.id != tabObjId)
	{		
		obj.style.color = "#0f1d31"
		obj.style.background = "url(/images/design/buttons/portfolio.png) no-repeat";
	}
}

function getElementsByClassName(classname, node)  
{
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function filterportfolios(sel) 
{
	
	var category;
	var divs = [];
	var cats, isCat;
	var Taitl;
	if(sel.options.selectedIndex == 0){
      //alert('Please choose an option');
      return false;
   }
   else{
	category = sel.options[sel.selectedIndex].value;
      
      divs = getElementsByClassName("portfoliosngl", document.getElementById("ebay_store_design"));
	  
	  for(var i=0; i<divs.length; i++)
        {
		Taitl = divs[i].title;
		cats = Taitl.split(",");
		isCat = false;
		for(var j=0; j<cats.length; j++)
			{
			if(category==cats[j]) {
				isCat = true;
			}
			}
		if(isCat) {
			divs[i].style.display = "";	
		}
		else {
			divs[i].style.display = "none";	
		}
		}
      
   } 
	return false;
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setTime(exdate.getTime()+(15*60*1000));
var c_value=escape(value) + "; expires="+exdate.toUTCString();
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
