﻿// JScript File
// Common functions
function validate(theForm, _ErrMsg, arrNotRequired) {
	try {
		validForm = true;
		firstError = null;
		errorstring = '';
		var _frm = document.getElementById(theForm);
		if(_frm==null){return false;}
		var x = _frm.elements;
		var arr = ','+arrNotRequired.toString()+ ',';
		for (var i=0;i<x.length;i++) {
			if (arr.indexOf(','+x[i].id+',')==-1) {
				if (!x[i].value)
				{
					var str="";
					str = "".concat(x[i].value);
					if ((str.toString() != "undefined") || (str.toString() != "button") || (str.toString() != "hidden"))
					{
						writeError(x[i], ' (*)');
						if (firstError ==null)
						firstError = x[i];				
					}
				}
				if (x[i].id == 'txt_compemail')
				{			
					var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
					if(!strEmail.test(x['txt_compemail'].value))
						writeError(x['txt_compemail'],' (*)');
				}
				if (x[i].id == 'txtEmail')
				{			
					var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
					if(!strEmail.test(x['txtEmail'].value))
						writeError(x['txtEmail'],' *');
				}
				if (x[i].id == 'txt_confirmPassword')
				{			
				    if (x[i].value != document.getElementById('txt_newPassword').value)
				    {
					    writeError(x['txt_confirmPassword'],' (*) Mật khẩu xác nhận không chính xác!');
				    }
				}
			}
		}
		
		if (!W3CDOM)
			alert(errorstring);
		if (firstError)
			firstError.focus();
		if (validForm)
			return true;
			
		return false; // I return false anyway to prevent actual form submission. Don't do this at home!
		
	}catch(ex){alert(ex);return(false);}
}

function revalidate() {
		var noerror = true;
		if (!this.value)
		{
			var str="";
			str = "".concat(this.type);
			if ((str.toString() != "undefined") || (str.toString() != "button") || (str.toString() != "hidden"))
			{
				noerror = false;			
			}
		}
		if (this.name == 'txtEmail')
		{			
			var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
			if(!strEmail.test(this.value))
				noerror = false
		}
		if (this.name == 'txt_compemail')
				{			
					var strEmail = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
					if(!strEmail.test(this.value))
						noerror = false
				}
		if(noerror){
			this.className = this.className.substring(0,this.className.lastIndexOf(' '));
			this.parentNode.removeChild(this.hasError);
			this.hasError = null;
			this.onchange = null;
		}			
}

function writeError(obj,message) {
	validForm = false;
	if (obj.hasError) return;
	if (W3CDOM) {
		obj.className += ' error';
		obj.onchange = revalidate;
		var sp = document.createElement('span');
		sp.className = 'error';
		sp.appendChild(document.createTextNode(message));
		obj.parentNode.appendChild(sp);
		obj.hasError = sp;
	}
	else {
		errorstring += obj.name + ': ' + message + '\n';
		obj.hasError = true;
	}
	if (!firstError)
		firstError = obj;
}

function removeError() {
	this.className = this.className.substring(0,this.className.lastIndexOf(' '));
	this.parentNode.removeChild(this.hasError);
	this.hasError = null;
	this.onchange = null;
}

// Specific functions
function viewTab(_oid, _pid, _fid){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_pid==null)||(_pid=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "/ajax/actions.aspx?type=viewTab&pid=" + window.encodeURIComponent(_pid) + "&fid=" + window.encodeURIComponent(_fid) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;	
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.tostring);}
}

function viewCat(_oid,_page){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_page==null)||(_page=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewCat&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.tostring);}
}

function viewStudentPage(_oid,_page){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_page==null)||(_page=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=viewStudentPage&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.tostring);}
}

function login(){
	try{
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = '';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _username = document.getElementById("txt_username").value;
		var _password = document.getElementById("txt_password").value;
		var obj = document.getElementById("txt_username");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "/ajax/actions.aspx?type=login&username=" + window.encodeURIComponent(_username) + "&password=" + window.encodeURIComponent(_password) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET", actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        window.location = "/khachhang";
			    }	
			    else if(HttpRequest.responseText == "false")
			    {
			        document.getElementById('err').innerHTML = 'Tên truy cập hoặc mật khẩu không đúng ';
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function checkOldpassword(){
	try{
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = 'txt_newPassword,txt_confirmPassword';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _oldpassword = document.getElementById("txt_oldPassword").value;
		var obj = document.getElementById("txt_oldPassword");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=checkOldpass&oldpass=" + window.encodeURIComponent(_oldpassword) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        document.getElementById('oldPassword').innerHTML = ' OK!';
			    }	
			    else if (HttpRequest.responseText == "false")
			    {
			        document.getElementById('oldPassword').innerHTML = ' Mật khẩu không chính xác!';
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function confirmtext(){
	try{
	    valid = true;
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = 'txt_compfax';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _result = document.getElementById("txt_result").value;
		var obj = document.getElementById("txt_result");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=confirmtext&result=" + window.encodeURIComponent(_result) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "false")
			    {
			        document.getElementById('result').innerHTML = ' Kết quả không chính xác!';
			        valid = false;
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		if (valid) return true;
		return false;
	}catch(ex){alert(ex);}
}

function changepass(){
	try{
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = '';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _oldpassword = document.getElementById("txt_oldPassword").value;
		var _newpassword = document.getElementById("txt_newPassword").value;
		var obj = document.getElementById("txt_newPassword");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=changepassword&oldpass=" + window.encodeURIComponent(_oldpassword) + "&newpass=" + window.encodeURIComponent(_newpassword) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        window.location = "khachhang";
			    }	
			    else
			    {
			        
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function studentlogin(){
	try{
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = '';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _username = document.getElementById("txt_username").value;
		var _password = document.getElementById("txt_password").value;
		var obj = document.getElementById("txt_password");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=studentlogin&username=" + window.encodeURIComponent(_username) + "&password=" + window.encodeURIComponent(_password) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        window.location = "TrangHocVien";
			    }	
			    else
			    {
			        document.getElementById('err').innerHTML = 'Tên truy cập hoặc mật khẩu không đúng ';
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function studentreg(){
	try{
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = '';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _name = document.getElementById("txt_studname").value;
		var _mail = document.getElementById("txt_studmail").value;
		var _phone = document.getElementById("txt_studphone").value;
		var _username = document.getElementById("txt_studusername").value;
		var _password = document.getElementById("txt_newPassword").value;
		var obj = document.getElementById("txt_newPassword");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "ajax/actions.aspx?type=studentreg&name=" + window.encodeURIComponent(_name) + "&mail=" + window.encodeURIComponent(_mail)+ "&phone=" + window.encodeURIComponent(_phone)+ "&username=" + window.encodeURIComponent(_username)+ "&password=" + window.encodeURIComponent(_password) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        window.location = "TrangHocVien";
			    }	
			    else
			    {
			        alert("sak");
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function reg_trial(_pid){
	try{
	    if (confirmtext()==false) {return;}
		var _frm = document.getElementById('frmcontact');
		if (_frm==null) return(false);
		var arrNotRequired = 'txt_compfax';
		if (validate("frmcontact", " *", arrNotRequired)==false) {
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _taxcode = document.getElementById("txt_comptaxcode").value;
		var _compname = document.getElementById("txt_compname").value;
		var _contactperson = document.getElementById("txt_contactperson").value;
		var _compaddress = document.getElementById("txt_compaddress").value;
		var _compphone = document.getElementById("txt_compphone").value;
		var _compfax = document.getElementById("txt_compfax").value;
		var _compemail = document.getElementById("txt_compemail").value;
		var obj = document.getElementById("txt_compemail");
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "/ajax/actions.aspx?type=regtrial&code=" + window.encodeURIComponent(_taxcode) + "&name=" + window.encodeURIComponent(_compname)+ "&add=" + window.encodeURIComponent(_compaddress)+ "&phone=" + window.encodeURIComponent(_compphone)+ "&fax=" + window.encodeURIComponent(_compfax)+ "&email=" + window.encodeURIComponent(_compemail) + "&contactperson=" + window.encodeURIComponent(txt_contactperson) +"&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "truetrue") {
			       alert('Bạn đã đăng ký dùng thử thành công!\nBạn vui lòng check email để download bản dùng thử');
				   window.location.reload();
			    }	
			    else
			    {
			        alert("Có lỗi khi gửi, bạn vui lòng thử lại sau!");
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex);}
}

function cusrequest(){
	try{
		if (document.getElementById("txt_cusrequest").value == "") {
			writeError(document.getElementById("txt_cusrequest"), ' (*)');
			return;
		}
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		var _msg = document.getElementById("txt_cusrequest").value;
		var actionURL = "ajax/actions.aspx?type=cusrequest&msg=" + window.encodeURIComponent(_msg) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
			    if (HttpRequest.responseText == "true") {
			        document.getElementById("success").innerHTML = "Yêu cầu đã được gửi, xin cảm ơn bạn."
			    }	
			    else
			    {
			        
			    }
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){}
}	

function viewNews(_oid,_page){
	try{
		var HttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		if (!HttpRequest) return;
		if((_oid==null)||(_oid=='')||(_page==null)||(_page=='')){return;}
		var obj = document.getElementById(_oid);
		if(!obj){return;}
		obj.innerHTML = '<img src="/images/assets/indicator.gif" />';
		var actionURL = "/ajax/actions.aspx?type=viewNews&page=" + window.encodeURIComponent(_page) + "&rd=" + Math.random();
		//window.location = actionURL;
		//return;
		var indicator = document.getElementById('processDiv');
		if(indicator!=null){
			indicator.style.display = 'block';
		}
		HttpRequest.open("GET",actionURL);
		HttpRequest.onreadystatechange = function()
		{
		   if (HttpRequest.readyState == 4 && HttpRequest.status == 200)
		   {
			   if(HttpRequest.responseText.indexOf('err=')!=0){
					obj.innerHTML = HttpRequest.responseText;
			   }
			   if(indicator!=null){indicator.style.display = 'none';}
		   }
		}
		HttpRequest.send(null);
		return;
	}catch(ex){alert(ex.tostring);}
}

function get_value(_frm){
	var getStr = "";
	var frm = document.getElementById(_frm);
	var inputs = frm.getElementsByTagName("input");
	if(!frm){return;}
	
	for (i=0; i<inputs.length; i++) {
		if(inputs[i].name!='' && inputs[i].name!='undefined') {
			switch(inputs[i].type){
				case "text":
					getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
					break;
				case "password": 
					getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
					break;
				case "hidden":
					getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
					break;
				case "checkbox":
					if(inputs[i].checked) {
						getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
					}else{
						getStr += ""; //"&" + inputs[i].name + "="
					}
					break;
				case "radio":
					if(inputs[i].checked) {
						getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
					}else{
						getStr += "";// + inputs[i].name + "="
					}
					break;
				default:
					break;
			}
		}
	}
	inputs = frm.getElementsByTagName("textarea");
	if(!inputs.length) {
		getStr += "&" + inputs.name + "=" + window.encodeURIComponent(inputs.value);
	}else{
		for (i=0; i<inputs.length; i++) {
			getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
		}
	}
	inputs = frm.getElementsByTagName("select");
	if(!inputs.length) {
		getStr += "&" + inputs.name + "=" + window.encodeURIComponent(inputs.text);
	}else{
		for (i=0; i<inputs.length; i++) {
			getStr += "&" + inputs[i].name + "=" + window.encodeURIComponent(inputs[i].value);
		}
	}
	return getStr;
}
function sendmail(_title, _body){
	window.location = "mailto:your-friend@email.com?subject=" + encodeURIComponent(_title) + '&body=' + window.encodeURIComponent(_body);
}

function register_trial(_oid) {
	try{
		var getStr = "type=regtrial"
		getStr += get_value(_oid);
		getStr += "&rd=" + Math.random(); 
		var actionURL =  "/ajax/actions.aspx";		
		
		$.ajax({
			type: "POST",
			url: actionURL,
			data: getStr,
			success: function(msg){
				$("#" + _oid)[0].reset();
				if(msg.indexOf('err=')!=0){
					alert(regOK);
				}
				else {
					alert(regFail);
				}
			}
		});
		return;
	}catch(ex){}
}