// JavaScript Document

var http_request_chat = false;
var bgndTimer;
var numbness;
 var viewportwidth;
 var viewportheight;
 var chatAjaxTimer;
 var footMargin = "32";
var fullPageHeight;
var pageHeight3;
var passchange = ""; 

function newBg(where) {

	var whereMe = where;
   clearTimeout(bgndTimer);
   var scrollAmount = 'start';
   var scrOfX = 'start';
   
numbness=Math.ceil(23*Math.random());
x=new Image;
if (whereMe == 'other'){
x.src='../images/bg/fr-bg-'+numbness+'.jpg';
}
else {
x.src='images/bg/fr-bg-'+numbness+'.jpg';
}

iw=x.width;
ih=x.height;

	   var pageWidth;
	   var pageHeight;
	   var pageHeight2;
	   var underHeight;
	   
	   
	 	//document.getElementById('bgStretch').height = "340px";   
	  
	//  document.getElementById('pageUnder').style.height = "340px";   
  	  
if( window.innerHeight && window.scrollMaxY ) {
pageWidth = window.innerWidth + window.scrollMaxX;
pageHeight2 = window.innerHeight + window.scrollMaxY;
}
// all but Explorer Mac
else if( document.body.scrollHeight > document.body.offsetHeight ) 
{
pageWidth = document.body.scrollWidth;
pageHeight2 = document.body.scrollHeight;
}	   
else if (typeof document.height != 'undefined') {
pageHeight2 = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
pageHeight2 = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
pageHeight2 = document.body.scrollHeight;
} 

// works in Explorer 6 Strict, Mozilla (not FF) and Safari
else 
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft; pageHeight2 = document.body.offsetHeight + document.body.offsetTop; }
 
 
 
/*
   
  // Work out view area 
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
   
    if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth;
      viewportheight = window.innerHeight;
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth;
       viewportheight = document.documentElement.clientHeight;
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
       viewportheight = document.getElementsByTagName('body')[0].clientHeight;
 }
 

// Work out scroll amount


 if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrollAmount = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrollAmount = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrollAmount = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  if (!scrollAmount || scrollAmount== 'start'){
  scrollAmount = document.body.scrollTop;
  }
    if (!scrOfX || scrOfX== 'start'){
  scrOfX = document.body.scrollLeft;
  }
  
// Calculations and set background position


var posFin = viewportheight - ih + scrollAmount;
//var bgFlt = (viewportheight + scrollAmount) - ((fullPageHeight - (viewportheight + scrollAmount)) - 32);
var bgFlt = (viewportheight + scrollAmount);
var bgWid = viewportwidth + scrOfX;
//var maxiScroll = document.body.maxVPosition;
//alert(maxiScroll);

/*
  // Work out max height
 	   var pageWidth;
  if( window.innerHeight && window.scrollMaxY ) {
pageWidth = window.innerWidth + window.scrollMaxX;
fullPageHeight = window.innerHeight + window.scrollMaxY;
}
// all but Explorer Mac
else if( document.body.scrollHeight > document.body.offsetHeight ) 
{
pageWidth = document.body.scrollWidth;
fullPageHeight = document.body.scrollHeight;
}	   
else if (typeof document.height != 'undefined') {
fullPageHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
fullPageHeight = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
fullPageHeight = document.body.scrollHeight;
} 

// works in Explorer 6 Strict, Mozilla (not FF) and Safari
else 
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft; fullPageHeight = document.body.offsetHeight + document.body.offsetTop; }


if (fullPageHeight == (viewportheight + scrollAmount)){
bgFlt = bgFlt - 32;	
}
*/

//if ((viewportheight + scrollAmount) <= (fullPageHeight - 32)){
//var bgFlt = viewportheight + scrollAmount;
//bgFlt = (fullPageHeight - (fullPageHeight - (viewportheight + scrollAmount)) - 32);
//}
//var stretchHeight;
//stretchHeight = document.getElementById('bgStretch').height;
//stretchHeight = stretchHeight + 300;
//alert(stretchHeight);

pageHeight2 = pageHeight2 - 247;

if (whereMe == 'other'){
document.getElementById('bgndFloat').style.background='url(../images/bg/fr-bg-'+numbness+'.jpg)';
}
else {
document.getElementById('bgndFloat').style.background='url(images/bg/fr-bg-'+numbness+'.jpg)';
}
document.getElementById('bgndFloat').style.backgroundRepeat="no-repeat";
document.getElementById('bgndFloat').style.backgroundPosition="right bottom";
document.getElementById('bgndFloat').style.width = "650px";
document.getElementById('bgndFloat').style.top = "0px";
document.getElementById('bgndFloat').style.left = "50%";
document.getElementById('bgndFloat').style.marginLeft = "-190px";
document.getElementById('bgndFloat').style.height = pageHeight2+"px";


/*
alert(ih+'  -  '+viewportheight+'     -      '+scrollAmount+'     -      '+posFin+ '   w:' + document.getElementById('bgndFloat').style.width + '     h:'+document.getElementById('bgndFloat').style.height+'   -   ' + maxiScroll);
*/

bgndTimer = setTimeout("newBg('" + whereMe + "')", 10000);
}



   function chatAjax(url, parameters) {
      http_request_chat = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request_chat = new XMLHttpRequest();
         if (http_request_chat.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request_chat.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request_chat = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request_chat = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request_chat) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request_chat.onreadystatechange = alertChat;
      http_request_chat.open('POST', url, true);
      http_request_chat.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request_chat.setRequestHeader("Content-length", parameters.length);
      http_request_chat.setRequestHeader("Connection", "close");
      http_request_chat.send(parameters);
   }

   function alertChat() {
      if (http_request_chat.readyState == 4) {
         if (http_request_chat.status == 200) {
            //alert(http_request.responseText);
            result = http_request_chat.responseText;
            document.getElementById('chatNo').innerHTML = result;            
         } else {
           // alert('There was a problem with the request.');
         }
      }
   }
   
   function getChatNo(where) {
	   var whereMe5;
	   whereMe5 = where;
	   clearTimeout(chatAjaxTimer);
      var poststr = "";
	  if (whereMe5 == 'sitewide'){
      chatAjax('../aquires/frontChatNo.php', poststr);
	  }
	  else{
		chatAjax('aquires/frontChatNo.php', poststr);  
	  }
	     chatAjaxTimer = setTimeout("getChatNo('" + whereMe5 + "')", 60000);
   }
   
   // Window height funcions
   
   
   
   function resizePage(where){
	   
	   var pageWidth;
	   var whereMe = where;
	   var pageHeight;
	   var pageHeight2;
	   var underHeight;
	 
	   
	 	//document.getElementById('bgStretch').height = "340px";   
	  
	//  document.getElementById('pageUnder').style.height = "340px";   
  	  
if( window.innerHeight && window.scrollMaxY ) {
pageWidth = window.innerWidth + window.scrollMaxX;
fullPageHeight = window.innerHeight + window.scrollMaxY;
}
// all but Explorer Mac
else if( document.body.scrollHeight > document.body.offsetHeight ) 
{
pageWidth = document.body.scrollWidth;
fullPageHeight = document.body.scrollHeight;
}	   
else if (typeof document.height != 'undefined') {
fullPageHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
fullPageHeight = document.documentElement.scrollHeight;
}
else if (document.body && typeof document.body.scrollHeight !=
'undefined') {
fullPageHeight = document.body.scrollHeight;
} 

// works in Explorer 6 Strict, Mozilla (not FF) and Safari
else 
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft; fullPageHeight = document.body.offsetHeight + document.body.offsetTop; }
 
  pageHeight = fullPageHeight - 150;
 pageHeight2 = fullPageHeight - 70;
  underHeight = fullPageHeight - 202;
  underHeight2 = fullPageHeight - 102;
  pageHeight3 = fullPageHeight - 344;
	if(whereMe == 'other'){
	document.getElementById('bgStretch').height = pageHeight2 +"px"; 
	document.getElementById('pageUnder').style.height = underHeight2 +"px"; 
	}
	else if(whereMe == "engage"){
		  pageHeight3 = fullPageHeight + 180;
		  var pageHeight5 ;
		  pageHeight5 = fullPageHeight + 155;
	document.getElementById('bgStretch').style.height = pageHeight3 +"px"; 	
	document.getElementById('pageFrame').style.height = pageHeight5 +"px";
	}
	else{
	document.getElementById('bgStretch').style.height = pageHeight3 +"px"; 
	//  document.getElementById('pageUnder').style.height = underHeight +"px"; 
	}
 
	  
	  
	  
	  footMargin = "32";
	   
   }
   


// Drag stuff


function MM_scanStyles(obj, prop) { //v9.0
  var inlineStyle = null; var ccProp = prop; var dash = ccProp.indexOf("-");
  while (dash != -1){ccProp = ccProp.substring(0, dash) + ccProp.substring(dash+1,dash+2).toUpperCase() + ccProp.substring(dash+2); dash = ccProp.indexOf("-");}
  inlineStyle = eval("obj.style." + ccProp);
  if(inlineStyle) return inlineStyle;
  var ss = document.styleSheets;
  for (var x = 0; x < ss.length; x++) { var rules = ss[x].cssRules;
	for (var y = 0; y < rules.length; y++) { var z = rules[y].style;
	  if(z[prop] && (rules[y].selectorText == '*[ID"' + obj.id + '"]' || rules[y].selectorText == '#' + obj.id)) {
        return z[prop];
  }  }  }  return "";
}

function MM_getProp(obj, prop) { //v8.0
  if (!obj) return ("");
  if (prop == "L") return obj.offsetLeft;
  else if (prop == "T") return obj.offsetTop;
  else if (prop == "W") return obj.offsetWidth;
  else if (prop == "H") return obj.offsetHeight;
  else {
    if (typeof(window.getComputedStyle) == "undefined") {
	    if (typeof(obj.currentStyle) == "undefined"){
		    if (prop == "P") return MM_scanStyles(obj,"position");
        else if (prop == "Z") return MM_scanStyles(obj,"z-index");
        else if (prop == "V") return MM_scanStyles(obj,"visibility");
	    } else {
	      if (prop == "P") return obj.currentStyle.position;
        else if (prop == "Z") return obj.currentStyle.zIndex;
        else if (prop == "V") return obj.currentStyle.visibility;
	    }
    } else {
	    if (prop == "P") return window.getComputedStyle(obj,null).getPropertyValue("position");
      else if (prop == "Z") return window.getComputedStyle(obj,null).getPropertyValue("z-index");
      else if (prop == "V") return window.getComputedStyle(obj,null).getPropertyValue("visibility");
    }
  }
}

function MM_dragLayer(objId,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v9.01
  //Copyright 2005-2006 Adobe Macromedia Software LLC and its licensors. All rights reserved.
  var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all;
  var NS=(!IE&&document.getElementById); if (!IE && !NS) return false;
  retVal = true; if(IE && event) event.returnValue = true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = document.getElementById(objId); if (!curDrag) return false;
    if (!document.allLayers) { document.allLayers = new Array();
      with (document){ if (NS) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div");
        for (i=0;i<spns.length;i++) if (MM_getProp(spns[i],'P')) allLayers[allLayers.length]=spns[i];}
        for (i=0;i<all.length;i++) {
	        if (MM_getProp(all[i],'P')) allLayers[allLayers.length]=all[i]; 
        }
    } }
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
  
    curDrag.MM_oldZ = MM_getProp(curDrag,'Z');
    curLeft = MM_getProp(curDrag,'L');
    if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
    curTop = MM_getProp(curDrag,'T');
    if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
    } else {
    var theEvent = ((NS)?objId.type:event.type);
    if (theEvent == 'mousedown') {
      var mouseX = (NS)?objId.pageX : event.clientX + document.body.scrollLeft;
      var mouseY = (NS)?objId.pageY : event.clientY + document.body.scrollTop;
      var maxDragZ=null; document.MM_maxZ = 0;
      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
        var aLayerZ = MM_getProp(aLayer,'Z');
        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
        var isVisible = (MM_getProp(aLayer,'V')).indexOf('hid') == -1;
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (NS) { parentLayer = aLayer.parentNode;
            while (parentLayer != null && parentLayer != document && MM_getProp(parentLayer,'P')) {
              parentL += parseInt(MM_getProp(parentLayer,'L')); parentT += parseInt(MM_getProp(parentLayer,'T'));
              parentLayer = parentLayer.parentNode;
              if (parentLayer==document) parentLayer = null;
          } } else if (IE) { parentLayer = aLayer.parentElement;       
            while (parentLayer != null && MM_getProp(parentLayer,'P')) {
              parentL += MM_getProp(parentLayer,'L'); parentT += MM_getProp(parentLayer,'T');
              parentLayer = parentLayer.parentElement; } }
          var tmpX=mouseX-((MM_getProp(aLayer,'L'))+parentL+MM_hLeft);
          var tmpY=mouseY-((MM_getProp(aLayer,'T'))+parentT+MM_hTop);
          if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += MM_getProp(aLayer,'W');
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += MM_getProp(aLayer,'H');
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        document.onmousemove = MM_dragLayer;
        curLeft = MM_getProp(curDrag,'L');
        curTop = MM_getProp(curDrag,'T');
        if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          var newZ = parseInt(document.MM_maxZ)+1;
          eval('curDrag.'+('style.')+'zIndex=newZ');
          if (!curDrag.MM_dropBack) document.MM_maxZ++; }
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        var mouseX = (NS)?objId.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS)?objId.pageY : event.clientY + document.body.scrollTop;
        var newLeft = mouseX-MM_oldX; var newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS){style.left = newLeft + "px"; style.top = newTop + "px";}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        if (MM_dragJS) eval(MM_dragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-(MM_getProp(document.MM_curDrag,'L')),2)+
             Math.pow(MM_targT-(MM_getProp(document.MM_curDrag,'T')),2))<=MM_tol) {
          if (NS) {style.left = MM_targL + "px"; style.top = MM_targT + "px";}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      document.MM_curDrag = null;
    }
    if (NS) document.routeEvent(objId);
  } return retVal;
}

function moveChatBg(){
	var chl;
	var cht;
	chl = document.getElementById('chatManDo').style.left;
	cht = document.getElementById('chatManDo').style.top;
	document.getElementById('chatUnder').style.top = cht;
	document.getElementById('chatUnder').style.left = chl;
	
}




function updateStylesheets() {
	var isIE = /*@cc_on!@*/false;
	if (isIE != false){
	var i,a,s;
	a=document.getElementsByTagName('link');
	for(i=0;i<a.length;i++) {
		s=a[i];
		if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {
			var h=s.href.replace(/(&|\\?)forceReload=d /,'');
			s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf());
		}
	}
	}
}



 function pwrdTest(){
					  var scorer = 0;
					    var strHere = document.getElementById('password2').value;
						
					  if(document.getElementById('password2').value != "" && document.getElementById('password3').value != ""){ 
					  
					  if(document.getElementById('password2').value != document.getElementById('password3').value){
					  
					  document.getElementById('pwrdSpan').innerHTML="&nbsp;<font style='color:red'>Your passwords don't match, please re-enter them.</font>"; 
					  document.getElementById('password2').value = ''; 
					  document.getElementById('password3').value = '';
					  
					  }
					  else{
	
var lenggy = strHere.length;

if (isNaN(strHere) == false){
// numbers
//alert('numbers');
scorer = 1;
}
else{
var alphaExp = /^[a-zA-Z]+$/;
	if(strHere.match(alphaExp)){
		// letters
		//alert('letters');
		scorer = 1;
	}
else{
// alphanumeric
//alert('alphanumeric');
scorer = 2;
}

}

var caseCount = strHere.replace(/[^A-Z]/g, "").length;
var casePercent = (caseCount/lenggy) * 100;


if (casePercent > 0 && casePercent < 100){
scorer = scorer * 1.25;
}



scorer = scorer * lenggy;
if (scorer < 7){
document.getElementById('pwrdSpan').innerHTML="&nbsp;<font style='color:black'>Low strength</font>&nbsp;:&nbsp;<a onclick='pwrdreset()' href='#'>reset</a>";
}
else if (scorer >= 7 && scorer < 14){
document.getElementById('pwrdSpan').innerHTML="&nbsp;<font style='color:black'>Medium strength</font>&nbsp;:&nbsp;<a onclick='pwrdreset()' href='#'>reset</a>";
}
else if (scorer >= 14 && scorer < 22){
document.getElementById('pwrdSpan').innerHTML="&nbsp;<font style='color:black'>High strength</font>&nbsp;:&nbsp;<a onclick='pwrdreset()' href='#'>reset</a>";
}
else{
document.getElementById('pwrdSpan').innerHTML="&nbsp;<font style='color:black'>Very high strength</font>&nbsp;:&nbsp;<a onclick='pwrdreset()' href='#'>reset</a>";
}

document.getElementById('password2').disabled = true;
document.getElementById('password3').disabled = true;

document.getElementById('pwrdfinal').value = strHere;
//passchange = "set";
//alert(casePercent+' : ' + scorer);
					  }
					  
					 } 
					 else {
						//passchange = ""; 
						
					 }
	
				 }
				
				
				function pwrdreset(){
					document.getElementById('password2').disabled = false;
document.getElementById('password3').disabled = false;
document.getElementById('password2').value = ''; 
					  document.getElementById('password3').value = '';
document.getElementById('pwrdSpan').innerHTML='';
				}