function checkLogin() {
	if(document.getElementById("HomeUser").value=="") {
		alert("Please enter your username");
		document.getElementById("HomeUser").focus();
		return false;
	}
	if(document.getElementById("HomePassword").value=="") {
		alert("Please enter your password");
		document.getElementById("HomePassword").focus();
		return false;
	}
	document.loginFrm.submit();
}


function checkSearch() {
	if(document.getElementById("HomeKeyword").value=="") {
		alert("Please enter keyword to search");
		document.getElementById("HomeKeyword").focus();
		return false;
	}
	document.searchFrm.submit();
}

function checkLogin1() {
	if(document.getElementById("HomeUser").value=="") {
		alert("Please enter your username");
		document.getElementById("HomeUser").focus();
		return false;
	}
	if(document.getElementById("HomePassword").value=="") {
		alert("Please enter your password");
		document.getElementById("HomePassword").focus();
		return false;
	}
	return true;
}

function takeFocus() {
	document.getElementById("HomeUser").focus();
}


function checkPage() {
	var selectTitle = document.getElementById("StaticpageFldDefinedTitle").value;
	var rUrl = document.getElementById("rUrl").value;
	if(selectTitle=="0") {
		document.getElementById("newTitle").style.display = "inline";
		document.getElementById("StaticpageFldTitle").focus();
		
		document.getElementById("upload_pdf").style.display = "inline";
		document.getElementById("hide_upload_pdf").style.display = "none";
	}
	else if(selectTitle	==	'')
	{
		document.getElementById("upload_pdf").style.display = "none";
		document.getElementById("hide_upload_pdf").style.display = "inline";
		document.getElementById("newTitle").style.display = "none";
	}
	
	else {
		document.getElementById("newTitle").style.display = "none";
		document.getElementById("upload_pdf").style.display = "inline";
		document.getElementById("hide_upload_pdf").style.display = "none";
		window.location.href=rUrl+"/"+selectTitle;
		
	}
}

function checkpage() {
	if(document.getElementById("StaticpageFldDefinedTitle").value=="") {
		alert("Please select a page");	
		document.getElementById("StaticpageFldDefinedTitle").focus();
		return false;
	}
	else if(document.getElementById("StaticpageFldDefinedTitle").value=="0") {
		if(document.getElementById("StaticpageFldTitle").value=="") {
			alert("Please enter the new page title");	
			document.getElementById("StaticpageFldTitle").focus();
			return false;	
		}
	}
	return true;	
}

function checksubmenu() {
	if(document.getElementById("SublinkFldTitle").value=="") {
		alert("Please enter sub-menu link title");	
		document.getElementById("SublinkFldTitle").focus();
		return false;
	}
	if(document.getElementById("SublinkFldParentId").value=="") {
		alert("Please select parent menu item");	
		document.getElementById("SublinkFldParentId").focus();
		return false;
	}
	if(document.getElementById("status_1").checked==true) {
		if(document.getElementById("SublinkFldPageId").value==0) {
			alert("Please select existing page to link-up.");	
			document.getElementById("SublinkFldPageId").focus();
			return false;
		}
	}
	return true;
}

function confirm_update(cur_stat,title) {
	if(cur_stat=="Active"){
		return confirm("Do you really want to disable the "+title+" sub-menu link? The link will not display in front-end.");
	}
	else {
		return confirm("Do you really want to enable the "+title+" sub-menu link? The link will display in front-end.");
	}
}

function deleteconfirm(title) {
	return confirm("Do you really want to delete the "+title+" sub-menu link?");
}

function choosePage(val) {
	if(val==1) {
		document.getElementById("viewExisting").style.display = "inline";
	}
	else {
		document.getElementById("viewExisting").style.display = "none";
	}
}
function choosePage1(val) {
	if(val==1) {
		document.getElementById("viewExisting").style.display = "inline";
		document.getElementById("new").style.display = "none";
	}
	else {
		document.getElementById("viewExisting").style.display = "none";
		document.getElementById("new").style.display = "inline";
	}
}
function opepopup(url) {
	newwindow = window.open(url,'name');
}

function confirm_imageDel(valu) {
	if(valu=="image") {
		return confirm("Do you really want to delete selected image?");
	}
	else {
		return confirm("Do you really want to delete selected PDF file?");
	}
}

function confirm_folderDel() {
	return confirm("Do you really want to delete? All documents exists in selected directory will also be deleted.");
}
function confirm_folderUpd() {
	return confirm("Do you really want to edit? All documents exists in selected directory will also be affected.");
}

function changePage(url) {
	var valu = document.getElementById("FilesType").value;
	if(valu!="") {
		if(valu==1) {
			window.location.href = url+"admin/files/img";
		}
		else {
			window.location.href = url+"admin/files/pdfs";
		}
	}
}

function check_valid() {
	if(document.getElementById('status_0').checked==true) {
		if(document.getElementById("DocumentFldFolder1").value=="") {
			alert("Please enter the folder name");
			document.getElementById("DocumentFldFolder1").focus();
			return false;
		}
		if(!AlphaNumeric(document.getElementById("DocumentFldFolder1").value)) {
			alert("Folder name should be alpha-numeric.");
			document.getElementById("DocumentFldFolder1").focus();
			return false;
		}
		
	}
	if(document.getElementById("DocumentFldDocumentname").value=="") {
		alert("Please enter document name");
		document.getElementById("DocumentFldDocumentname").focus();
		return false;
	}
	return true;
}