// JavaScript Document
/* ----------------------------------------------------------------------------------------------------------------
							This is the 2Tone Javascript/VBScript Library. 
							Code is copyright of 2ToneWeb.com, unless otherwise stated.
							For more information, please contact support@2toneweb.com
							
--------------------------------------------------------------------------------------------------------------------
*/
//<![CDATA[

// 2tone Fader bar-
// Bar for fading the strip on mouseover.

function makearray(n) {
	this.length = n;
	for(var i = 1; i <= n; i++)
		this[i] = 0;
	return this;
}
function hex(i) {
	if (i < 0)	  return "00";
	else if (i > 255) return "ff";
	else		  return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
function hexnumtodec(hexchar) {
	if (parseInt(hexchar) == hexchar) return Number(hexchar)
	hexchar = hexchar.toUpperCase()
	switch (hexchar) {
		case 'A': return 10; break;
		case 'B': return 11; break;
		case 'C': return 12; break;
		case 'D': return 13; break;
		case 'E': return 14; break;
		case 'F': return 15; break;
	}
}
function hextodec(daHex) {
	var daDec = Number((16 * hexnumtodec(daHex.substring(0,1))) + hexnumtodec(daHex.substring(1,2)))
	return daDec
}

function setColor(r,g,b) {
	var hr = hex(r); var hg = hex(g); var hb = hex(b);
	var daColor = "#"+hr+hg+hb
	daEl.style.backgroundColor = daColor
	if (daColor == colorend.toLowerCase()) {
		clearInterval(iId)
		iId = null
		timerRunning = false
	}
}
// Start Fade in IE identifyable browsers.
function fade() {
	i++
	setColor(
		Math.floor(sr * ((step-i)/step) + er * (i/step)),
		Math.floor(sg * ((step-i)/step) + eg * (i/step)),
		Math.floor(sb * ((step-i)/step) + eb * (i/step)));
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
	hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

var i
var iId = null
var sr, sg, sb
var er, eg, eb
var interval = 1
var step = 16
var colorstart
var colorend
var daEl
var timerRunning = false

function myfade(el,cs,ce,iv,st) {
	daEl = el
	colorstart = cs
	colorend = ce
	interval = iv
	step = st
	i = 0
	if (timerRunning) {
		clearInterval(iId)
		iId = null
	}
	// Check the status
	var myRe = /#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i
	if (colorstart.match(myRe)) {
		sr = hextodec(RegExp.$1)
		sg = hextodec(RegExp.$2)
		sb = hextodec(RegExp.$3)
	}
	if (colorend.match(myRe)) {
		er = hextodec(RegExp.$1)
		eg = hextodec(RegExp.$2)
		eb = hextodec(RegExp.$3)
	}
	timerRunning = false;
	iId = setInterval("fade()",interval)
	timerRunning = true;
}
function cellover(table_cell) {
	// Values will be changed here. If the 2tone header needs to be re-modularized to versioning, then leave this intact.
	// element, from_color, to_color, interval(milliseconds), transition steps
	myfade(table_cell,'#4a4a4a','#FFCC00',20,32)
}
function cellout(table_cell) {
	if (timerRunning) {
		clearInterval(iId)
		iId = null
	}
	table_cell.style.backgroundColor = '#4a4a4a'
}
// Function to validate login entry fields (/account/login.asp)
function ValidateLogin(){
var lfldEmailAddress=document.frmLogin.fldEmailAddress.value;
var lfldPassword=document.frmLogin.fldPassword.value;
		if((lfldUserName==null)||(lfldUserName==""))
	{
			alert('Please enter your email address');
			document.frmLogin.fldUserName.focus();
			//document.frmLogin.fldQuery.select();
			return false;
	}
		else if ((lfldPassword==null)||(lfldPassword==""))
	{
			alert('Please enter your password');
			document.frmLogin.fldPassword.focus();
			//document.frmLogin.fldQuery.select();
			return false;
	}			
}

// Quick Search on the right flank- Validate entry
function ValidateQuickSearch(){
var fldQuery=document.frmQuickSearch.fldQuery.value;
		if((fldQuery==null)||(fldQuery==""))
	{
			alert('Please Enter a query to search for.');
			document.frmQuickSearch.fldQuery.focus();
			document.frmQuickSearch.fldQuery.select();
			return false;
	}
}



// Main top menu angled line switcher.
function SwitchImage(ImageName){
var lImageName = ImageName;

	lImageName.src= "/images/mouseoverangledlineMENU.gif";
}
function SwitchImageOff(ImageName){
var lImageName = ImageName;

	lImageName.src= "/images/angledhiteline.gif";
}	
		
/*---------------------------------------------------------------
Master Form Validation -  functions 
----------------------------------------------------------------*/
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.65
//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(parseInt(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=='');
}
// Help Window ID passed to this function. If fldHelpID=0 or NULL, display error message in window
function openHelpWindow(lURL, lWindowName) {
var lfldURL = lURL;
var lfldWindowName = lWindowName;
  window.open(lfldURL,
              lfldWindowName,
              "width=350,height=284," +
              "scrollbars,status");
}  
// Print registration details window 
function openRegistrationPrintWindow(lURL, lWindowName) {
var lfldURL = lURL;
var lfldWindowName = lWindowName;
  window.open(lfldURL,
              lfldWindowName,
              "width=400,height=474," +
              "scrollbars,status");
}
// OpenAccountType Window
function openAccountTypeWindow(lURL, lWindowName) {
var lfldURL = lURL;
var lfldWindowName = lWindowName;
  window.open(lfldURL,
              lfldWindowName,
              "width=400,height=530," +
              "scrollbars,status");
}
/* Side Bar Rollovers */
function BGNew(obj, new_style, message) 
{ 
obj.className = new_style; 
window.status = message; 
} 
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}
// Function for account type ID page to get account type, redirect to start page, and close window.
function exit () { 

    el = document.frmAccountType.fldAccountTypeID;
	var lValue
	var AgreementPort = document.frmAccountType.IPAddress.value
	var UserTypeID = document.frmAccountType.fldUserTypeID.value
    for ( i=0; i < el.length; i++ ) {

        if ( el[i].checked ) {
			lValue= el[i].value
			opener.location = "start.asp?fldStatusCode=yes&cmdSave=TRUE&fldAccountTypeID="+lValue+"&fldAgreementPort="+AgreementPort+"&fldUserTypeID="+UserTypeID+""
			self.close();
            //alert( el[i].value );
            break;
        }
    }
}
function exitColumnRateWindow () { 

    var columnID
	columnID = document.frmPrint.fldColumnID.value;
	opener.location = "frmFeature.asp?fldColumnID="+columnID+" "
    self.close();
}

function GetRadioValue() { 

    var el = document.frmAgree.fldAgree;
	var lValue
	//var AgreementPort = document.frmAccountType.IPAddress.value
    for ( i=0; i < el.length; i++ ) {

        if (el[i].checked)
		{
		lValue = el[i].value
		//alert (lValue);
		//break;
		}
			
    }
		
	if (lValue == '1')
	{
	openAccountTypeWindow('frmAccountType.asp', 'accounttype')
	}
	else
	{
		location.href="../reasons.asp?fldReasonID=1"
	}
}

//Function for forum navigation
function GetDropDownValue(){
var lfldForumLink = document.frmChooseForum.fldForumID.value;

location.href= lfldForumLink;
}
//Takes dynamic links or otherwise, and redirects them.
function GetDropDownValueAuthors(){
var lfldAuthorLink = document.frmAuthorChoice.fldAuthorID.value;

location.href= lfldAuthorLink;
}
function OpenRateWindow() {
	var Rating 
	var IPAddress
	var ColumnID
	//Rating  = document.frmRate.fldRating.value
	IPAddress = document.frmRate.fldRegistrationIP.value
	ColumnID = document.frmRate.fldRateColumnID.value
	
	
	
	var el1 = document.frmRate.fldRating;
	var lValue
	//var AgreementPort = document.frmAccountType.IPAddress.value
    for ( i=0; i < el1.length; i++ ) {

        if (el1[i].checked)
		{
		lValue = el1[i].value
		//alert (lValue);
		//break;
		}
			
    }
	
	
	
	MM_openBrWindow("frmFeatureRate.asp?fldColumnID="+ColumnID+"&fldRegistrationIP="+IPAddress+"&fldRating="+lValue+"","RateWindow","width=365,height=250");
	//openHelpWindow('frmFeatureRate.asp?fldColumnID=+ColumnID+&fldRegistrationIP=+IPAddress+&fldRating=+Rating+')
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
}
//-->

function CheckOption() {
if (document.frmColumnSearch.lfldCategoryID.selectedIndex/1==0)
{
alert ("You must select a category")
return false;
}
window.location=document.frmColumnSearch.lfldCategoryID.options[document.frmColumnSearch.lfldCategoryID.selectedIndex].value
}
function CheckOption2() {
if (document.frmColumnSearch.lfldAuthorDropDownID.selectedIndex/1==0)
{
alert ("You must select an author")
return false;
}
window.location=document.frmColumnSearch.lfldAuthorDropDownID.options[document.frmColumnSearch.lfldAuthorDropDownID.selectedIndex].value
}
	   
function checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
  var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
  if (app.indexOf('Netscape') != -1) {
    if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
    else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= IEvers || verStr.indexOf(IEvers) != -1)
     {if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
    else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
  } else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
  if (newURL) { window.location=unescape(newURL); document.MM_returnValue=false; }
}
// Cancel registration if user chooses not to register. Pass these values to reasons.asp to record activity type upto this point.
function CancelRegistration() {
if(confirm('You are about to cancel this registration. All data entered upto this point will be lost. Continue?'))
window.location = "../reasons.asp?fldReasonID=6&fldActivityIntercept=TRUE"

}
// Cancel Profile registration for portfolio if user goes away.
function CancelProfile() {
if(confirm('You have not completed filling out your profile. Are you sure you wish to cancel?'))
window.location = "../reasons.asp?fldReasonID=6&fldActivityIntercept=TRUE"
else
return false;

}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function CheckPortfolioStatus(fldlinktype) {
	var linkType = fldlinktype;
	var statusfield = document.frmPortfolioPage.fldPortfolioRecordcount.value;
		if ((statusfield == "1") && (linkType == "view"))
		{
		window.location = "frmViewPortfolio.asp"
		}
		else if ((statusfield == "1") && (linkType == "modify"))
		{
		window.location = "frmEditPortfolio.asp"
		}
		else
		{
			alert("You have not created a profile. To view your profile, you must create one first.")
			return false;
		}
}
//Function to check file type before uploading to the server
// Server side checking not used to prevent excess load and access to server security settings
<!-- Begin
function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1) ?
alert('That file satisfies our file type requirements!') : 
alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
}
// Check valid category choice before going to portfolioBrowse page./
function CheckOptionPortfolioBrowse() {
if (document.frmBrowseByCategory.lfldCategoryID.selectedIndex/1==0)
{
alert ("You must select a category")
return false;
}
window.location=document.frmBrowseByCategory.lfldCategoryID.options[document.frmBrowseByCategory.lfldCategoryID.selectedIndex].value
}
   
   
// -->
//]]>


