<!--

// Script Source for Guest Book.
// ©2003 Gurgen Alaverdian www.gurgensvbstuff.com

function submitform(oform)
{
var errorm = "";
var uname = (oform.fName.value);
var uname = uname.replace(/\s/g, "");
var email = "";
var ePat = (/(\w+)@(\w+)\.(\w+)/);
var matchEmail=email.match(ePat);
var comment = (oform.fComment.value);
var icomment = comment.replace(/\s/g, "");
var ASPCodePat = /<%(.|\n)*%>|<script(.|\n)*script>|<style(.|\n)*style>|<meta[\s]/gi;
var testForASP = comment.match(ASPCodePat);
var cLenght = comment.length;
var maxChr = (oform.maxPost.value);

	if (cLenght > maxChr){

		var errorm = ("    -- Vas vic sadrzi " + cLenght + " Karaktera. Samo " + maxChr + " karaktera je dozvoljeno.  " + "\n");
		var trap = ("error");
		
	}

	if (testForASP !== null){
		var errorm = errorm + ("    -- Vas vic vjerovatno sadrzi nedozvoljavajuci kod!    " + "\n");
		var trap = ("error");
	}


	if (uname == "") {
		var errorm = errorm + ("    -- Nedostaje Ime!    " + "\n");
		var trap = ("error");
	}
	if (email !== "") {
		if (matchEmail == null){
			var errorm = errorm + ("    -- Email format nije dobar!    " + "\n");
			var trap = ("error");
		}	
	}
	if (icomment == "") {
		var errorm = errorm + ("    -- Nema vica, upisite vic!    " + "\n");
		var trap = ("error");
	}

		

	if (trap == "error") {
		alert ("Molimo vas da popravite gresku i pokusate ponovo:" + "\n" + "\n" + errorm);
	}
	else {
		 var longPat = /((\S){60})/g;
		 var testComment = (comment);
		 oform.fComment.value = testComment.replace(longPat, "$1" + "\n");
		 oform.submitFlag.value = "post";
		 oform.submit();
	     }
}

function popup(url,wname,params)
{
PopWin = window.open(url,wname,params);
PopWin.focus();
}

function Save_Message(action)
{

	if (action == "save"){
		var conf = window.confirm("Are you sure you want to save changes?");
		if (!conf){
		return
		}
		else
			document.postnew.action.value = "save"
			document.postnew.submit();
	}

	if (action == "clear"){
		var conf = window.confirm("This action will clear the comment in the database! Continue?");
		if (!conf){
		return
		}
		else
			document.postnew.action.value = "clear"
    		document.postnew.submit();
	}
	
}

function sm(val)
{
var selFrom = window.opener.document.postnew.elements["fComment"];

selFrom.value = selFrom.value + val
}

function checkAll(oChkBox)
{
var bStatus = oChkBox.checked;
var docFrm = document.forms["admin"];
    for (i=0; i < docFrm.elements.length; i++) {
    	if (docFrm.elements[i].type == "checkbox") {
			docFrm.elements[i].checked = bStatus;
       }
    }
}

function popup(url,wname,params)
{
PopWin = window.open(url,wname,params);
PopWin.focus();
}

function sting(cform)
{
var n = (cform.T1.value);
var p = (cform.T2.value);
var c = (cform.T3.value);
if (p !== c) {
	alert("Password does not match.");
	cform.T2.value = ("");
	cform.T3.value = ("");
	return
}
if (n == "" | p == "") {
	var conf = window.confirm("Name or Password is blank. Do you want to continue?");
	if (!conf) {
	return
	}
}
cform.submit();
}


function feedback(reportform)
{


	if (typeof(document.forms[reportform].report) == "object"){
			alert(document.forms[reportform].report.value);
		
	}

	if (typeof(document.forms[reportform].refreshBook) == "object"){
		window.location=window.location
		window.opener.location=window.opener.location
	}
}

function archive()
{

var arch = document.frmarchive.D1.options[document.frmarchive.D1.selectedIndex].value;

		if (arch == "2"){
			if (window.confirm("You are about to Archive All messages from Guest Book.")){
				frmarchive.submit();
			}
			else
				return
		}
		else
			if (window.confirm("You are about to archive messages older than " + arch + " days from Guest Book.")){
				frmarchive.submit();
			}
}

function showArchive(oform)
{

	if (oform.options.length == 0){
		alert("Archive List is Empty!");
		return
	}

var selArch = oform.options[oform.selectedIndex].value;
popup("archive.asp?arch=" + selArch + "&Page=1","archive","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1000,height=700");

}

function delarchive()
{

	if (document.frmarchdel.D2.options.length == 0){
		alert("Archive List is Empty!");
		return
	}
	if (window.confirm("You are about to delete selected Archive.")){
		frmarchdel.submit();
	}
}


function searchGuestBook(){
	var sTarget = document.search.D1.options[document.search.D1.selectedIndex].value;
	var sType = document.search.D2.options[document.search.D2.selectedIndex].value;
	var sDate = document.search.D3.options[document.search.D3.selectedIndex].value;
	var searchStr = document.search.T1.value;
	var matchCase = document.search.C1.checked;
	var checkStr = searchStr.replace(/\s/g, "");
	if (checkStr == "")
		return alert("Please specify a String to search.");
	if (sType !== "3"){
		var searchStr = searchStr.replace(/[^A-Za-z0-9\s_]/g, "");
		var tempSplit = searchStr.split(" ");
		var searchStr = "";
		for (var i=0; i < tempSplit.length; i++){
			if (tempSplit[i] !== ""){
				var searchStr = searchStr + "+" + tempSplit[i];
			}
		}
		searchStr = searchStr.replace(/\+/, "");
	}
	document.search.action = "search.asp?Target=" +  escape(sTarget) + "&string=" + escape(searchStr) + "&type=" + sType + "&Displ=1&Date=" + sDate + "&case=" + matchCase;
	document.search.submit();

}


function setbg(bg){

	document.bgrd.background.value = bg;
	document.bgrd.submit();

}

function saveTheme(){

var tname = (frmColor.fTname.value);
var tname = tname.replace(/\s/g, "");
var tPatt = /[^\w-]/g;
var checkName=tname.match(tPatt);

	if (tname == "") {
		alert("    -- Please Specify a name of the Theme!");
		return;
	}

	if (checkName !== null){
		alert("    -- Only Alphanumeric values,  ‘-‘ and ‘_’ allowed as a Theme Name!");
		return;
	}

	document.frmColor.sTheme.value = "save"
	document.frmColor.submit();
}

function delTheme()
{

	if (document.frmColor.tList.options.length == 0){
		alert("Themes List is Empty");
		return
	}
	if (window.confirm("You are about to delete selected Theme.")){

		document.frmColor.ThemeConfig.value = "delete"
		document.frmColor.submit();
	}
}

function loadTheme()
{

	if (document.frmColor.tList.options.length == 0){
		alert("Themes List is Empty");
		return
	}
	if (window.confirm("You are about to load selected Theme. If you have not saved current configuration it will be overridden!")){

		document.frmColor.ThemeConfig.value = "load"
		document.frmColor.submit();
	}
}


function selectPages(perPage, pageNumber, pageName)
{

	document.cookie = "Page="+pageNumber+";path=/";
	document.cookie = "PerPage="+perPage+";path=/";
	window.location = pageName;
}

function ShowColor(colorValue)
{


Color.style.backgroundColor = colorValue;
var stripValue = colorValue.replace("#", "");
frmhex.value=stripValue;

}



//-->



