<!-- 

// Rapid Classified v2.1 - Pro
// Developed by GA Soft ©2003-2004. Get a copy of this software at http://www.gurgensvbstuff.com

function catadmin(iAction) {



	switch (iAction) {

		case "create":
			cname = cat.ncat.value;
			scname = cat.nscat.value;
			descr = cat.ndescr.value;
			if (cname == "" | scname == "" | descr == "") {
				alert ("Category, Description and First Subcategory Names Must Be Specified!");
			}else{
				cat.submitFlag.value = "create";
		 		cat.submit();
			}
		break;
		case "addsubcat":
			scname = cat.ascat.value;
			if (scname == "") {
				alert ("Please Specify Subcategory Name!");
			}else{
				cat.submitFlag.value = "addsubcat";
		 		cat.submit();
			}
		break;
		case "catmod":
			cname = cat.mcat.value;
			descr = cat.mdescr.value;
			if (cname == "" | descr == "") {
				alert ("Category and Description Must Be Specified!");
			}else{
				cat.submitFlag.value = "catmod";
		 		cat.submit();
			}
		break;
		case "catsmod":
			scname = cat.mscat.value;
			if (scname == "") {
				alert ("Please Specify Subcategory Name!");
			}else{
				cat.submitFlag.value = "catsmod";
		 		cat.submit();
			}
		break;

		case "delcat":
			if (window.confirm("You are about to DELETE selected Category!")) {
				cat.submitFlag.value = "delcat";
				cat.action = "admin_deletecat.asp";
		 		cat.submit();
			}
		break;

		case "delscat":
			if (window.confirm("You are about to DELETE selected Subcategory!")) {
				cat.submitFlag.value = "delscat";
				cat.action = "admin_deletecat.asp";
			 	cat.submit();
			}
		break;
	}


}

function selectcat(ipage) {

	oform = document.cat;
	catID = oform.ccat.options[oform.ccat.selectedIndex].value;
	window.location = ipage+"?catid="+catID;

}

function selectsubcat() {

	oform = document.cat;
	catID = oform.ccat.options[oform.ccat.selectedIndex].value;
	subcatID = oform.cscat.options[oform.cscat.selectedIndex].value;
	window.location = "admin_cat.asp?catid="+catID+"&subcatID="+subcatID;

}

function validateInput() {

	var errorm = "";
	var nick = document.register.R1.value.replace(/[\s<>']/g, "");
	document.register.R1.value = nick
	var city = document.register.R2.value.replace(/[<>']/g, "");
	document.register.R2.value = city
	var email = document.register.R3.value.replace(/[\s<>']/g, "");
	var pass = document.register.R4.value.replace(/[\s<>]/g, "");
	document.register.R4.value = pass
	var cpass = document.register.R5.value.replace(/[\s<>]/g, "");
	document.register.R5.value = cpass
	var ePat = /^([\w-\.]+)@([\w-]+)\.([\w-\.]+)$/g;
	var matchEmail=email.match(ePat);
	var nLen = nick.length;
	var pLen = pass.length;


	if (nick == "" | email == "" | city == "" | pass == "" | cpass == "") {
		var errorm = errorm + ("    -- One of the required fields is empty!     \n");
		var trap = ("error");
	}


	if (email !== "") {
		if (matchEmail == null){
			var errorm = errorm + ("    -- Email format is invalid!     \n");
			var trap = ("error");
		}
	}

	if (nick !== "") {
		if (nLen < 4){
			var errorm = errorm + ("    -- Name must be at list 4 characters long!     \n");
			var trap = ("error");
		}
	}

	if (pass !== "") {
		if (pLen < 6){
			var errorm = errorm + ("    -- Password must be at list 6 characters long!     \n");
			var trap = ("error");
		}
	}

	if (pass !== cpass) {
		var errorm = errorm + ("    -- Password do not match!     \n");
		var trap = ("error");

	}


	if (trap == "error") {
		alert ("Please fix the following errors and resubmit:\n\n" + errorm);
	} else {
		document.register.B1.disabled = true;
		document.register.submit();
	}

}

function ulogon(oform) {

	var email = oform.L1.value;
	var ePat = /^([\w-\.]+)@([\w-]+)\.([\w-\.]+)$/g;
	var matchEmail = email.match(ePat);

	if (email == "" | matchEmail == null) {
		alert("    -- Email format is invalid!     \n");
		return;
	}
	oform.submit();
}

function usrmgr(oForm, iAction, user) {

	switch (iAction) {

		case "moderator":
			if (window.confirm("You are about to change an account status for user <"+user+">.")) {
				oForm.itask.value = iAction;
				oForm.submit();		
			}
		break;

		case "maillist":
			if (window.confirm("You are about to change an Email List participation status for user <"+user+">.")) {
				oForm.itask.value = iAction;
				oForm.submit();		
			}
		break;

		case "add_credit":
			if (window.confirm("You are about to ADD credits for user <"+user+">.")) {
				oForm.itask.value = iAction;
				oForm.submit();		
			}
		break;

		case "remove_credit":
			if (window.confirm("You are about to REMOVE credits for user <"+user+">.")) {
				oForm.itask.value = iAction;
				oForm.submit();		
			}
		break;

		default:
			if (window.confirm("You are about to "+iAction+" account for user <"+user+">.")) {
				oForm.itask.value = iAction;
				oForm.submit();		
			}
	}

}

function popup(url,wname,params) {
	PopWin = window.open(url,wname,params);
	PopWin.focus();
}

function evalSize(iw,ih) {

	if (document.getElementById("uimage")!==null) {
		var osz=document.getElementById("sz");
		var oimage=document.getElementById("uimage");
		var w = oimage.width;
		var h = oimage.height;
		osz.innerHTML="Dimension: "+w+"x"+h+" px";
		if (w > iw | h > ih) {
			alert("The Image size is greater than maximum allowed: "+iw+"x"+ih+"px.\n\nPlease Select a different image.");
			document.img.isvalid.value="false";
		}else{
			document.img.isvalid.value="true";
			document.img.imgw.value = w;
			document.img.imgh.value = h;
		}

	}
}

function sendImage(oForm, oRemForm) {
	
	if (oForm.isvalid.value=='true') {
		oRemForm.action = "iprev.asp?w="+oForm.imgw.value+"&h="+oForm.imgh.value;
		oForm.B2.disabled = true;
		oRemForm.submit();
	}else{
		alert("The Image size is greater than maximum allowed: 400x400px.\n\nPlease Select a different image to upload.");
	}


}

function seebanner() {
	var oform = document.img;
	var banner = oform.selpic.value;
	var olayer=document.getElementById("yourbanner");
	var oimage=document.getElementById("uimage");
	if (banner !== "") {
		var bPat = /\.jpg$|\.gif$/i;
		var matchbName = banner.match(bPat);
		if (matchbName !== null) {
			olayer.style.visibility = "visible";
			oform.bPath.value = banner;
			var srcbanner = banner.replace(/\\/g, "/");
			oimage.src="file:///"+srcbanner;
			setTimeout('evalSize(468,60)', 100);
		}else{
			alert("Only .jpg or .gif images allowed!");
			return false;
		}
	}else{
		alert("No image were selected!");
		return false;
	}

}

function attachBaner() {
	var oform = document.img;
	if (oform.isvalid.value == "true") {
		oform.B2.disabled = true;
		oform.submit();
	}else{
		alert("No valid image has been selected! Please select a valid banner image and click 'Preview'.");
	}

}

function postAd(oform, maxchr, update) {

	var errorm = "";
	var subject = oform.P1.value.replace(/[<>]/g, "");
	oform.P1.value = subject

	var descr = oform.P5.value.replace(/[<>]/g, "");
	oform.P5.value = descr

	var cLenght = descr.length;

	if (cLenght > maxchr){

		var errorm = ("    --The Description contains " + cLenght + " characters. Only " + maxchr + " allowed. Please revise!    \n");
		var trap = ("error");

	}
	
	if (subject == "") {
		var errorm = errorm + ("    -- Subject must be specified!    \n");
		var trap = ("error");


	}

	if (descr == "") {
		var errorm = errorm + ("    -- Description must be specified!    \n");
		var trap = ("error");


	}


	if (trap == "error") {
		alert ("Please fix the following errors and resubmit:\n\n" + errorm);
	}else {
		 var longPat = /((\S){70})/g;
		 var testdescr = (descr);
		 oform.P5.value = testdescr.replace(longPat, "$1" + "\n");
		 if (update == "True") {oform.action = "update.asp"} else {oform.action = "process.asp"}
		 oform.B1.disabled = true;
		 oform.submit();
	     }


}

function sendmail() {
	
	var errorm = "";
	var email = document.reply.R1.value;
	var ePat = /^([\w-\.]+)@([\w-]+)\.([\w-\.]+)$/g;
	var matchEmail=email.match(ePat);
	var message = document.reply.R2.value.replace(/[<>]/g, "");
	var mLen = message.length;
	var sname = document.reply.R3.value.replace(/[<>]/g, "");

	if (email == "" | message == "" | sname == "") {
		var errorm = errorm + ("    -- One of the required fields is empty!     \n");
		var trap = ("error");
	}


	if (mLen > 500){

		var errorm = ("    --The Message contains " + mLen + " characters. Only 500 allowed. Please revise!    \n");
		var trap = ("error");

	}

	if (email !== "") {
		if (matchEmail == null){
			var errorm = errorm + ("    -- Email format is invalid!     \n");
			var trap = ("error");
		}
	}

	if (trap == "error") {
		alert ("Please fix the following errors and resubmit:\n\n" + errorm);
	} else {
		 document.reply.submit();
	}

}

function searchAds() {

	var oform = document.search; 
	var sTarget = oform.SH3.options[oform.SH3.selectedIndex].text;
	oform.categoryName.value = sTarget;
	var searchStr = oform.SH1.value;
	var searchStr = searchStr.toLowerCase();

	if (searchStr == "") {return alert("Please specify Keywords to search.");}
	oform.SH1.value = searchStr;
	oform.action = "search.asp"
	oform.submit();


}

function savePrefs(oform, action) {

	if (action == "pass") {
		oform.flag.value = "reset";
		var id = oform.P13.value;
		var pass = oform.P14.value;
		var conf = oform.P15.value;
		if (pass !== conf) { return alert("Password do not match!"); }
		if (id == "" | pass == "") {if (!window.confirm("Admin ID or Password is blank. Would you like to continue?")) return;}

	}else{
		oform.flag.value = "config";
	}

	oform.submit();
}

function bnDelete(oform)
{


	if (oform.options.length !==0){
		i=0;
		for (i=0; i < oform.options.length; i++) {
			if (oform.options[i].selected == true){
				if (window.confirm("Do you wish to DELETE banner "+oform.options[oform.selectedIndex].value+"?")) {
					window.location="filter.asp?url=admin_rotator.asp&act=13&b="+oform.options[oform.selectedIndex].value;
				}
				return false;
			}else{
				notselected = true;
			}
   		}
		if (notselected) {alert("No banner was selected.");}

	}else{
		alert("The available banners list is empty.");
	}

}

function savePaymentOptions(oform) {

	var ePat = /(\w+)@(\w+)\.(\w+)/;
	var email = oform.AP13.value
	var re = /\d+\.\d{2}/;
	for (var i=1; i<12; i++){
		var mch = re.exec(oform.elements["AP"+i].value);
		if (mch == null) {return alert("One or more of the price fields misconfigured. Make sure to use currency format. To set a price to 0 use 0.00");} 
		oform.elements["AP"+i].value = mch;
	}

	var matchEmail=email.match(ePat);
	if (matchEmail == null){return alert("Your PayPal Email Format is Invalid!");}
	oform.submit();
	

}

function calculate(credit,minAmount) {
	var oform = document.price;
	var d = oform.D;
	var j = oform.I;
	var h = oform.H;
	var min = parseFloat(minAmount);
	var credit = parseFloat(credit);
	var total = parseFloat(oform.base.value);
	var disc = parseFloat(oform.disc.value);
	for(var i=0; i < d.length; i++) {
		if (d[i].checked) { 
			total = total + parseFloat(d[i].value);
			switch (i) {
				case 0:
					oform.final_duration.value = 20;
					break;
				case 1:
					oform.final_duration.value = 30;
					break;
				case 2:
					oform.final_duration.value = 45;
					break;
				case 3:
					oform.final_duration.value = 60;
					break;
				case 4:
					oform.final_duration.value = 10;
					break;
			}

		}
		
	}

	for(var i=0; i < j.length; i++) {
		if (j[i].checked) { 
			total = total + parseFloat(j[i].value);
			switch (i) {
				case 0:
					oform.final_image.value = 1;
					break;
				case 1:
					oform.final_image.value = 2;
					break;
				case 2:
					oform.final_image.value = 3;
					break;
				case 3:
					oform.final_image.value = 4;
					break;
				case 4:
					oform.final_image.value = 5;
					break;
				case 5:
					oform.final_image.value = 0;
					break;
			}
		}
		
	}

	for(var i=0; i < h.length; i++) {
		if (h[i].checked) { 
			total = total + parseFloat(h[i].value);
			switch (i) {
				case 0:
					oform.final_hotlist.value = 1;
					break;
				case 1:
					oform.final_hotlist.value = 0;
					break;
			}
		}
		
	}
	total = total-total*disc/100;
	total = Math.round(total*100)/(100);
	diff = total - credit;
	diff = Math.round(diff*100)/(100);
	if (diff < min) {diff = min}
	if (total > credit + 0.02) {oform.B1.disabled = true;}else{oform.B1.disabled = false;}
	total = total.toString();

	decArray = total.split(".");
	dec = decArray[1];

		if (dec==null) {
			dec="00";
		}else{
			if (dec.length>2) {
				dec=dec.substring(0,2)
			}else{

			if (dec.length==1) {dec=dec+"0";}
			}		
		}

	total = decArray[0]+"."+dec;
	document.getElementById("tp").innerHTML = "<font size='2' color='#FFFFFF'><b>"+total+"</b></font>";
	oform.final_price.value = total;

}

function checkAll(oChkBox)
{
var bStatus = oChkBox.checked;
var docFrm = document.forms["paylog"];
    for (i=0; i < docFrm.elements.length; i++) {
    	if (docFrm.elements[i].type == "checkbox") {
			docFrm.elements[i].checked = bStatus;
       }
    }
}

function createTemplate(oform) {

var name = oform.NT1.value.replace(/["']/g, "");  
var descr = oform.NT2.value.replace(/["']/g, "");
var subject = oform.NT3.value.replace(/["']/g, "");
var body = oform.NT4.value;
oform.NT1.value = name;
oform.NT2.value = descr;
oform.NT3.value = subject;
if (name == "" | descr == "" | subject == "" | body == "") {return alert("One of the fields is empty!");}
var type = oform.NT5.options[oform.NT5.selectedIndex].text;

if (window.confirm("You are about to create New '"+type+"' - '"+name+"'.")){oform.submit();}



}

//-->
