function trim(str)
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function refresh_code(base_path){
	document.getElementById("code_image").src= base_path+"/verification/index/mr/"+Math.random();
}
function checkfrm(){
	var admin = document.getElementById("admin");
	var password = document.getElementById("password");
	var verify = document.getElementById("verify");
	admin.value = trim(admin.value);
	password.value = trim(password.value);
	verify.value = trim(verify.value);
	if(admin.value==''){
		alert("Please enter the admin name.");
		admin.focus();
		return false;
	}
	if(password.value==''){
		alert("Please enter the password.");
		password.focus();
		return false;
	}
	if(verify.value.length<4){
		alert("Please enter the verify code,it must be 4 bytes.");
		verify.focus();
		return false;
	}
}

function isMail(email) {
	return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(email));
}

function trim(str)
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function refresh_code(base_path){
	document.getElementById("code_image").src= base_path+"/verification/index/mr/"+Math.random();
}
function checkfrm(){
	var admin = document.getElementById("admin");
	var password = document.getElementById("password");
	var verify = document.getElementById("verify");
	admin.value = trim(admin.value);
	password.value = trim(password.value);
	verify.value = trim(verify.value);
	if(admin.value==''){
		alert("Please enter the admin name.");
		admin.focus();
		return false;
	}
	if(password.value==''){
		alert("Please enter the password.");
		password.focus();
		return false;
	}
	if(verify.value.length<4){
		alert("Please enter the verify code,it must be 4 bytes.");
		verify.focus();
		return false;
	}
}

function isMail(email) {
	return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(email));
}

function submissionOccures(targetUrl) {
	$.ajax({url: targetUrl,
			type: 'POST',
			data: "url="+$("#website")[0].value,
			dataType: 'html',
			timeout: 1000,
			error: function(){alert('Error submitting website');},
			success: function(result){
				$("#submitWebsite").html(result);
			}
		}
	);
	return false;
}

function subscriptionOccures(targetUrl) {
	$.ajax({url: targetUrl,
			type: 'POST',
			data: "email="+$("#email")[0].value,
			dataType: 'html',
			timeout: 1000,
			error: function(){alert('Error subscribing');},
			success: function(result){
				$("#subscribeEmail").html(result);
			}
		}
	);
	return false;
}

function subscriptionBack() {
	$("#subscribeEmail").html('<td class="first" width="40" align="left">Email:</td><td width="100" align="left"><input name="email" id="email" size="12" type="text"></td><td><input name="subscribe" id="subscribe" value="Subscribe" src="/images/subscribe.png" type="image"></td>');
}

function submissionBack() {
	$("#submitWebsite").html('<td class="first" width="40" align="left">Site:</td><td id="submitWebsite" width="100" align="left"><input name="website" id="website" size="12" type="text"></td><td><input name="add" id="add" value="Submit" src="/images/add.png" type="image"></td>');
}

function viewSite(targetUrl, modelId) {
	$.ajax({url: targetUrl,
			type: 'POST',
			data: "id="+modelId,
			dataType: 'html',
			timeout: 1000,
			success: function(result){
				//$("#subscribeEmail").html(result);
			}
		}
	);
	return true;
}