
function strReplace(str1, str2, str3) { 
  while(str1.indexOf(str2) != -1) {
   str1 = str1.replace(str2, str3);
 } 
  return str1;     
} 

function preview(t)
{
    var tt = document.getElementById(t).value;
    //.value
    //alert(t);
    var w = window.open('','prev');
    w.document.write(tt);

}
function center(oNode)
	{
   		var oParent=oNode.parentElement;
   		oNode.style.left=oParent.offsetWidth/2 - oNode.offsetWidth/2;
	}

function hasParent()
{
	alert(window.parent.location.href);
}
function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   var now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = monthname + 
                    ' ' + 
                    monthday + 
                    ', ' + 
                    year;
   //return dateString;
   DateSpan.innerText = dateString;
   //setTimeout('getCalendarDate()',1000);
} // function getCalendarDate()

function showMDiv(divID)
{
	for (i=1;i<4;i++)
	{ var iobj = 'mDiv' + i
		document.getElementById(iobj).style.display= 'none';
		//alert(iobj);
	}
	document.getElementById(divID).style.display= 'block';
}
function showPf(tabID,divID)
{
	//hide all pages then show the passed page
	for (i=1;i<4;i++)
	{ var iobj = 'tab' + i
		document.getElementById(iobj).className = 'tab';
		//alert(iobj);
	}
	document.getElementById(tabID).className = 'tab-active';
	//hide or show external frame
	showMDiv(divID);
}
function showPage(myPage,tabName,tabID,page,userName)
{
	//hide all pages then show the passed page
	for (i=1;i<6;i++)
	{ var iobj = 'tab' + i
		document.getElementById(iobj).className = 'tab';
	}
	if (myPage=='1')
	{
		//reset tab7 and tab8 to usertab class
		document.getElementById('tab6').className = 'userTab';
		document.getElementById('tab7').className = 'userTab';
		document.getElementById('tab8').className = 'userTab';
		//document.getElementById('tab9').className = 'userTab';
	}
	//set the class of the active tab to tab-active
	document.getElementById(tabID).className = 'tab-active';
	//hide or show external frame
	if (tabName == 'AbtMe' ){ 
		document.getElementById('externalFrame').style.display='none'
		document.getElementById('AbtMe').style.display=''
	}
	else {
		var curFrame = frames('externalFrame').location.href;
		document.getElementById('externalFrame').style.display='';
		document.getElementById('AbtMe').style.display='none';
		
		//chk if user going to a tab page that's already open, 
		//if they're just show the page rather than reload
		if (curFrame.indexOf(page + '?targetUser=' + userName) < 0)
		{ 	//show loading layer
			document.getElementById("loadingDIV").style.display = ''
			frames('externalFrame').location.href= page + '?targetUser=' + userName;
		}
	}
	 
}


	function checkBoxes() { 
		//get collection of chkboxes 
		var chkColl = document.all('SelMsg');
		if (document.getElementById('SelAllMsgs').checked)
		{ 
			//make sure collection is greater than 1
			if (chkColl.length > 1)
			{ 
				for (i=0; i < chkColl.length; i++) 
				{ 
					chkColl[i].checked = true; 
					chkColl[i].parentElement.parentElement.className = 'SelMsgRow'
				} 
			}
		}
		else 
		{ 
			for (i=0; i < chkColl.length; i++) 
				{ 
					chkColl[i].checked = false; 
					chkColl[i].parentElement.parentElement.className = 'tahoFont'
				} 
		} 
	}
	
function execRemote(URL) 
{ 
   var xmlhttp = new ActiveXObject("Msxml2.xmlHttp"); 
   xmlhttp.open("GET", URL, false); 
   xmlhttp.send(); 
   var txt = xmlhttp.responseText;
  return txt;
} 

function showEditPage(userName)
{
	//hide all pages then show the passed page
	for (i=1;i<7;i++)
	{ 	var iobj = 'tab' + i
		document.getElementById(iobj).className = 'tab';
	}
	// show external frame
		var curFrame = frames('externalFrame').location.href;
		document.getElementById('externalFrame').style.display='';
		document.getElementById('AbtMe').style.display='none';
		
		//chk if user going to a tab page that's already open, 
		//if they're just show the page rather than reload
		if (curFrame.indexOf('manageProfile.aspx?targetUser=' + userName) < 0)
		{ 	//show loading layer
			document.getElementById("loadingDIV").style.display = ''
			frames('externalFrame').location.href= 'manageProfile.aspx?targetUser=' + userName;
		}	 
}

function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour + 
                    ':' + 
                    minute + 
                    ':' + 
                    second + 
                    " " + 
                    ap;
   //return timeString;
   ClockSpan.innerText = timeString;
   setTimeout('getClockTime()',1000);
} 

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_findObj(n, d) { //v3.0
  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); 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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function CellColOn(id, col) {
        if (!id.contains(event.fromElement)) {
            id.bgColor = col;
        }
    }
function CellColOff(id,col) {
        if (!id.contains(event.toElement)) {
            id.bgColor = col;
        }
    }


function posLayerOld(){
//get screen height
var scrHgt = screen.height
var scrWth = screen.width
var PopHgt = 200
var PopWth = 320

var FinalTopPos = (scrHgt/2) -  (PopHgt/2)
var FinalLeftPos = (scrWth/2) -  (PopWth/2) -60
MovieLayer.style.pixelLeft = FinalLeftPos
MovieLayer.style.pixelTop = FinalTopPos 
}


//=============================================
// end of drag queens
//=============================================


function uploadphoto() {
	//validates picture editing form b4 sending
	var thephoto = document.photoform.PhotoLink.value
	var photofile = document.photoform.photofile.value
	
	if (trim(thephoto).length > 0)  
		{
		//alert(thephoto.length);
		if (thephoto.indexOf('http') >=0) 
			{ 
			return true;
			
			}
			else
			{
			alert('[' + thephoto + '] is not a valid Image Link \nLink must be of the type http://www.mysite.com/picture.gif')
			}
		}
		else
		{
			if (trim(photofile).length == 0)
			{
				alert('A Valid File Name is Required')
			}
			else
			{
			return true;
			
			}
		}
	}


		
function toggle(e)
{
	if (e.style.display == "none")
	{
		e.style.display = "";
	}
	else
	{
		e.style.display = "none";
	}
}


function validateTxt(txt,elName)
				  {
				  	var re = /[^a-zA-Z0-9\s_-]/
					if (txt.search(re) != -1)
					{
						alert('Invalid Characters detected\n-  ' + elName + ' can only contain alphanumeric Characters [a-z] or [A-Z] or [0-9]');
						return false;
					}
				  }

function validateUsername(txt,elName)
				  {
				  	var re = /[^a-zA-Z0-9_-]/
					if (txt.search(re) != -1)
					{
						alert('Invalid Characters detected\n-  ' + elName + ' can only contain alphanumeric Characters [a-z] or [A-Z] or [0-9] or [_-]\n No spaces are allowed. Please try again');
						event.returnValue=false;
					}
				  }

function validateNum(txt,elName)
				  {
				  	var re = /[^0-9\s]/
					if (txt.search(re) != -1)
					{
						alert('Invalid Characters detected\n-  ' + elName + ' can only contain Numeric Characters [0-9]');
						event.returnValue=false;
					}
				  }


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function clearALLRows(RowName,RowCount)
{
	for (i=1;i<=RowCount;i++) 
		{	
		RowNam = RowName + i
		document.getElementById(RowNam).className= 'Tahofont';
  		}

}

function getRadioValue(radioName) 
{
  var coll;
  coll = document.all(radioName); // document.AllTransFrm.TransID; //[radioName];
  //alert (coll[0].value)
  //alert ('first' + coll[0].value)
  if (coll.length != undefined)// if the radio button coll is an array (remember Gerald, one button is not an array)
  	{
		//alert (coll.length)
  		for (i=0;i<coll.length;i++) 
		{
    		if (coll[i].checked)
    			return(coll[i].value);
  		}
	}
	else
		{
		//alert ('none ' + coll.value)
		return coll.value;
		}
}

function rowsChecked(chkBoxID)
{
	//returns the number of rows chked within a checkbox list
	var chkBox;var num = 0
  chkBox = document.all(chkBoxID); // document.AllTransFrm.TransID; //[radioName];
  //alert (coll[0].value)
  //alert ('first' + coll[0].value)
  if (chkBox.length != undefined)// if the chkBox collection is an array (remember Gerald, a single checked box is not an array)
  	{
		//alert (coll.length)
		
  		for (i=0;i<chkBox.length;i++) 
		{
    		if (chkBox[i].checked)
    			num = num + 1;
  		}
		return num;
	}
	else
		{ 
		var chkB = document.getElementById(chkBoxID);
		if (chkB.checked)
			return 1;
		else
			return 0;
		}	
}

function CheckSlang(slang) {
	   var emailfrm = document.SubmitFrm
	   var ErrMsg = ''
	  
		if (trim(emailfrm.SlangDef.value) ==  '' ) {
			ErrMsg = ErrMsg + '\n - ' + slang + '\'s Definition is required'
		}
		if  (ErrMsg != ''){
			alert(':::SOBAN.net Sasse - Speak Encyclopedia \n =================================' +ErrMsg)
	  	}
		else
			emailfrm.submit()
			//alert('submit form now')
}


  function CheckPass() 
  {
	   var ErrMsg = '';
	   
	   var user = trim(document.getElementById("txtUserName").value)
		if ( user ==  '' ) 
		{
			ErrMsg = '\n - A valid User Name is required';
			callErr(ErrMsg);
			return false;
		}
		//chk pass wd
	  	passwd = trim(document.getElementById("txtPass").value)
      	if ( passwd ==  '' || passwd.length < 5) 
	  	 {
			ErrMsg = '\n - A valid Password is required and must be at least 5 letters long';
			callErr(ErrMsg);
			return false;
		} 
		if  (passwd  != trim(document.getElementById("txtVPass").value) )
		{
			ErrMsg = '\n - Passwords do not Match';
			callErr(ErrMsg);
			return false;
	  	}
		if (trim(document.getElementById("txtFName").value) ==  '' ) 
		{
			ErrMsg = '\n - Your First Name is required';
			callErr(ErrMsg);
			return false;
		}
		
		if (trim(document.getElementById("txtLName").value) ==  '' ) {
			ErrMsg = '\n - Your Last Name is required';
			callErr(ErrMsg);
			return false;
		}
		var EmailAdd = trim(document.getElementById("txtEmail").value)
		 if (EmailAdd ==  '') {
			ErrMsg = '\n - A valid Email Address is required';
			callErr(ErrMsg);
			return false;
		}
		 if (trim(document.getElementById("txtCity").value) ==  '' ) {
			ErrMsg = '\n - Your City of Residence is Required';
			callErr(ErrMsg);
			return false;
		}  
		
		if (trim(document.getElementById("txtDOBDay").value) <= 0 || trim(document.getElementById("txtDOBDay").value) > 31 ) {
			ErrMsg = '\n - A valid Day of Birth is required and must be between 1st and 31st';
			callErr(ErrMsg);
			return false;
		}		
		
		return true;
}


function verifyPass(oldE,newE,VnewE) 
{
	   var newval = document.getElementById(newE);
	   var Vnewval = document.getElementById(VnewE);
	   var oldval = document.getElementById(oldE);
	   var ErrMsg = '';
	   var passwd = trim(oldval.value);
       if ( passwd ==  '' ){ 
			ErrMsg = '\n - Invalid Old Password.';
			callErr(ErrMsg);
			return false;
	   }
		if ( trim(newval.value).length < 5) {
			ErrMsg = '\n - Invalid New Password. It must be at least 5 letters long';
			callErr(ErrMsg);
			return false;
		}
		if  (trim(newval.value) != trim(Vnewval.value) ){
			ErrMsg = '\n - Your New Passwords do not Match';
			callErr(ErrMsg);
			return false;
	  	}
		else
			
		return true;
}

 
  function doToggleView()
  {  
    if(viewMode == 1)
    {
      iHTML = iView.document.body.innerHTML;
      iView.document.body.innerText = iHTML;
      
      // Hide all controls
      tblCtrls.style.display = 'none';
      selFont.style.display = 'none';
      selSize.style.display = 'none';
      iView.focus();
      
      viewMode = 2; // Code
    }
    else
    {
      iText = iView.document.body.innerText;
      iView.document.body.innerHTML = iText;
      
      // Show all controls
      tblCtrls.style.display = 'inline';
      selFont.style.display = 'inline';
      selSize.style.display = 'inline';
      iView.focus();
      
      viewMode = 1; // WYSIWYG
    }
  }
  
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function iTip(tipText) {
	
		xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		
		var iT = document.getElementById("iTip");
		var iHd = document.getElementById("iTipData");
		
		//====== reposition tip box ===============
		if ((xMousePos - 160 > 0) )
			iT.style.pixelLeft = (xMousePos - 160);		
		else
			iT.style.pixelLeft = xMousePos;
		
		if ((xMousePos - 160 > 0) )
			iT.style.pixelLeft = (xMousePos - 160);
		
		else
			iT.style.pixelLeft = xMousePos;
		//=============== end of positioning =========
		iT.style.pixelTop = yMousePos;
		iHd.innerHTML = tipText;
		/* if (iT.style.display != 'none')
			OpaceLayer("iTip",0);
		else */
			OpaceLayer("iTip",1,1); 
}

function iHelp(helpText) {
  if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		
		
		var iH = document.getElementById("iHelp");
		var iHd = document.getElementById("iHelpData");
		var maxLP = 680; newP= xMousePos - 160
		if (screen.width > 1024 && window.parent.location == window.location) //if page is not an iframe.. and resolution is too big, reset maxLP
			{maxLP = 680 + (screen.width - 1024);
			newP = xMousePos + 20;}
		//====== reposition help box ===============
		//alert(newP);
		if ((xMousePos + 160 > maxLP) )
			iH.style.pixelLeft = (newP);	
		else
			iH.style.pixelLeft = xMousePos;
		//=============== end of positioning =========
		iH.style.pixelTop = yMousePos;
		iHd.innerHTML = helpText;
		OpaceLayer("iHelp",1);
    } 
}

function OpaceLayer(strLayerID,ShowHide)
{
				//if ShowHide is True, then show Target, else hide obj...
			//window.focus();
		try
		{
				TargetObj = document.getElementById(strLayerID);
				var ftnName ='OpaceLayer("' + TargetObj.id + '",' + ShowHide + ')'
				//alert (ftnName)
				if (ShowHide==1)
				{
					TargetObj.style.display = '';
					if(TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity <100)
					{
						TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity += 10;
						setTimeout(ftnName,20)
					}
					
				}
				else
				{
					if(TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity >0)
					{
						TargetObj.filters.item("DXImageTransform.Microsoft.Alpha").opacity -= 10;
						setTimeout(ftnName,20);
						
					}
					else
						{
						TargetObj.style.display = 'none';
						}
						
				}
		}
	catch(e)
			{
				alert(" There was an error.." + e + "\nYour Browser may not be compatible with SOBAN.net V4");
			}
	
}