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 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 changeBg(what,x){
	if(what){
	document.getElementById('btn'+x).className = '';
	}
	else{
	document.getElementById('btn'+x).className = '';
		}
}
/*---------------------Members Validations-------------------------------------------*/
//TRIM Functions
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function ValidateRegister()
{
	var msg="";
	var msg1="";
	if (Trim(document.getElementById("txtUserName").value)=="")
		msg+="- User Name\n"
	if (Trim(document.getElementById("txtPassword").value)=="")
		msg+="- Password\n"
	if (Trim(document.getElementById("txtConfirm").value)=="")
		msg+="- Confirm Password\n"	
	if (Trim(document.getElementById("txtPassword").value)!=Trim(document.getElementById("txtConfirm").value))
	    msg1+="- Password and its confirmation do not match.\n"	
	if (Trim(document.getElementById("txtFName").value)=="")
		msg+="- First Name\n"
	if (Trim(document.getElementById("txtLName").value)=="")
		msg+="- Last Name\n"
	if (Trim(document.getElementById("txtNickname").value)=="")
		msg+="- NickName\n"
	if (document.getElementById("lstDays").selectedIndex==0 || document.getElementById("lstMonths").selectedIndex==0 || document.getElementById("lstYears").selectedIndex==0)
		msg+="- Date of Birth\n"
	if (document.getElementById("lstCountry").selectedIndex==0)
	   msg+="- Country\n"	   
	if (Trim(document.getElementById("txtEmail").value)==""){
		msg+="- Email\n"
		}
    else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail"));
	    if (strvalmail.length>0)
	     msg1+=strvalmail
	    } 
	    
	if (Trim(document.getElementById("txtConfirmEmail").value)=="")
		msg+="- Confirm Email\n"
//	if (Trim(document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value)!=Trim(document.getElementById("ctl00_ContentPlaceHolder1_txtConfirmEmail").value))
//	    msg1="Email and its confirmation do not match.\n"	
	 
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}
}

function ValidateEdit()
{
	var msg="";
	var msg1="";
	if (Trim(document.getElementById("txtUserName").value)=="")
		msg+="- User Name\n"
	if (Trim(document.getElementById("txtFName").value)=="")
		msg+="- First Name\n"
	if (Trim(document.getElementById("txtLName").value)=="")
		msg+="- Last Name\n"
		if (Trim(document.getElementById("txtNickname").value)=="")
		msg+="- NickName\n"
	if (document.getElementById("lstDays").selectedIndex==0 || document.getElementById("lstMonths").selectedIndex==0 || document.getElementById("lstYears").selectedIndex==0)
		msg+="- Date of Birth\n"
	if (document.getElementById("lstCountry").selectedIndex==0)
	   msg+="- Country\n"
	if (Trim(document.getElementById("txtEmail").value)==""){
		msg+="- Email\n"
		}
    else{
		var strvalmail=IsValidEmail(document.getElementById("txtEmail"));
	    if (strvalmail.length>0)
	     msg1+=strvalmail
	    } 
  	
	if (msg==""){
		if (msg1=="")
		   return true
        else
		{
			alert(msg1);
			return false;}
	}
	else{  
	   alert("The following fields are required,\n please be sure to fill them and try again:\n\n" + msg )
		return false;
		}
}

function ValidateChangePassword(){
    if (Trim(document.getElementById("txtOldpwd").value)=="" || Trim(document.getElementById("txtNewPwd").value)=="" || Trim(document.getElementById("txtConfirm").value)=="")
	{
		alert("The following fields are required:\n - Old Password \n - New Password \n - Confirm New Password");
	    return false;
	  }
	else{
		if (document.getElementById("txtNewPwd").value!=document.getElementById("txtConfirm").value){
			alert("New Password and Confirm New Password do not match");
			return false;
			}
		else{
			return true;
		}
	}
}


function IsValidEmail(txt){
    var stremail="";
	if(txt.value !=""){ 
		var goodEmail = txt.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
		    return true;
		} else {
			stremail=" - The Email address is not valid\n";
			return stremail;
		}
	}
}

function ResetForm() {
    form1.reset()
}

/*----------------------------------------------------------------------------------------------------------*/

/**********************POPUP********************************/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
/********Popup******/
function closepopupDiv() {
    document.getElementById("popupmenuDiv").style.display = "none"
}
function ShowFulldata(video, DivID, thumb) {
    if (typeof last_lyrics_div_id != "undefined") {
        $("#" + last_lyrics_div_id).hide("normal");
        if (last_lyrics_div_id == DivID) {
            last_lyrics_div_id = "";
            return;
        }
    }
    last_lyrics_div_id = DivID;
    //$("#" + DivID).css({ height: "400px", width: "150px" }).show("normal");
    $("#" + DivID).html("<span>Loading...</span>");
    $.get("GetVideo.aspx?video=" + video + "&thumb=" + thumb + "&DivID=" + DivID, '', function(data) {
        $("#" + DivID).html(data);
 //       var h = $("#" + DivID).find("div:first").height();
//        var w = 300;
//        h = Math.min(h, 300);
        $("#" + DivID).show("normal")
    });
}
function CloseDiv(DivID) { $("#" + DivID).fadeOut("normal"); }
