<!--

// Script Source for Guest Book v2.2
// ©2004 Gurgen Alaverdian www.gurgensvbstuff.com


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,isnn) {

	if (isnn == 1){
		GetLost(window.opener.document.postnew.fComment);
		var selFrom = window.opener.document.postnew.fComment;
	}else{
		var myParent = window.parent.dialogArguments["DIALOGOPENER"];
		GetLost(myParent.document.postnew.fComment);
		var selFrom = myParent.document.postnew.fComment;
	}

	if (selFrom.storedRange) {
		 selFrom.storedRange.text = val;

	}else{
    		 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 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, act)
{
	window.location = "filter.asp?url="+pageName+"&act="+act+"&pn="+pageNumber+"&pp="+perPage

}

function ShowColor(colorValue)
{
	Color.style.backgroundColor = colorValue;
	var stripValue = colorValue.replace("#", "");
	frmColor.frmhex.value=stripValue;
}

function buffer(oForm) {
  	var iRange = document.selection.createRange();
  	oForm.storedRange = iRange.duplicate();
}


function postStyle(image,iLocation,iStyle) {

	GetLost(document.postnew.fComment);
	var oForm = document.postnew.fComment;

	switch(iStyle){
		case "bold":
			var sTag = "[b]";
			var eTag = "[/b]";
			var sImage = "b.jpg";
			var eImage = "b1.jpg";
			var sID = "sbold";
			var eID = "ebold";
			if (image.id=="sbold") {var iStart = true;}
			break;
		case "it":
			var sTag = "[i]";
			var eTag = "[/i]";
			var sImage = "i.jpg";
			var eImage = "i1.jpg";
			var sID = "sit";
			var eID = "eit";
			if (image.id=="sit") {var iStart = true;}
			break;
		case "us":
			var sTag = "[u]";
			var eTag = "[/u]";
			var sImage = "u.jpg";
			var eImage = "u1.jpg";
			var sID = "sus";
			var eID = "eus";
			if (image.id=="sus") {var iStart = true;}
			break;

	}

	if (iStart) {
		if (oForm.storedRange) {
			if (oForm.storedRange.text.length > 0) {
    				oForm.storedRange.text = sTag+oForm.storedRange.text+eTag;
			}else{
				oForm.storedRange.text = sTag;
				var iSwitch = true;
			}
		}else{
    			oForm.value += sTag;
			var iSwitch = true;
  		}				
		if (iSwitch) {
			image.src = iLocation+eImage;
			image.id = eID;
		}
				
	}else{
		if (oForm.storedRange) {
			if (oForm.storedRange.text.length > 0) {
    				oForm.storedRange.text += eTag;
			}else{
				oForm.storedRange.text = eTag;
			}
		}else{
    			oForm.value += eTag;
  		}				
		image.src = iLocation+sImage;
		image.id = sID;
	}

}


function animate(iButton, action){

iButton.style.border = "2px "+action;

}

function moveoffline(ID, action)
{
	
	switch (action) {
	case "offline":
		var conf = window.confirm("This action will take comment offline. Continue?"); break;
	case "online":
		var conf = window.confirm("This action will move record into online database. Continue?"); break;		
	case "delete":
		var conf = window.confirm("This action will completely remove selected comment(s) from database \nas well as delete a picture attached to this comment. Continue?"); break;
	}

	if (conf){
		window.location="adminmisc.asp?ID="+ID+"&act="+action;
	}

}

//-->



