function DoCallback(data){
	    // branch for native XMLHttpRequest object
	    if (window.XMLHttpRequest) {
	        req = new XMLHttpRequest();
	        req.onreadystatechange = processReqChange;
	        req.open('POST', url, true);
	        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	        req.send(data);
	    // branch for IE/Windows ActiveX version
	    } else if (window.ActiveXObject) {
	        req = new ActiveXObject('Microsoft.XMLHTTP')
	        if (req) {
	            req.onreadystatechange = processReqChange;
	            req.open('POST', url, true);
	            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	            req.send(data);
	        }
	    }
	}
	
	function processReqChange() {
	    // only if req shows 'loaded'
	    if (req.readyState == 4) {
	        // only if 'OK'
	        if (req.status == 200) {
	            eval(returnFunc);
	        } else {
	            alert('There was a problem retrieving the XML data: ' +
	                req.responseText);
	        }
	    }
	}


//CALL DO-ACTION
function DoAction(formName, formAction, params) {	
			
		document.forms[formName].Action.value = formAction;
		document.forms[formName].Params.value = params;
		document.forms[formName].submit(); 
	         
}


	
//INSERT HTML FROM - AJAX		
//-------------------------------------------------------------------	
function InsertAjaxHTML(Container, Details){
	var Container = document.getElementById(Container);
	Container.innerHTML = Details;		
}				

	


function GetTemplateImages( Folder, Variable, UserID, StockOnly) {
	
	url = "http://www.napublishers.com/js/includes/AjaxFuncs.php";	
	returnFunc = "ShowFieldEditor(req.responseText, 'Image')";

	DoCallback("Action=GetTemplateImages&Folder=" + Folder + "&Variable=" + Variable + "&UserID=" + UserID + "&StockOnly=" + StockOnly );
}




function EditTemplateText(Variable,LinkTo, Format) {
	if( Format == undefined ) Format ="HTML";	
	content = document.getElementById(Variable + "_Content").innerHTML;	
	html = "<textarea rows=\"24\" cols=\"60\" name=\"" + Variable + "\" id=\"" + Variable + "\">" + content + "</textarea>";	
	if( Format == "Text"){
		html = str_replace("<BR>", "\n", html);
	}		
	html += "<center><input type=\"submit\" name=\"submit\" value=\"Save\" /></center>";
	ShowFieldEditor(html,'Text');
	if( Format != "Text")
		areaedit_init();
}








function ShowFieldEditor(FieldDetails, BG) {
	document.getElementById("FieldEditor").style.display = "block";
	document.getElementById("FieldEditor").className = BG + "Gallery";
	if( FieldDetails != "" && FieldDetails != undefined ) {
		InsertAjaxHTML('FieldEditorContent', FieldDetails)
	}
}


function HideFieldEditor() {
	document.getElementById("FieldEditor").style.display = "none";
	//window.location.reload();
}

function BlankFunc() {

}

function ClickCount(LinkName,PageName,UserID) {
	url = "http://www.napublishers.com/js/includes/AjaxFuncs.php";	
	returnFunc = "BlankFunc()";
	

	DoCallback("Action=CountClicks&Link="+LinkName+ "&Page=" + PageName + "&UserID=" + UserID );
	
	//alert("&Link="+LinkName+ "&Page=" + PageName + "&UserID=" + UserID);
	//return false;
}

