function on (id) {
	id.className='tmON';
}

function off (id) {
	id.className='tmOFF';
}

function onl (id) {
	id.className='tmON1';
}

function offl (id) {
	id.className='tmOFFl';
}

function visit (id) {
	location.href='/index.cfm?id='+id;;
}

function toggle(id){
	show_tr=eval("TR"+id);
	
	if (show_tr.style.display == 'none') {
		show_tr.style.display='block';
		}
	else {
		show_tr.style.display='none';
	}
}



var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
preloadimages("/images/spacer.gif");


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];}
}
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 toggleCheck(field) {
	if (document.frmFilters.globalCategory.checked == true) {
		checkAll(field);
		disableAll(field);
	}
	else {
		
		uncheckAll(field);
		enableAll(field);
	} 
}

function checkAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = true ;
	}
}

function uncheckAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = false ;
	}
}

function enableAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].disabled = false ;
	}
}

function disableAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].disabled = true ;
	}
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    }
	
    return true;
}



function validateRecover() {
	error = 0;

	   if ((!frmPasswordRecover.email.value) && error == 0) {
	       alert("Please enter your email address");
		   error=1;
	   }

	   if (!isValidEmail(frmPasswordRecover.email.value) && error == 0) {
	       alert("Please enter a valid email address");
		   error=1;
	   }

		if (error == 0) {
			frmPasswordRecover.submit();	
		}	
}


function validateSignUp() {
	error = 0;
	
	
	
	if (frmMember.cat_id.value == 0 && error == 0) {
		alert("Please choose the most appropriate category for your website. If you cannot find anything which matches your website, please contact us at support@indexguy.com and ask for a new category to be added.");
		error=1;
	}

	if (!frmMember.title.value && error == 0) {
		alert("Please enter the title (i.e. the clickable text) of your website.");
		error=1;
	}

	if (frmMember.url.value == 'http://' || frmMember.url.value == '') {
		if (error==0) {
			alert("The URL of your website has to be entered");
			error=1;
		}
	}

	if (!frmMember.description.value && error == 0) {
		alert("Please enter a short description for your website");
		error=1;
	}


	if (frmMember.platform.value == 0 && error == 0) {
		alert("Please choose the platform which is supported by your web hosting provider.");
		error=1;
	}

	if (!frmMember.email.value && error == 0) {
		alert("Please enter your email address");
		error=1;
	}


   if (!isValidEmail(frmMember.email.value) && error == 0) {
       alert("Please enter a valid email address");
	   error=1;
   }


	if (!frmMember.username.value && error == 0) {
		alert("Please enter a username.");
		error=1;
	}
	
   if (!allValidChars(frmMember.username.value) && error == 0) {
       alert("Please enter a username with characters [1-9] and/or [aA-zZ]");
	   error=1;
   }


	if (!frmMember.password.value && error == 0) {
		alert("Please enter a password.");
		error=1;
	}

	if (!frmMember.verify_password.value && error == 0) {
		alert("Please verify your password.");
		error=1;
	}

   if ((frmMember.password.value != frmMember.verify_password.value) && error == 0) {
       alert("Passwords do not match. Try again.");
	   error=1;
   }
   
	if (!frmMember.humantest.value && error == 0) {
		alert("Human verification is missing. Try again.");
		error=1;
	}

	if (frmMember.terms.checked == false && error == 0) {
		alert("In order to proceed with the registration you have to accept the Terms and Conditions.");
		error=1;
	}   
	
	alert(error);
	
	if (error == 0) {
		frmMember.submit();	
	}	
}


function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
	countfield.value = maxlimit - field.value.length;
}


function validateWebsite() {
	if ((frmWebsite.url.value == 'http://') || (frmWebsite.url.value == '')) {
		alert("The URL field of your website has to be entered");
	}
	else frmWebsite.submit();
}

function Explain () {
	if (explain.style.display == 'none') {
		explain.style.display='block';
		}
	else {
		explain.style.display='none';
	}
}

function Explain1 () {
	if (explain1.style.display == 'none') {
		explain1.style.display='block';
		}
	else {
		explain1.style.display='none';
	}
}

function Explain2 () {
	if (explain2.style.display == 'none') {
		explain2.style.display='block';
		}
	else {
		explain2.style.display='none';
	}
}

function Explain3 () {
	if (explain3.style.display == 'none') {
		explain3.style.display='block';
		}
	else {
		explain3.style.display='none';
	}
}

function Explain4 () {
	if (explain4.style.display == 'none') {
		explain4.style.display='block';
		}
	else {
		explain4.style.display='none';
	}
}

function Explain5 () {
	if (explain5.style.display == 'none') {
		explain5.style.display='block';
		}
	else {
		explain5.style.display='none';
	}
}

function Explain6 () {
	if (explain6.style.display == 'none') {
		explain6.style.display='block';
		}
	else {
		explain6.style.display='none';
	}
}

function Explain7 () {
	if (explain7.style.display == 'none') {
		explain7.style.display='block';
		}
	else {
		explain7.style.display='none';
	}
}


function validateCode() {
	var radio_choice = false;
	for (counter = 0; counter < frmGenerator.platform.length; counter++)
		{
			if (frmGenerator.platform[counter].checked)
			radio_choice = true; 
		}
	if (!radio_choice)
		{
			alert("Please choose one of the provided platforms")
			return (false);
		}
	else {
		frmGenerator.submit();
	}
}

function validateContact () {
	if (frmContact.message.value == "") {
		alert("Please enter your message");
	}
	else {
		frmContact.submit();
	}
}

function validateLogin()  {
	
	error = 0;
	
	if (frmLogin.username.value == "") {
		alert("Please enter your username");
		error = 1;
	}
	
	if (frmLogin.password.value == "" && error == 0) {
		alert("Please enter your password");
		error = 1;
	}

	if (error == 0) {
		frmLogin.submit();
	}
}

function quickTour() {
	window.open('tour1.cfm','newwindow', 'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=550,height=350');
}

function liveHelp() {
	window.open('http://www.indexguy.com/chat/chatstart.htm?domain=www.indexguy.com','new_win', 'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=484,height=361');
}


function toggledisplay(id){
	show_tr=eval("TR"+id);
	
	if (show_tr.style.display == 'none') {
		show_tr.style.display='block';
		}
	else {
		show_tr.style.display='none';
	}
}


function showPlatform() {
	accFree.className='accountClassShow';
	accPaid.className='accountClassHide';
}

function showProduct() {
	accFree.className='accountClassHide';
	accPaid.className='accountClassShow';
}


function CopyToClipboard()
{
   codeForm.codeSnippet.focus();
   codeForm.codeSnippet.select(); 
   CopiedTxt = document.selection.createRange();
   CopiedTxt.execCommand("Copy");
}

