function $id(id){ return document.getElementById(id); }

function ShowHideObjectByID(sObjectID, bShow)
{
    var oObject = $id(sObjectID);
    
    oObject.style.display = "none";
    //if (bShow==true) { oObject.style.display = "block"; }
    if (bShow==true) { oObject.style.display = ""; }
}


function RegisterVal() {	
isValid = true;    
var sEmail = document.myForm.email.value;   
    
	if (document.myForm.username.value == "") {
		document.myForm.username.select();
		document.myForm.username.focus();
		alert("Please fill in a username");
		isValid = false;

	} else if (document.myForm.password.value == "") {
		document.myForm.password.select();
		document.myForm.password.focus();
		alert("Please fill in a password");
		isValid = false;
	}
	else if (sEmail == "") {
		document.myForm.email.select();
		document.myForm.email.focus();
		alert("Please fill in an email");
		isValid = false;
	}
	else if (sEmail.length <= 0 || sEmail.length > 75 || sEmail.indexOf("@") == -1 || sEmail.indexOf(".") == -1) {
		document.myForm.email.select();
		document.myForm.email.focus();
		alert('Please enter a valid email address.');
		isValid = false;
	}
return isValid;
}

function LoginVal() {		
	if (document.LoginForm.username.value == "") {
		document.LoginForm.username.select();
		document.LoginForm.username.focus();
		alert("Please fill in a username");
		return false;

	} else if (document.LoginForm.password.value == "") {
		document.LoginForm.password.select();
		document.LoginForm.password.focus();
		alert("Please fill in a password");
		return false;	
	}		
}

function ChangePassVal() {		
	if (document.ChangePassForm.old_pwd.value == "") {
		document.ChangePassForm.old_pwd.select();
		document.ChangePassForm.old_pwd.focus();
		alert("Please fill in the Old Password field");
		return false;

	} else if (document.ChangePassForm.new_pwd1.value == "") {
		document.ChangePassForm.new_pwd1.select();
		document.ChangePassForm.new_pwd1.focus();
		alert("Please fill in the New Password field");
		return false;	
		
	} else if (document.ChangePassForm.new_pwd2.value == "") {
		document.ChangePassForm.new_pwd2.select();
		document.ChangePassForm.new_pwd2.focus();
		alert("Please fill in the Confirm New Password field");
		return false;	
			
	} else if (document.ChangePassForm.new_pwd1.value != document.ChangePassForm.new_pwd2.value) {
		document.ChangePassForm.new_pwd1.select();
		document.ChangePassForm.new_pwd1.focus();
		alert("Please fill in the same password");
		return false;	
	}		
}

function SendPassVal() {		
 var sEmailForm = document.SendPassForm.email.value; 
	if (sEmailForm == "") {
		document.SendPassForm.email.select();
		document.SendPassForm.email.focus();
		alert("Please fill in an email");
		return false;	
	}
	else if (sEmailForm.length <= 0 || sEmailForm.length > 75 || sEmailForm.indexOf("@") == -1 || sEmailForm.indexOf(".") == -1) {
		document.SendPassForm.email.select();
		document.SendPassForm.email.focus();
		alert('Please enter a valid email address.');
		return false;	
	}	
}
function InviteGuestVal() {		
 var sEmailForm = document.getElementById('email').value; 
	if (document.getElementById('username').value == "") {
		document.getElementById('username').select();
		document.getElementById('username').focus();
		alert("Please fill in a username");
		return false;

	}else if (sEmailForm == "") {
		document.getElementById('email').select();
		document.getElementById('email').focus();
		alert("Please fill in an email");
		return false;	
	}
	else if (sEmailForm.length <= 0 || sEmailForm.length > 75 || sEmailForm.indexOf("@") == -1 || sEmailForm.indexOf(".") == -1) {
		document.getElementById('email').select();
		document.getElementById('email').focus();
		alert('Please enter a valid email address.');
		return false;	
	}	
}
function MeetVal() {		

	if (document.MeetForm.rName.value == "") {
		document.MeetForm.rName.select();
		document.MeetForm.rName.focus();
		alert("Please fill in a Studio name");
		return false;
	}
	else if(!checkMeetrName(document.MeetForm.rName.value)) {
	    document.MeetForm.rName.select();
		document.MeetForm.rName.focus();
		alert("Studio names can only contain letters and numbers");
		return false;
		}
}
function checkMeetrName(str)
{
        var rName = /^[a-zA-Z0-9\s]+$/;
        if (str.match(rName)) {
             return true;
        } else {
               return false;
        }
}
function buy() {
			if(document.forms.myinfo.account_type.options[1].selected || document.forms.myinfo.account_type.options[2].selected) {
				window.location = "http://www.vidize.com/buy.php";
			}
		 }
function showDiv(divid, ReadMore, MoreImage) {
 if (divid == ReadMore) {
  var curItem = document.getElementById(ReadMore);
    var curImage = document.getElementById(MoreImage);   
      if (curItem.style.display == 'block') {
        document.getElementById(ReadMore).style.display = "none";	 
        curImage.src = "images/plus.gif";
        curImage.title = "Read More";       
      }
      else {            
        document.getElementById(ReadMore).style.display = 'block';           
        curImage.src = "images/minus.gif";
        curImage.title = "Close";
      }
   }
   else 
    document.getElementById(divid).style.display = 'block';			
 }

