// JavaScript Document compiled by Arisia ©2006
// not all functions are used in every website constructed for Clarity Callback
// any copyrights should be copied over if used in other js files.

// this function opens a normal pop-up window that the customer has requested; window sizes are width and height; window position is top and left dimensions.
function callme()
{
window.open('call2you/callme.htm?version=1','callme','width=420,height=420,top=250,left=300');
}
// end function

// this function opens pop-up window when the customer moves away from special pages. In the body tag place, onunload="return exit_popup();" , to capture customer moving away from page.
function exit_popup()
{
	var clarityWindow = window.open('../call2you/callmesorry2.htm?version=3','callme','width=10,height=10,top=100,left=100','resizable=yes');
	self.focus();
	//clarityWindow.blur();
}
// end function


//-----------------------------------------------------------------------------------------------------------
// this function sets the visibility of the layers, plus sets the position of the pop up when it appears.
function setPopUpVisibility(){
	Call2yousetVisibility('callmeouter','visible');
	document.getElementById('callmeouter').innerHTML = "<iframe id='callmeiframe' src='call2you/callme.htm?version=1' height='460' width='410' frameborder='0' allowtransparency='true' scrolling='no'></iframe>";
	// stop automatic pop-up of help version
	clearTimeout(clarity_timeout);
	// animation of the pop-up form across the page. first 2 numbers are final position, last number is speed of transverse.
	//initAnimate('callmeouter',120,100,20);
	movelayer('callmeouter',120,120);// set up layer without animation
	Set_Cookie( 'DontLeaveUs', 'clear', '0', '/', window.location.host);
}
//or
function setPopUpVisibility2(){
	Call2yousetVisibility('callmeouter','visible');
	document.getElementById('callmeouter').innerHTML = "<iframe id='callmeiframe' src='../call2you/callme.htm?version=1' height='460' width='410' frameborder='0' allowtransparency='true' scrolling='no'></iframe>";
	// stop automatic pop-up of help version
	clearTimeout(clarity_timeout);
	// animation of the pop-up form across the page. first 2 numbers are final position, last number is speed of transverse.
	//initAnimate('callmeouter',120,100,20);
	movelayer('callmeouter',120,120);// set up layer without animation
	Set_Cookie( 'DontLeaveUs', 'clear', '0', '/', window.location.host);
}

// this function sets the visibility of the layers, plus sets the position of the pop up when it appears.
function setPopUpHelpVisibility(){
	Call2yousetVisibility('callmeouter','visible');
	document.getElementById('callmeouter').innerHTML = "<iframe id='callmeiframe' src='../call2you/callme.htm?version=2' height='460' width='410' frameborder='0' allowtransparency='true' scrolling='no'></iframe>";
	// animation of the pop-up form across the page. first 2 numbers are final position, last number is speed of transverse.
	//initAnimate('callmeouter',260,120,30);
	movelayer('callmeouter',120,120);// set up layer without animation
	Set_Cookie( 'DontLeaveUs', 'clear', '0', '/', window.location.host);
}

// this function sets the visibility of the layers, plus sets the position of the pop up when it appears.
function setPopUpSorryVisibility(){
	Call2yousetVisibility('callmeouter','visible');
		document.getElementById('callmeouter').innerHTML = "<iframe id='callmeiframe' src='../call2you/callme.htm?version=3' height='460' width='410' frameborder='0' allowtransparency='true' scrolling='no'></iframe>";
	// animation of the pop-up form across the page. first 2 numbers are final position, last number is speed of transverse.
	//initAnimate('callmeouter',260,120,30);
    movelayer('callmeouter',120,120);// set up layer without animation
	// stop automatic pop-up of help version
	clearTimeout(clarity_timeout);
	Set_Cookie( 'DontLeaveUs', 'clear', '0', '/', window.location.host);
}
// timed delay for 'do you require help' layered pop up, in milliseconds
var clarity_timeout;

function timedVisibility(delay){
	<!-- changing the 'theDelay' variable will change pop-up timing. 1000 = 1second. eg 60,000 is 1 minute -->
	var theDelay = delay*1000;
	clarity_timeout = setTimeout('setPopUpHelpVisibility();', theDelay);
}

// timed delay for 'sorry to see your leaving' layered pop up, in milliseconds.
var clarity_timeout2;

function timedVisibility2(){
	<!-- changing the 'theDelay' variable will change pop-up timing. 1000 = 1second. eg 60,000 is 1 minute -->
	var theDelay2 = 2000;
	clarity_timeout2 = setTimeout('setPopUpSorryVisibility();', theDelay2);
}

// this function tries to stop the pop up layer appearing if the pop up window has been successful
function halt_layer(){
	clearTimeout(clarity_timeout2);
}

// closes a layered pop up window
function setPopUpClose(){
	Call2yousetVisibility('callmeouter','hidden');
	movelayer('callmeouter',-495,-495);
}

// function sets visibility of layer
function Call2yousetVisibility(objectID,state) {
	var object = document.getElementById(objectID);
	object.style.visibility = state;
}

//-------------------------------------------------------------------------------------------------------
// sets the layer off screen for Netscape browsers which don't fully support invisable layers
function movelayer(objectID,x,y){
object = document.getElementById(objectID);
		object.style.left=x+'px';
		object.style.top=x+'px';

}

//--------------------------------------------------------------------------------------------------------------------
// Cookie Functions.

// changed by arisia 04/10/2006

function CheckClarityCTP(message){
	var monicor="DontLeaveUs";
	var result=GetCookie(monicor);
	if (result==null){
		Set_Cookie( 'DontLeaveUs', message, '0', '/', window.location.host);
	}
	else{
		if (result=="goodbye"){
			if (message=="hello"){
				setPopUpSorryVisibility();
				Set_Cookie( 'DontLeaveUs', message, '0', '/', window.location.host);
			}else if (message=="clear"){
				Set_Cookie( 'DontLeaveUs', 'hello', '0', '/', window.location.host);
			}
		}
		else if (result!=message){
			if (message!="hold"){
				Set_Cookie( 'DontLeaveUs', message, '0', '/', window.location.host);
			}else{
				Set_Cookie( 'DontLeaveUs', 'goodbye', '0', '/', window.location.host);
			}
		}
	}
}
	
// get named cookie
function GetCookie (name) {  
	var arg = name + "=";
	//alert (arg);
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
			i = document.cookie.indexOf(" ", i) + 1;    
			if (i == 0) break;   
		}  
	return null;
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );
		expires = expires * 1000;
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
//-->

//-----------------------------------------------------------------------------------------------------------------------
// the following script is used to keep the pop-up window on the screen even if the viewer scrolls down .

/***********************************************
* Dock Content script- Created by and © Dynamicdrive.com
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full script
***********************************************/

var offsetfromedge=100 //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array()   //array to cache corresponding clearinterval pointers

function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=0;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
else
obj.source.style.top=100;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


//----------------------------------------------------------------------------------------------------
// animating the pop-up layer
var animateSpeed = null;
var fX = null;
var fY = null;
var cX = null;
var cY = null;
var dX = null;
var dY = null;
var stepX = null;
var stepX = null;
var stepY = null;

function initAnimate(objectID,x,y,animate){

	object = document.getElementById(objectID);
	fX = x;
	fY = y;
	animateSpeed = animate;
	
	cX = object.offsetLeft;
	cY = object.offsetTop;
	dX = Math.abs(fX-cX);
	dY = Math.abs(fY-cY);
	if((dX==0)||(dY==0)){slope=0;}
	else {slope=dY/dX;
		if(dX>=dY){
			if(cX<fX){stepX=animateSpeed;}
			else if(cX>fX){stepX=-animateSpeed;}
			if(cY<fY){stepY=animateSpeed*slope;}
			else if(cY>fY){stepY=-animateSpeed*slope;}
		}
		else if(dX<dY){
			if(cY<fY){stepY=animateSpeed;}
			else if(cY>fY){stepY=-animateSpeed;}
			if(cX<fX){stepX=animateSpeed/slope;}
			else if(cX>fX){stepX=-animateSpeed/slope;}
		}
	}
	animateObject();
}
function animateObject(){
	if((dX>0)||(dY>0)){
		object.style.left=Math.round(cX)+'px';
		object.style.top=Math.round(cY)+'px';
		cX=cX+stepX;
		cY=cY+stepY;
		dX=dX-Math.abs(stepX);
		dY=dY-Math.abs(stepY);
		setTimeout('animateObject()',0);
	}
	else{
		object.style.left=fX+'px';
		object.style.top=fY+'px';
	}
	return;
}

//------------------------------------------------------------------------------------------------
// dragging pop-up layer
var object2 = null;
var ccX = null;
var ccY = null;

function initPage(x,y) {
	ccX=x;
	ccY=y;
	document.onmousedown = pickIt;
	document.onmousemove = dragIt;
	document.onmouseup = dropIt;
}

function pickIt(evt) {
	evt = (evt)?evt:((window.event)?event:null);
	//var objectID = (evt.target)?evt.target.id:((evt.srcElement)?evt.srcElement.id:null);
	//object2 = document.getElementById(objectID);
	object2 = document.getElementById('callmeouter');
	if (object2) {
		object2.style.zIndex = 9;
		ccX = evt.clientX - object2.offsetLeft;
		ccY = evt.clientY - object2.offsetTop;
		return;
		}
	else {
			object2 = null;
			return false;
	}
}

function dragIt(evt) {
	evt = (evt)?evt:((window.event)?event:null);
	if (object2) {
	object2.style.left = evt.clientX - ccX + 'px';
	object2.style.top = evt.clientY - ccY + 'px';
	return false;
	}
}

function dropIt() {
	if (object2) {
		object2.style.zIndex = 9;
		object2 = null;
		return false;
	}
}
//

<!-------------------------------------------------------------------------------------------------------------
// standard functions dealing with checking the form before sending
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 YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}
//-->

<!-------------------------------------------------------------------------------------------------------------
<!-- standard functions dealing with image swapping
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_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_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];}
}
//-->