function wysid (iets) {
//	alert ("\ninnertHTML="+iets.innerHTML+"\nid="+iets.id+"\nvalue="+iets.value);
	//alert ("hallo")
}
//-- ajax from dynamicdrive.com  
//	gets included in header if signalled from prof.php to do so
//Step 2: Define a "callback" function to process the data returned by the Ajax request:

//http://www.htmlgoodies.com/primers/jsp/article.php/359462
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt") {
	
	var matrix = new Array();
	if (myajax.responseText.indexOf('\t\n|')>0) matrix = myajax.responseText.split('\t\n|')
	else {
		matrix = myajax.responseText.split('\t\n');
//		alert("\n0=>"+matrix[0]+"\n1=>"+matrix[1]+"\n2=>"+matrix[2]+"\n3=>"+matrix[3] +"\n4=>"+matrix[4]  +"\n5=>"+matrix[5]+"\n6=>"+matrix[6]+"\n7=>"+matrix[7]+"\n8=>"+matrix[8])
	}

	if (matrix[0]=='usepic') {
		var ajaxDisplay = document.getElementById('dvdimage'); 
		ajaxDisplay.setAttribute("src", matrix[1]); 
		//feedback1=document.getElementById("changepicused");
		//feedback1.innerHTML="<span style=\"color:#FFFFFF\">"+matrix[3]+"</span>"
	}


	else if (matrix[0]=='deletefile') {
		feedback=document.getElementById("photofeedback");
		feedback.innerHTML=matrix[1]

			}

	else if (matrix[0]=='picwords') {
		var feedback = document.getElementById('photofeedback'); 
		feedback.innerHTML=matrix[1]
	}


	else if (matrix[0]=='setconfig') {
		var target1=document.getElementById(matrix[2])
		target1.value=matrix[3]

	} //setconfig

	else if (matrix[0]=='builddir') {
		var target1=document.getElementById("dirstrip")
		target1.innerHTML=matrix[1]

	} //setconfig

	else 	if (matrix[0]=="login") { 
		var ajaxDisplay1 = document.getElementById('loginfeedback'); 
		ajaxDisplay1.innerHTML = matrix[1]; //feedback
		//var ajaxDisplay2 = document.getElementById('loginfullname'); 	
		//ajaxDisplay2.innerHTML = matrix[2]; //fullname
		if (matrix[3]=='admin') {
			var ajaxDisplay3 = document.getElementById('sendlogin'); 
			//alert(ajaxDisplay3.innerHTML)
			ajaxDisplay3.innerHTML="";	
			//alert(ajaxDisplay3.innerHTML)
		}
	}

	else if (matrix[0]=='buildtitles') {
		var target1=document.getElementById("titlecol")
		target1.innerHTML=matrix[3]+matrix[4]+matrix[5]+matrix[1]+matrix[4]+matrix[6]//+matrix[2]
		scrollTo(0,200)
		//(matrix[2])==debugfeedback  
		// 		[3] == listing (unused)
		// 		[4] == dirlist
		// 		[5] == feedback
		//matrix[6] sasbiggest.htm"

	} 

	else if (matrix[0]=='listall') {
		var target1=document.getElementById("titlecol")
		target1.innerHTML=matrix[3]+matrix[4]+matrix[5]+matrix[1]//+matrix[2]+"==== "
		//(matrix[2])==debugfeedback  [4] = dirlist
		/*
		echo "\t\n";
		echo $debugfeedback."\t\n";
		echo $listing."\t\n";
		echo $feedback.$debugfeedback."\t\n";
		*/


	} //listall

	else if (matrix[0]=='expandlist') {
//	alert("\n0=>"+matrix[0]+"\n1=>"+matrix[1]+"\n2=>"+matrix[2]+"\n3=>"+matrix[3]) 
//+"\n4=>"+matrix[4]  +"\n5=>"+matrix[5]+"\n6=>"+matrix[6]+"\n7=>"+matrix[7]+"\n8=>"+matrix[8])

		var target1=document.getElementById("listall_"+matrix[1])
		target1.innerHTML=matrix[4]+matrix[3]
		
		/*
		1echo $_POST['title']."\t\n";
		2echo "<div style=\"color:#FFFFFF\">".$debugfeedback."</div>\t\n";
		3echo $feedback."\t\n";
		4echo $listing."\t\n";
		*/
	} //expandlist



	else if (matrix[0]=='updatestockstatus') {
//	alert("\n0=>"+matrix[0]+"\n1=>"+matrix[1]+"\n2=>"+matrix[2]+"\n3=>"+matrix[3]) 
//+"\n4=>"+matrix[4]  +"\n5=>"+matrix[5]+"\n6=>"+matrix[6]+"\n7=>"+matrix[7]+"\n8=>"+matrix[8])
		var target1=document.getElementById("ussfb_"+matrix[4])
		target1.innerHTML=matrix[2]//+matrix[1]
		
		/*
echo "<div style=\"color:#FFFFFF\">".$debugfeedback."</div>\t\n";
echo $feedback."\t\n";
echo $_POST['newval']."\t\n";
echo $_POST['title_id']."\t\n";
		*/
	} //updatestockstatus

/*	else if (matrix[0]=='fullpic') {
//		alert("\n0=>"+matrix[0]+"\n1=>"+matrix[1]+"\n2=>"+matrix[2]+"\n3=>"+matrix[3]) 
		var teikenprent=document.getElementById("img_"+matrix[1])
		teikenprent.setAttribute("src",matrix[2])
		var targetsmallpic=document.getElementById("smallpic"+matrix[1])
		targetsmallpic.innerHTML="click to reduce"
	} //fullpic
*/

	else if (matrix[0]=='fullpic') {
//		alert("\n0=>"+matrix[0]+"\n1=>"+matrix[1]+"\n2=>"+matrix[2]+"\n3=>"+matrix[3]) 
		var target1=document.getElementById("pix"+matrix[1])
		target1.innerHTML=matrix[2]//+matrix[1]
//		var targetsmallpic=document.getElementById("smallpic"+matrix[1])
//		targetsmallpic.innerHTML="click <b>here</b> to reduce"
	} //fullpic

	else { //retrieving plain html ?
//		alert("plain html")
		var ajaxDisplay = document.getElementById('titlecol');
		ajaxDisplay.innerHTML = myajax.responseText
	}


    }  //myfiletype=txt
else
alert(myajax.responseXML)
} // //req successful

} //readystate==4
} //function
//Step 3: Invoke the Ajax routine method to make the desired Ajax request.


/*function DoenAjaxSavePhotoComment(picfile) {
	//alert("savign"+picfile)
	var pcomment = document.getElementById('imgcommenttxta');
	var poststr= "picfilename=" +encodeURI(picfile) + "&comments="+ encodeURI(pcomment.value)
	//alert(poststr)
	ajaxpack.postAjaxRequest("ajax_picwords.php", poststr, processGetPost, "txt")

	}
*/
function DoenAjaxDelPhoto(imagedir,picfile) {
	//alert("savign"+picfile)
	var poststr= "imagedir=" +encodeURI(imagedir) + "&delfilename=" +encodeURI(picfile) 
//	alert(poststr)
	ajaxpack.postAjaxRequest("ajax_delfile.php", poststr, processGetPost, "txt")

	}



function DoenAjaxEditConfig(configfield,callerid,configval) {
	var cfield = document.getElementById(configfield);
	var callid = document.getElementById(configfield);

	var poststr = "configfield=" + encodeURI(configfield) + "&setto=" +  encodeURI(cfield.value)
	callid.value="updating"
//	alert(poststr)
	ajaxpack.postAjaxRequest("ajax_setconfig.php", poststr, processGetPost, "txt")
}

function Ajax_usepic (pic,record) {
	var poststr="pic="+encodeURI(pic) + "&record=" +encodeURI(record)
	//alert(poststr)
	ajaxpack.postAjaxRequest("ajax_usepic.php", poststr, processGetPost, "txt")
}


function DoenAjaxBuilddir (dircols) {
	var term = document.getElementById('buiddirterm');
	if (term.value !="") 
		var poststr="term="+encodeURI(term.value)+"%"
	else  var poststr="term="
	poststr += "&cols="+dircols
//	alert(poststr)
	ajaxpack.postAjaxRequest("ajax_builddir.php", poststr, processGetPost, "txt")

}

function DoenAjaxBuilddirall (dircols) {
	var term = document.getElementById('buiddirterm');
	if (term.value !="") 
		var poststr="term=%"+encodeURI(term.value)+"%"
	else  var poststr="term="
	poststr += "&cols="+dircols
//	alert(poststr)
	ajaxpack.postAjaxRequest("ajax_builddir.php", poststr, processGetPost, "txt")
}

function DoenAjaxBuilddirselective (selectorstring,limitterm,cols) {
	//alert(selectorstring+","+limitterm+","+cols)
	var poststr="term="+encodeURI(selectorstring)+"&limitterm="+encodeURI(limitterm)+"&cols="+encodeURI(cols)  
//	alert(poststr)
	ajaxpack.postAjaxRequest("ajax_builddir.php", poststr, processGetPost, "txt")

}

function DoenAjaxLogin(hierdie) {
        var usn = document.getElementById('ajxusn').value;
	var pwd = document.getElementById('ajxpwd').value;
	var poststr="usn="+usn + "&pwd="+pwd 
	//alert(poststr) 
	ajaxpack.postAjaxRequest("ajax_login.php", poststr, processGetPost, "txt")
}

// function DoenAjaxGetByCategoryLiteral(literalid) {
// 	var poststr="category="+literalid //id of pic, not name of cat, cat gets looked up by pic id
// 	ajaxpack.postAjaxRequest("ajax_buildtitles.php", poststr, processGetPost, "txt")
// 	}
// 
// function DoenAjaxGetByStudioLiteral(literalid) {
// 	var poststr="studio="+literalid //id of pic, not name of cat, cat gets looked up by pic id
// 	ajaxpack.postAjaxRequest("ajax_buildtitles.php", poststr, processGetPost, "txt")
// 	}
// 

//function DoenAjaxGetByStudio(hierdie) {
//function DoenAjaxGetByCategoryStep(hierdie,step) { //specifies limits for batch retrieval
//function DoenAjaxGetByStudioStep(hierdie,step) {
//function DoenAjaxGetByTitleId(title_id) {


function DoenAjaxListall(bywhat) {
	//	alert (bywhat)
	var target1=document.getElementById("titlecol")
	target1.innerHTML="<span class=\"catname\">Loading ...</span>"
	ajaxpack.postAjaxRequest("ajax_listall.php", "bywhat="+bywhat, processGetPost, "txt")
	}

function DoenAjaxExpand(bywhat,cat_studio_title) {
	var poststr="bywhat="+bywhat+"&title="+cat_studio_title
	ajaxpack.postAjaxRequest("ajax_expandlist.php", poststr, processGetPost, "txt")
	}

function DoenAjaxUpdateStockStatus (hierdie) {
	var title_id=hierdie.id
	var selectedvalue=hierdie[hierdie.options.selectedIndex].value
	poststr="title_id="+title_id + "&newval="+selectedvalue
	ajaxpack.postAjaxRequest("ajax_updatestockstatus.php", poststr, processGetPost, "txt")
}


function DoenAjaxFullpic(largepic,smallpic,titleid) { // ACTUALLY : loadthis, is_current:setthistonext,titleide
	var target1=document.getElementById("pix"+titleid)
	target1.innerHTML="Loading ..."
	poststr="loadthis="+largepic + "&dest="+titleid + "&storethis="+smallpic
	ajaxpack.postAjaxRequest("fullpic.php", poststr, processGetPost, "txt")
}

//function DoenAjaxSwappic(loadthis,storethis,titleid,currentwidth) { 



function wysprent(prent,ident) {  //not ajax
	var teikenprent = document.getElementById("img_"+ident)
	teikenprent.setAttribute("src",prent)
	teikenprent.setAttribute("width",150)
	var targetsmallpic=document.getElementById("smallpic"+ident)
	targetsmallpic.innerHTML="click <b>picture</b> to enlarge"
}

function DoenAjax_getspecial(hierdie){
	var target1=document.getElementById("titlecol")
	target1.innerHTML = "<span style=\"text-align:center\">Loading ..</span>"
  	if (hierdie.id=="img131") var poststr="specials.htm"
  	if (hierdie.id=="img122") var poststr="../gaysite/specials.htm"
	ajaxpack.getAjaxRequest(poststr, "", processGetPost, "txt")
}

//function DoAjax_search(obj,step) { // navstrip wants to put a this as first parameter

