﻿function set_opt(v){
 var csc = document.join.cascade;
 for (i=0; i<csc.length; i++) {
  if( csc.options[i].value == v && csc.options[i].selected == false){ 
   document.join.cascade.options[i].selected = true;
   alert('Membership Type: '+csc.options[i].text + ' has been selected');
   set_visible(v);
  }
 }
}
function set_visible(v){
try{
   if(v=='INIDIALER'){
    document.getElementById('table_options').style.visibility = 'hidden';
   }else{
    document.getElementById('table_options').style.visibility = 'visible';
   }
}catch(e){}
}
function checkform(form) {
	if(form.iagree.checked == false) {
		alert("You must agree to the Terms and Conditions");
		form.iagree.focus();
		return false;
	}
}
function intellichat_disable(){
	try{
		DisableSASChat();
	}catch(e){}
}









/***** May need to be edited sitename & optionid, no time to dynamic check: base_900 & optionid(4) *****/
var base_900_href = "/signup/signup.php";
var nav = new String;
var brw = new String;
var displatype = new String;
nav = navigator.userAgent.toLowerCase();			//std brwoser identification string

function GetBrowserComp(nav){
        //browser check
        if(nav.indexOf('firefox') > -1 ){
                brw = 'firefox';
                displatype = "table-row";
        }else {
                if(nav.indexOf('opera') > -1){
                        brw = 'opera';
                        displatype = "block";
                }else {
                        if(nav.indexOf('msie') > -1){
                                brw = "ie";
                                displatype = "block";
                        }else {
                                brw = 'ie2';
                                displatype = "block";
                        }
                }
        }
        return displatype
}
displatype = GetBrowserComp(nav);

function IsEmailValid(t){
        try{ if (t.indexOf(".") == -1){ return false; } if (t.indexOf("@") == -1){ return false; } return true; }catch(e){ return false; }
}

function TestString(strUSR){
	for(i=0;i<strUSR.length;i++){
		isOK = false;
		if(i==0){
			 if(	((strUSR.charCodeAt(i) >= 97) && (strUSR.charCodeAt(i) <= 122)) ||
                                ((strUSR.charCodeAt(i) >= 65) && (strUSR.charCodeAt(i) <= 90)) ) isOK = true;
        	}else{
			if(   ((strUSR.charCodeAt(i) >= 65) && (strUSR.charCodeAt(i) <= 90)) || 
				((strUSR.charCodeAt(i) >= 97) && (strUSR.charCodeAt(i) <= 122)) || 
				((strUSR.charCodeAt(i) >= 48) && (strUSR.charCodeAt(i) <= 57)) ) isOK = true;
		}
		if(isOK != true) return false;   	
        }
	return true;
}

function CheckJoinForm(){
        Warn = ""; var xf;
        try{xf=document.getElementById("USR");if((xf.value=="")||(xf.value.length<6)||(xf.value.length>16)){Warn=Warn+"\tUsername [6-16 chars]\n";}}catch(e){}
        try{xf=document.getElementById("USR");if(TestString(xf.value)==false){Warn=Warn+"\tUsername valid characters: numbers and letter\n\t\tFirst character must be a letter\n\n";}}catch(e){}
        try{xf=document.getElementById("PWD");if((xf.value=="")||(xf.value.length<6)||(xf.value.length>16)){Warn=Warn+"\tPassword [6-16 chars]\n";}}catch(e){}
		try{xf=document.getElementById("PWD");if(TestString(xf.value)==false){Warn=Warn+"\tPassword valid characters: numbers and letter\n\t\tFirst character must be a letter\n\n";}}catch(e){}
        try{xf=document.getElementById("ZIP");if(xf.value==""){Warn=Warn+"\tZip Code\n";}}catch(e){}
        try{xf=document.getElementById("EML");if((!IsEmailValid(xf.value))||(xf.value.length<5)||(xf.value.length>128)){Warn=Warn+"\tEmail\n";}}catch(e){}
        if(Warn!=""){alert("Please fill the specified field(s):\n\n"+Warn);return false;} 
        return true;
}
function trydisplay(t){
        if(t.style.display == displatype) t.style.display = 'none';
        else t.style.display = displatype
        return true;
}
function TryFind900(){
      	for(i=0;i<=document.forms[0].elements.length;i++){

try{
        	if( ((document.forms[0].elements[i].value == '4') || (document.forms[0].elements[i].value == '11')) && (document.forms[0].elements[i].name == 'signup[optionid]') ){
			return i;
              	}
}catch(e){}

      	}
	return true;
}

function TryFindOtherValue(){
        for(i=0;i<document.forms[0].elements.length;i++){
        	if( !((document.forms[0].elements[i].value == '4') || (document.forms[0].elements[i].value == '11')) && (document.forms[0].elements[i].name == 'signup[optionid]') && (document.forms[0].elements[i].checked == true) ){
                        return i;
                }
        }
        return true;
}

