
/* POP-UP WINDOW */
function openwin(URL,theHeight,theWidth,addScroll) {
	var nXpos = (screen.availWidth - theWidth) / 2; 
	var nYpos = (screen.availHeight - theHeight) / 2; 
	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + 'toolbar=0,scrollbars=' + addScroll + ',location=0,statusbar=0,menubar=0');
	win.focus();
}

/* OPEN EXTERNAL LINKS IN NEW WINDOW */
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}


/* --------------------------------------- */
/* SET A COOKIE */
/* --------------------------------------- */
function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
		expire.setTime(today.getTime() + 3600000*24*nDays);
		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}


/* --------------------------------------- */
/* SET REGION COOKIE BASED ON TIMEZONE */
/* --------------------------------------- */

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function regionCookie() {
	
	var rightNow = new Date();
	var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
	var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
	var temp = date1.toGMTString();
	var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
	var temp = date2.toGMTString();
	var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
	var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
	var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
	
	if (hoursDiffStdTime in {'0':'','1':''}) { // IS EUROPE
		SetCookie('myRegion','uk',364);
	} else {
		SetCookie('myRegion','us',364);
	}
	
}



/* ******* START LOADER ******* */
function addLoadEvent(func) {   
  var oldonload = window.onload;   
  if (typeof window.onload != 'function') {   
    window.onload = func;   
  } else {   
    window.onload = function() {   
      if (oldonload) {   
        oldonload();   
      }   
      func();   
    }   
  }   
}   
  
addLoadEvent(externalLinks);
addLoadEvent(regionCookie);
/* ******* END LOADER ******* */



/* --------------------------------------- */
/* REPORTING TOGGLE */
/* --------------------------------------- */
/*
function reportTog(thmb,theID,whichImg,newImg) {
	var adImg = 'ad' + theID;
	var mpImg = 'mp' + theID;
	if(thmb.className=='mp') {
		document.getElementById(adImg).src = '/images/ad_off.jpg';
		document.getElementById(mpImg).src = '/images/mp_on.jpg';
	} else if(thmb.className=='ad') {
		document.getElementById(adImg).src = '/images/ad_on.jpg';
		document.getElementById(mpImg).src = '/images/mp_off.jpg';
	}
	document.getElementById(whichImg).src = '/images/' + newImg;
}
*/




/* --------------------------------------------------- */
/* SET ARRAY OF CLIENT PAGES */
/* --------------------------------------------------- */
var clientArray = new Array();
clientArray[0] = "amber-composites.php";
clientArray[1] = "the-camden-group.php";
clientArray[2] = "maveron.php";
clientArray[3] = "first-aid-live.php";
clientArray[4] = "perlman-creative-group.php";
clientArray[5] = "brush-research.php";
clientArray[6] = "teasdale.php";
clientArray[7] = "exclusive-luxury-rentals.php";

function next(keyValue) {
	alert(keyValue + ' - ' + clientArray.length);
	/*
	if (currentKey < (imageArray.length - 1)) {
		keyValue = keyValue + 1;
		currentKey++;
	} else {
		var nextClient = clientArray[currentClientKey + 1];
		if (keyValue == clientArray.length) {
			window.location = clientArray[0];
		} else {
			window.location = nextClient;
		}
	}
	return imageArray[keyValue];
	*/
}

function previous(keyValue) {
	var openPage;
	if (currentKey <= (imageArray.length - 1) && currentKey !== 0) {
		keyValue = keyValue - 1;
		currentKey--;
	} else {
		var nextClient = clientArray[currentClientKey - 1];
		if (currentClientKey == 0) {
			window.location = clientArray[clientArray.length];
		} else {
			window.location = nextClient;
		}
	}
	return imageArray[keyValue];
}