
	function selall(tr)
	{
		if(document.getElementById('checkbox').checked==true)
		{
			for(i=0; i<tr; i++)
			{
				var c='check'+i;
				document.getElementById(c).checked=true;
			}
		}

		if(document.getElementById('checkbox').checked==false)
		{
			for(i=0; i<tr; i++)
			{
				var u='check'+i;
				document.getElementById(u).checked=false;
			}
		}
	}

	function confirmdel()
	{	
		return confirm('Are you sure you want to Delete?');
	}
	
	function allselect()
	{
		var read = document.getElementById('read').value;		
		if(read>0)
		{
			for(i=0; i<read; i++)
			{
				var c='read'+i;
				document.getElementById(c).checked=true;
			}
		}
		
		var unread = document.getElementById('unread').value;		
		if(unread>0)
		{
			for(i=0; i<unread; i++)
			{
				var c='unread'+i;
				document.getElementById(c).checked=true;
			}		
		}
	}

	function allreadselect()
	{
		var read = document.getElementById('read').value;				
		if(read>0)
		{
			for(i=0; i<read; i++)
			{
				var c='read'+i;
				document.getElementById(c).checked=true;
			}
		}
		
		var unread = document.getElementById('unread').value;		
		if(unread>0)
		{
			for(i=0; i<unread; i++)
			{
				var c='unread'+i;
				document.getElementById(c).checked=false;
			}		
		}		
	}		
	
	function allunreadselect()
	{
		var unread = document.getElementById('unread').value;				
		if(unread>0)
		{
			for(i=0; i<unread; i++)
			{
				var c='unread'+i;
				document.getElementById(c).checked=true;
			}		
		}
		
		var read = document.getElementById('read').value;		
		if(read>0)
		{
			for(i=0; i<read; i++)
			{
				var c='read'+i;
				document.getElementById(c).checked=false;
			}
		}		
	}
	
	function allunselect()
	{
		var read = document.getElementById('read').value;				
		if(read>0)
		{
			for(i=0; i<read; i++)
			{
				var c='read'+i;
				document.getElementById(c).checked=false;
			}
		}		
		
		var unread = document.getElementById('unread').value;				
		if(unread>0)
		{
			for(i=0; i<unread; i++)
			{
				var c='unread'+i;
				document.getElementById(c).checked=false;
			}		
		}
	}	
	
/* AUTHORIZATION */
	function username_check(max_length,forbidden)
	{
		//alert(forbidden_usernames);
		var username = document.getElementById('uname').value;
		if(username.length > max_length)
		{
			alert("User Name maximum length will be "+max_length+" characters.");
			document.getElementById('uname').value = username.substr(0,max_length);
			document.getElementById('uname').focus();
			return false;
		}
		
		var forbidden_usernames = forbidden.split(",");
		for (var i = 0; i < forbidden.length; i++)
		{
			if (forbidden_usernames[i] == username)
			{
				alert("Sorry, You can not use "+username+" as User Name.");
				document.getElementById('uname').value = null;
				document.getElementById('uname').focus();
				return false;				
			}
        }
		return true;		
	}	
/* AUTHORIZATION END */

/* PROFILE */
	function check_password_length(min_length,max_length)
	{
		//alert(forbidden_usernames);
		var password = document.getElementById('new_password').value;
		
		if(password.length < min_length){
			alert("Password minimum length will be "+min_length+" characters.");
			return false;
		}
		
		else if(password.length > max_length)
		{
			alert("Password maximum length will be "+max_length+" characters.");
			document.getElementById('new_password').value = password.substr(0,max_length);
			document.getElementById('new_password').focus();
			return false;
		}
		
		return true;		
	}
	
	function back_profile(mem_id)
	{
		window.location.href= "index.php?module=profile&action=profile&mem_id="+mem_id;
	}
/* END PROFILE */	

/* Point */
	function no_activity_prev()
	{
		alert("You have no more point activity in previous.");							
	}
	function no_activity_next()
	{
		alert("You have no more point activity in next.");							
	}
	
	function add_point()
	{
		window.location.href= "index.php?module=point&action=add_point";
	}	
/* End Point */

/* Forum */
	function back_topic(frm_id)
	{
		window.location.href= "index.php?module=forum&action=topic&frm_id="+frm_id;
	}			
	
	function back_post(top_id)
	{
		window.location.href= "index.php?module=forum&action=view_post&top_id="+top_id;
	}

	function fivestar_rate() 
	{
		var rate = document.getElementById('rate').value;
		if (rate==false) {
			document.getElementById('rate_img').innerHTML='<img src="images/modules/rate_0.gif" width="80" height="15" alt="*****"/>';
		}
		else
		{
			for(var i=1; i<=5; i++)
			{
				if(i==rate){
					document.getElementById('rate_img').innerHTML='<img src="images/modules/rate_'+i+'.gif" width="80" height="15" alt="*****"/>';
					break;
				}
			}
		}
	}
/* End Forum */

/* Mailbox */
	function status_connected(mem_id)
	{
		window.location.href= "index.php?module=profile&action=profile&mem_id="+mem_id+"&msg=connected";
	}
	
	function mail_froward(mes_id)
	{
		window.location.href= "index.php?module=mailbox&action=compose&task=froward&mes_id="+mes_id;
	}

	function mail_reply(mes_id)
	{
		window.location.href= "index.php?module=mailbox&action=compose&task=reply&mes_id="+mes_id;
	}	
/* End Mailbox */

/* LICENSE */
	function download_mylicense(ldw_id)
	{
		window.location.href= "index.php?module=profile&action=download_license&ldw_id="+ldw_id;
	}
/* END LICENSE */

/* MODULE */
	function download_mymodule(mdw_id)
	{
		window.location.href= "index.php?module=profile&action=download_module&mdw_id="+mdw_id;
	}
/* END MODULE */

/* VALIDATION FORM */
	function validate_email() 
	{
		var str = document.getElementById('email').value;
		var month = document.getElementById('month').value;
		var day = document.getElementById('day').value;
		var year = document.getElementById('year').value;
		if (str==false) 
		{
			alert("E-mail Address can not be empty.");						
			return false;
		}
		else if (month==false) 
		{
			alert("Date of Birth month can not be empty.");						
			return false;
		}
		else if (day==false) 
		{
			alert("Date of Birth day can not be empty.");						
			return false;
		}
		else if (year==false) 
		{
			alert("Date of Birth year can not be empty.");						
			return false;
		}		
		else if(str!=false)
		{		
			var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		    if (!str.match(re)) {
		        alert("Verify the email address format.");
		        return false;
			}
		}
		return true;
	}	

	function validate_send_message() 
	{
		if (document.getElementById('subject').value==false) 
		{
			alert("Subject can not be empty.");						
			return false;
		}
		else if (document.getElementById('message').value==false) 
		{
			alert("Message can not be empty.");						
			return false;
		}				
		return true;
	}	
	
	function validate_compose() 
	{
		if (document.getElementById('email').value==false) 
		{
			alert("Recipient email address can not be empty.");						
			return false;
		}		
		if (document.getElementById('subject').value==false) 
		{
			alert("Subject can not be empty.");						
			return false;
		}
		else if (document.getElementById('message').value==false) 
		{
			alert("Message can not be empty.");						
			return false;
		}				
		return true;
	}		
	
	function validate_invite(friend) 
	{
		if (friend==1) 
		{
			alert("You are already connected with him/her.");						
			return false;
		}			    
		else if (document.getElementById('message').value==false) 
		{
			alert("Message can not be empty.");						
			return false;
		}
		return true;
	}

	function validate_email_account() 
	{
		var email = document.getElementById('email').value;
		var password = document.getElementById('password_email').value;
		if (email==false) 
		{
			alert("E-mail Address can not be empty.");						
			return false;
		}
		else if (password==false) 
		{
			alert("Password can not be empty.");						
			return false;
		}
		else if(email!=false)
		{		
			var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		    if (!email.match(re)) {
		        alert("Verify the email address format.");
		        return false;
			}
		}
		return true;	
	}
	
	function validate_password_account() 
	{
		var old_password = document.getElementById('old_password').value;
		var new_password = document.getElementById('new_password').value;
		var confirm_password = document.getElementById('confirm_password').value;
		if (old_password==false) 
		{
			alert("Old Password cannot be empty.");						
			return false;
		}
		else if (new_password==false) 
		{
			alert("New Password cannot be empty.");						
			return false;
		}
		else if (confirm_password==false) 
		{
			alert("Confirm Password cannot be empty.");						
			return false;
		}		
		else if (new_password!=confirm_password) 
		{
			alert("New Password and Confirm Password do not match.");						
			return false;
		}
		else if (old_password==new_password) 
		{
			alert("Exist password and new password can not be same.");						
			return false;
		}
		return true;	
	}

	function validate_new_photo() 
	{
		var myphoto = document.getElementById('myphoto').value;
		if (myphoto==false) 
		{
			alert("New Photo cannot be empty.");						
			return false;
		}
		return true;		
	}

	function validate_add_point(pac_id) 
	{
		/* alert(pac_id);
		if(pac_id==false)
		{
			alert('Please choose a point package');
		} */	
		if(document.getElementById('agree').checked==false)
		{
			alert('You have agreed with terms of conditions.');
			return false;
		}
		
		return true;		
	}	
	
	function validate_do_getlicense() 
	{
		var member_point = document.getElementById('member_point').value;
		var point_need = document.getElementById('point_need').value;
		var is_less = member_point-point_need;
		
		if(point_need==0){
			return true;		
		}
		else if(is_less<0){
			return confirm('Please add point in your account because of your total point ('+member_point+') is fewer than point needed ('+point_need+').');		
		}		
		
		return true;		
	}	
/* END VALIDATION FORM */


/*Download Center */
	function enable_download()
	{		
		if(document.getElementById('terms_conditions').checked==true && document.getElementById('exchange_points').checked==true)
		{
			document.getElementById('submit').style.display="block";
			document.getElementById('start_download').style.display="block";			
			document.getElementById('disable').style.display="none";
		}
		else
		{
			document.getElementById('submit').style.display="none";
			document.getElementById('start_download').style.display="none";
			document.getElementById('disable').style.display="block";
		}
	}
	
	function start_download(i)
	{	
		var mod_id = document.getElementById('mod_id').value;
		var point = document.getElementById('point').value;
		document.getElementById('start_download').innerHTML="Thank You for supporting this great service. Your download may start in <span style='color:blue;'>"+i+"</span> seconds if Your download will not start after <span style='color:blue;'>10</span> seconds for some reason, please <a href='index.php?module=downloadcenter&action=download_module&task=1&mod_id="+mod_id+"'><span style='color:blue;'>Click here</span></a>";	
		if(i>0)
		{
			i--;
			setTimeout("start_download("+i+")", 1000);		
		}
		else{
			return true;
		}	
	}
	
	function validate_download_module(member_point,point_need,mod_id,capability)
	{
		if(capability == 1){
			start_download(10);
		}
		else if(member_point < point_need){
			return confirm('Please add point in your account because of your total point ('+member_point+') is fewer than point needed ('+point_need+').');
		}		
		else{
			start_download(10);
		}
		
		return true;
	}
	
	function locked_topic()
	{
		alert("Topic locked to post. You can not post under this topic.");		
	}
	
	/* MENU */
	function menu_home(val)
	{
		if( val==1) {
			$('m_home').addClassName('h-h');
		}
		else {
			$('m_home').removeClassName('h-h');		
		}
	}		
	function menu_myprofile(val)
	{
		if( val==1) {
			$('m_myprofile').addClassName('h-m-p');
		}
		else {
			$('m_myprofile').removeClassName('h-m-p');		
		}
	}	
	function menu_myaccount(val)
	{
		if( val==1) {
			$('m_myaccount').addClassName('h-m-a');
		}
		else {
			$('m_myaccount').removeClassName('h-m-a');		
		}
	}	
	function menu_mylicense(val)
	{
		if( val==1) {
			$('m_mylicense').addClassName('h-m-l');
		}
		else {
			$('m_mylicense').removeClassName('h-m-l');		
		}
	}	
	function menu_download(val)
	{
		if( val==1) {
			$('m_download').addClassName('h-d');
		}
		else {
			$('m_download').removeClassName('h-d');		
		}
	}	
	function menu_forum(val)
	{
		if( val==1) {
			$('m_forum').addClassName('h-f-s-m');
		}
		else {
			$('m_forum').removeClassName('h-f-s-m');		
		}
	}	
	function menu_faq(val)
	{
		if( val==1) {
			$('m_faq').addClassName('h-m-f');
		}
		else {
			$('m_faq').removeClassName('h-m-f');		
		}
	}
	/*END  MENU */	
	
	////////////
	function download_product()
	{
		alert("Please wait for starting/ending Downloading Your selected Product");
	}

	function get_download_license(mod_id,userpoint,point,currentpage)
	{
		var x = document.getElementById('license_type').value;
		var y = document.getElementById('Product').value;
		var z = document.getElementById('license_url').value;
		
		if(y==""){
			alert("You should select a product");
			return false;
		}
		
		if(z==""){
			alert("You should provide a domain/url name");
			return false;
		}
		
		if(x==""){
			alert("You should select a license type");
			return false;
		}
		
		if(x=="Standard License"){
			license_download();
			return false;
		}
		
		if(userpoint < point){
			
			alert("You need to add Point");
			window.location.href= "index.php?module=point&action=add_point&mod_id="+mod_id+"&license_url="+x+"&page="+currentpage;
			return false;
		}
		else{
			license_download();
			return false;
		}		
	}
	
	var kk = 10;
	function license_download()
	{
		document.getElementById('license_dwnl').innerHTML="Thank You for supporting this great service. Your download may start in <span style='color:blue;'>"+ kk +"</span> seconds if Your download will not start after <span style='color:blue;'>10</span> seconds for some reason, please <a href=''><span style='color:blue;'>Click here</span></a>";	
		if(kk>0)
		{
		kk--;
		setTimeout("license_download()", 500);		
		}
		else{
			//window.location.href= "index.php?module=license&action=license_home&mod_id="+mod_id+"&point="+point;
		}
	}
