// JavaScript Document
var bUploading = false;

function EmptyThisField(target,stringMatch) // clears the Value of a formField if it currently matches the stringMatch
{	if (stringMatch == "*")
	{	stringMatch == target.value;
	}
	if (target.value == stringMatch)
	{	target.value = "";
	}
}//function EmptyThisField(target,stringMatch) 
function FlipCSS(targetId, newclass)
{	document.getElementById(targetId).className= newclass;
}//function FlipCSS(targetId, newclass)

function HideItem(targetId)
{	document.getElementById(targetId).style.display= 'none';
}//function HideItem(targetId)

function ShowItem(targetId)
{	document.getElementById(targetId).style.display= '';
}//function ShowItem(targetId
							
function SetUploadingFlag()
{	bUploading = true;
}//function SetUploadingFlag()

function RemoveUploadingFlag()
{	bUploading = false;
}//function SetUploadingFlag()

function ToggleItem(targetId)
{	if (	document.getElementById(targetId).style.display == "none")
	{	ShowItem(targetId)
	}else
	{	HideItem(targetId);
	}	
}
function FadeColor(newCol,targetCol,speed,id)
{	var increment = 10;
	var tgtR, tgtG, tgtB, newR, newG, newB;
	newR = parseInt(newCol.substr(1,2),16);
	newG = parseInt(newCol.substr(3,2),16);
	newB = parseInt(newCol.substr(5,2),16);
	tgtR = parseInt(targetCol.substr(1,2),16);
	tgtG = parseInt(targetCol.substr(3,2),16);
	tgtB = parseInt(targetCol.substr(5,2),16);
	document.getElementById(id).style.background = newCol;
	//determine the next newCol
	if (newCol != targetCol)
	{
		if (newR < tgtR -increment)
		{	newR= newR + increment;	
		}else{
			if (newR > tgtR+increment)
			{	newR= newR - increment;	
			}else
			{	newR = tgtR;
			}
		}
		if (newG < tgtG-increment)
		{	newG= newG + increment;	
		}else{
			if (newG > tgtG+increment)
			{	newG= newG - increment;	
			}else
			{	newG = tgtG;
			}
		}
		if (newB < tgtB-increment)
		{	newB= newB + increment;	
		}else{
			if (newB > tgtB+increment)
			{	newB= newB - increment;	
			}else
			{	newB = tgtB;
			}
		}	
		futureCol = "#";
		if (newR < 16)
		{	futureCol += "0";
		} 
		futureCol += newR.toString(16);
		if (newG < 16)
		{	futureCol += "0";
		} 
		futureCol += newG.toString(16);
		if (newB < 16)
		{	futureCol += "0";
		} 
		futureCol += newB.toString(16);
		//alert(futureCol +":"+ newR +":"+newG+":"+newB);
		setTimeout( "FadeColor('"+ futureCol+"','"+ targetCol+"',"+speed+",'"+id+"')",speed);
	}	
}//function FadeItem()


function AddSlashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function StripSlashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}
function verifyPasswords(bTestSubstrings,ob1,ob2,messageId)  //matches ob1 against ob2
{ if (ob1.value != ob2.value)
	{	
		if(ob2.value != "")//if the other field isnt blank we have something to compare against.
		{	//check for substring match to see if we're typing. 
			//alert(ob1.value
			if ((bTestSubstrings)&&(ob2.value.substr(0,ob1.value.length) == ob1.value))
			{	
				document.getElementById(messageId).innerHTML = "";				
			}else{				
				document.getElementById(messageId).innerHTML = " Passwords do not match";
			}				
		}else{
			document.getElementById(messageId).innerHTML = "";
		}
	}else
	{	// they match but are they long enough. 
		if (ob1.value.length < 6)
		{	
			document.getElementById(messageId).innerHTML = " Password is too short. Must be at least 6 characters long.";
		}else
		{
			document.getElementById(messageId).innerHTML = "";
		}
	}
}//function verifyPasswords()

function SendLogoutRequest()
{	document.getElementById("statusIndicator").style.color = "#fb9822";
	document.getElementById("statusIndicator").innerHTML = "Logging Out....";
	logoutRequestObject=GetXmlHttpObject();
	var url="../responses/logout.php";
	logoutRequestObject.onreadystatechange=GetLogoutResponse;
	logoutRequestObject.open("GET",url,true);
	logoutRequestObject.send(null);
}//SendLogoutRequest()

function GetLogoutResponse()
{	if (logoutRequestObject.readyState == 4)
	{	if (logoutRequestObject.responseText == "true")
		{	window.location = "../index.php";
			document.getElementById("statusIndicator").style.color = "#fb9822";
			document.getElementById("statusIndicator").innerHTML = "Logged Out....";//alert("you have been logged out.");
		}			
	}
}//GetLogoutResponse()
function PreloadImages()
	{
		MM_preloadImages('images/site-h_06.gif',
			'images/site-h_32.gif',
			'images/site-h_07.gif',
			'images/site-h_08.gif',
			'images/site-h_09.gif',
			'images/site-h_16.gif',
			'images/site-h_20.gif',
			'images/site-h_21.gif');
	}//function PreloadImages()
<!--
	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_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_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 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];}
	}
	//-->