function addUser()
{

location.href='user_details.php';

}


function loginCheck()
{
	
	var loginusername=ob('loginusername').value
	var passwd=ob('passwd').value

	if(loginusername=='')
	{
		inlineMsg('loginusername','<strong>Error</strong><br />enter Username.',2);
		return false;
	}
	
	if(passwd=='')
	{
		inlineMsg('passwd','<strong>Error</strong><br />enter password.',2);
		return false;	}
	
	 //document.login.submit();
	  // return true;
	
}


function validateCreditCard(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
// validate number
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10 == 0);
}

function AdminNewUser(form) 
{
	
	var first_name = document.getElementById('first_name').value;
	var middle_name = document.getElementById('middle_name').value;
	var last_name = document.getElementById('last_name').value;
	var address = document.getElementById('address').value;
	var city = document.getElementById('city').value;
	var state = document.getElementById('state').value;
	var zip = document.getElementById('zip').value;
	var email = document.getElementById('email').value;	
	var password = document.getElementById('password').value;	
	var confirm_password = document.getElementById('confirm_password').value;		
	var membership_type = document.getElementById('membership_type').value;
	
	var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	var websiteRegex= /^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:~\+#]*[\w\-\@?^=%&amp;~\+#])?/;
    var isOkEmail= /^[a-zA-Z]([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if(first_name!="")
	{
	  if(!first_name.match(nameRegex)) {
		
		inlineMsg('first_name','<strong>Error</strong><br />You have entered an invalid first name.',2);
		return false;
	  }
	  
	}
	if(first_name=="")
	{
	  
		
		inlineMsg('first_name','<strong></strong><br />enter first name.',2);
		return false;
	  
	  
	}	
	
	if(last_name!="")
	{
	  if(!last_name.match(nameRegex)) {
		
		inlineMsg('last_name','<strong>Error</strong><br />You have entered an invalid last name.',2);
		return false;
	  }
	  
	}
	if(last_name=="")
	{
	  
		
		inlineMsg('last_name','<strong></strong><br />enter last name.',2);
		return false;
	  
	  
	}		
	if(address=="")
	{
	  
		
		inlineMsg('address','<strong></strong><br />enter your address.',2);
		return false;
	  
	  
	}	
	
	if(city=="")
	{
	  
		
		inlineMsg('city','<strong></strong><br />enter your city.',2);
		return false;
	  
	  
	}	
	
		if(state=="")
	{
	  
		
		inlineMsg('state','<strong></strong><br />enter your state.',2);
		return false;
	  
	  
	}	
	
		if(zip=="")
	{
	  
		
		inlineMsg('zip','<strong></strong><br />enter your zip.',2);
		return false;
	  
	  
	}	

	if(email=="")
	{
	  
		
		inlineMsg('email','<strong></strong><br />enter your email.',2);
		return false;
	  
	  
	}		
	if(email!="")
	{
	  if(!email.match(isOkEmail)) {
		
		inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
		return false;
	  }
	  
	}	

	if(password=="")
	{
	  
		
		inlineMsg('password','<strong></strong><br />enter your password.',2);
		return false;
	  
	  
	}
	if(confirm_password=="")
	{
	  
		
		inlineMsg('confirm_password','<strong></strong><br />confirm your password.',2);
		return false;
	  
	  
	}			
	if(confirm_password!="")
	{
	  if(password!=confirm_password) {
		
		inlineMsg('confirm_password','<strong>Error</strong><br />both passwords not matched.',2);
		return false;
	  }
	  
	}	



	url="user.add.commit.php?first_name="+first_name+"&last_name="+last_name+"&address="+address+"&city="+city+"&state="+state+"&zip="+zip+"&email="+email+"&password="+password+"&membership_type="+membership_type;
	
	xhr.open('GET', url, true);
	xhr.onreadystatechange =joinnowStateChange;
	//Send the proper header information along with the request
	xhr.send(null);


}
function membership(cost)
{
	//alert(cost);
	
	//$('#payment').slideToggle();
	document.getElementById('membership_cost').value=cost;	
	
	//document.getElementById('payment').style.display="block";
	
	
	
	
}
/*function membership_close(cost)
{
	alert(cost);
	
	
		$('#payment').slideUp("slow");
		//document.getElementById('payment').style.display="none";
	
}*/




function editUserMentorprofile(userid)
{
	var affilation = ob('affilation').value;
	var description = ob('description').value;

	
	url="lib.syn/manage_user.php?mode=editusermentorprofile&affilation="+affilation+"&description="+description;

	xhr.open('GET', url, true);
	xhr.onreadystatechange =profilestatechange;
	
	//Send the proper header information along with the request
	xhr.send(null);
	callsyn('lib.syn/edit_usermentordetail.php?start=0&userid='+userid,'','user_edit_mentorprofile',false,preloader_3,false,false);

}


function checkAllusers()
{
	if(document.getElementById('check_all_users').value=='Select All')
	{
		var element=document.user_list.elements;
		for(var i=0;i<element.length;i++)
		{
			if(element[i].name.indexOf('user')!=-1)
				element[i].checked='checked';
		}
		document.getElementById('check_all_users').value='Deselect All'
	}
	else
	{
		var element=document.user_list.elements;
		for(var i=0;i<element.length;i++)
		{
			if(element[i].name.indexOf('user')!=-1)
				element[i].checked=false;
		}
		document.getElementById('check_all_users').value='Select All'
	}
}

function deleteuser()
{
	var postr='';
	var element=document.user_list.elements;
	for(var i=0;i<element.length;i++)
		{
			if(element[i].name.indexOf('user')!=-1&&element[i].checked)
			{
				postr+='user_id'+i+'='+element[i].value;
				if(i!=element.length-1)
				postr+='&';
			}
		}
	if(postr!=''){
	if(confirm('Are you sure to delete these users?'))
	{
		callsyn('lib.syn/users.php?start=0',postr+'&action=del','adminlogin_content',false);
	}}
	else alert('No User has been selected')
}



function deactivateuser()
{
	var postr='';
	var element=document.user_list.elements;
	for(var i=0;i<element.length;i++)
		{
			if(element[i].name.indexOf('user')!=-1&&element[i].checked)
			{
				postr+='user_id'+i+'='+element[i].value;
				if(i!=element.length-1)
				postr+='&';
			}
		}
	if(postr!=''){
		
	if(confirm('Are you sure to de-activate these users?'))
	{
		callsyn('lib.syn/users.php?start=0',postr+'&action=disable','adminlogin_content',false);
	}}
	else alert('No user has been selected')
}

function activateuser()
{
	var postr='';
	var element=document.user_list.elements;
	for(var i=0;i<element.length;i++)
		{
			if(element[i].name.indexOf('user')!=-1&&element[i].checked)
			{
				postr+='user_id'+i+'='+element[i].value;
				if(i!=element.length-1)
				postr+='&';
			}
		}
	if(postr!=''){
		
	if(confirm('Are you sure to activate these Users?'))
	{
		callsyn('lib.syn/users.php?start=0',postr+'&action=enable','adminlogin_content',false);
	}}
	else alert('No user has been selected')
}

function AscenduserName()
{
		callsyn('lib.syn/users.php?start=0&action=AscenduserName','','adminlogin_content',false);
}

function DescenduserName()
{
		callsyn('lib.syn/users.php?start=0&action=DescenduserName','','adminlogin_content',false);
}

function AscenduserName_frnt()
{
		callsyn('lib.syn/userlist.php?start=0&action=AscenduserName','','realityu_content',false);
}

function DescenduserName_frnt()
{
		callsyn('lib.syn/userlist.php?start=0&action=DescenduserName','','realityu_content',false);
}
function Ascendstate_frnt()
{
		callsyn('lib.syn/userlist.php?start=0&action=Ascendstate','','realityu_content',false);
}

function Descendstate_frnt()
{
		callsyn('lib.syn/userlist.php?start=0&action=Descendstate','','realityu_content',false);
}



function Ascendcountry()
{		
		callsyn('lib.syn/users.php?start=0&action=Ascendcountry','','adminlogin_content',false);
}

function Descendcountry()
{
		callsyn('lib.syn/users.php?start=0&action=Descendcountry','','adminlogin_content',false);
}
function AscenduserMembership()
{		
		callsyn('lib.syn/users.php?start=0&action=AscenduserMembership','','adminlogin_content',false);
}
function DescenduserMembership()
{		
		callsyn('lib.syn/users.php?start=0&action=DescenduserMembership','','adminlogin_content',false);
}

function AscenduserMembership_frnt()
{		
		callsyn('lib.syn/userlist.php?start=0&action=AscenduserMembership','','realityu_content',false);
}
function DescenduserMembership_frnt()
{		
		callsyn('lib.syn/userlist.php?start=0&action=DescenduserMembership','','realityu_content',false);
}
function AscenduserLogin_frnt()
{		
		callsyn('lib.syn/userlist.php?start=0&action=Ascenduserlogin','','realityu_content',false);
}
function DescenduserLogin_frnt()
{		
		callsyn('lib.syn/userlist.php?start=0&action=Descenduserlogin','','realityu_content',false);
}



function Ascendusertype()
{
		callsyn('lib.syn/users.php?start=0&action=Ascendusertype','','adminlogin_content',false);
}
function Descendusertype()
{		
		callsyn('lib.syn/users.php?start=0&action=ascendedited','','adminlogin_content',false);
}
function AscenduserStatus()
{
        callsyn('lib.syn/users.php?start=0&action=AscenduserStatus','','adminlogin_content',false);
}

function DescenduserStatus()
{
        callsyn('lib.syn/users.php?start=0&action=DescenduserStatus','','adminlogin_content',false);
}
function filterusers(status)
{
        var element=document.filter_userss.elements;
		callsyn('lib.syn/users.php?start=0','status='+status+'&action=filter','adminlogin_content',false);
}

function AscendmentorRole()
{
		callsyn('lib.syn/userlist.php?start=0&action=AscendMentor','','realityu_content',false);
}

function DescendMentorRole()
{
		callsyn('lib.syn/userlist.php?start=0&action=DescendMentor','','realityu_content',false);
}

function editprofile(userid)
{
	var Eaddress = ob('Eaddress').value;
	var Ecity = ob('Ecity').value;
	var Estate = ob('Estate').value;
	var Ezip = ob('Ezip').value;
	var Ecountry = ob('Ecountry').value;
	var Elandline = ob('Ephone').value;
	var Emobile = ob('Emobile').value;
	var Efax = ob('Efax').value;
	var EIM = ob('EIM').value;
	var Ewebsite = ob('Ewebsite').value;
	var Eblog = ob('Eblog').value;
	var ESocialNetwork = ob('ESocialNetwork').value;
	var Eemail = ob('Eemail').value;
	
	url="lib.syn/manage_user.php?mode=editprofile&Eaddress="+Eaddress+"&Ecity="+Ecity+"&Estate="+Estate+"&Ezip="+Ezip+"&Ecountry="+Ecountry+"&Elandline="+Elandline+"&Efax="+Efax+"&EIM="+EIM+"&Ewebsite="+Ewebsite+"&Eblog="+Eblog+"&ESocialNetwork="+ESocialNetwork+"&Emobile="+Emobile+"&Eemail="+Eemail;
	
	xhr.open('GET', url, true);
	xhr.onreadystatechange =profilestatechange;
	//Send the proper header information along with the request
	xhr.send(null);
	callsyn('lib.syn/edit_profile.php?start=0&userid='+userid,'','user_edit_profile',false,preloader_3,false,false);

}

function editdescription(userid)
{
	var Eabout_me = ob('Eabout_me').value;
	url="lib.syn/manage_user.php?mode=editdescription&Eabout_me="+Eabout_me;
	xhr.open('GET', url, true);
	xhr.onreadystatechange =profilestatechange;
	//Send the proper header information along with the request
	xhr.send(null);
	callsyn('lib.syn/edit_description.php?start=0&userid='+userid,'','user_edit_description',false,preloader_3,false,false);
}

function upload_resource(form)
{
	var res_tittle = document.getElementById('res_tittle').value;
	var res_description = document.getElementById('res_description').value;
	var res_level = document.getElementById('res_level').value;
	
	var tittleRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	
	if(res_tittle!="")
	{
	  if(!res_tittle.match(tittleRegex)) {
		
		inlineMsg('res_tittle','<strong>Error</strong><br />You have entered an invalid resource tittle.',2);
		return false;
	  }
	}
	if(res_tittle=="")
	{
		inlineMsg("res_tittle","<strong></strong><br /> Resource tittle canno't be blank.",2);
		return false;
	}
	
		
	if(res_description!="")
	{
	  if(!res_description.match(tittleRegex)) {
		
		inlineMsg('res_tittle','<strong>Error</strong><br />You have entered an invalid resource tittle.',2);
		return false;
	  }
	}
	if(res_description=="")
	{
		inlineMsg("res_description","<strong></strong><br /> Resource description canno't be blank.",2);
		return false;
	}
	

	if(res_level=="")
	{
		inlineMsg("res_level","<strong></strong><br /> Please select the resource level.",2);
		return false;
	}
	
}
	function Ascendcontent(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=Ascendcontent&userid='+userid,'','profile_resource_list',false);
	}
	function DescendContent(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=DescendContent&userid='+userid,'','profile_resource_list',false);
	}
	function AscendContentType(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=AscendContentType&userid='+userid,'','profile_resource_list',false);
	}
	function DescendContentType(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=DescendContentType&userid='+userid,'','profile_resource_list',false);
	}
	function AscendContentRating(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=AscendContentRating&userid='+userid,'','profile_resource_list',false);
	}
	function DescendContentRating(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=DescendContentRating&userid='+userid,'','profile_resource_list',false);
	}
	function AscendContentDate(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=AscendContentDate&userid='+userid,'','profile_resource_list',false);
	}
	function DescendContentDate(userid)
	{
			callsyn('lib.syn/profile_resource_list.php?start=0&action=DescendContentDate&userid='+userid,'','profile_resource_list',false);
	}

