var timer = null;

// this function replaces the contents of a DIV with the contents of a specified page

function updateDiv(div_name, url) {

var url = '/' + url;
var aj = new Ajax.Updater( {success: div_name}, url, { method: 'get', evalScripts: true });

} // end update details function


function getDIV(ref) {

	ok=0; // it's just to start the loop, we don't use it to get out.
	while (!ok) {
		ref = ref.parentNode;
if (String(ref.nodeName)=="DIV") { alert("Found DIV: " + ref.name); return ref; }
			if (String(ref.nodeName)=="BODY") { alert('nothing found'); }
	}

} // end if


function bio_update(form_source, form_target) {
if (timer) { var x = clearTimeout(timer); }
timer = setTimeout("getBio(\"" + form_source + "\", \"" + form_target + "\")", 500);
} // end function bio_update

function getBio(form_source, form_target) {
new Ajax.Updater(form_target, '/xml/getbio.php?author='+$F(form_source), { method: 'get' });
} // end function


function updateAssetSidebar() {
var prism_target = "asset_result";
var url = "asset_parse.php?keyword="+$F("aj_keyword")+"&creator="+$F("aj_creator")+"&filter="+$F("aj_filter")+"&limit="+$F("aj_limit")+"&thumbsize="+$F("aj_thumbsize")+"&fullsize="+$F("aj_fullsize");
var aj = new Ajax.Updater({success: prism_target}, url, { method: "get", evalScripts: true } );
} // end function


function mhHover(tbl, idx, cls)
{
	var t = document.getElementById(tbl);
	if (t == null) return;
	var d = t.getElementsByTagName("TD");
	if (d == null) return;
	if (d.length <= idx) return;
	d[idx].className = cls;
}

function openimage1(imageName,iWidth,iHeight) {
var features = 'width=' + iWidth + ',height=' + iHeight + ',resizable=yes,fullscreen=no,status=no,toolbar=no,scrollbars=auto';
pressWin = window.open(imageName,'imageView',features);
}

function openWindow(url, windowname, iWidth,iHeight) {
var features = 'width=' + iWidth + ',height=' + iHeight + ',resizable=yes,fullscreen=no,status=no,toolbar=no,scrollbars=auto';
pressWin = window.open(url, windowname, features);
}

/* ajax.Request */
function ajaxRequest(url,data) {
  var aj = new Ajax.Request(
  url, {
   method:'get',
   parameters: data,
   onComplete: getResponse
   }
  );
}

/* ajax.Response */
function getResponse(oReq) {
$('result').innerHTML = oReq.responseText;
}

function creator_search(){
if (timer) { var x = clearTimeout(timer); }
timer = setTimeout("creator_research('creator_results')",500);
} // end function cb_update


function adultCheck() {

var adultAgree = confirm("By viewing adult profiles on our site you agree to the following terms:\n\nI am at least 18 years old and of legal age in my area.\n\nI am accessing this site of my own free will and for my own personal entertainment only. \n\nI am not violating any law of my city, town, state, province or nation by accessing this website. \n\nEach time I enter this site, I release, indemnify and hold harmless the providers, owners, and creators of this site from any and all liability arising from my use of this site. \n\nI understand this site contains material that may be considered objectionable; \n\nI will not pass any information contained herein to Minors or to anyone who would find such images offensive. \n\nBy continuing past this point, I affirm, under penalty of perjury that I am not acting as an agent or attorney for any other person, including any government, governmental agency or branch, law enforcement agency, or military agency or branch.");

if (adultAgree) { document.thisForm.adultChecker.value='present'; }

return adultAgree;

} // end adultCheck function


function creator_research() {

// an extra line
var creator_print = $F('creator_print');
var creator_web = $F('creator_web');
var creator_industry = $F('creator_industry');
var creator_keyword = $F('creator_keyword');
var creator_living = $F('creator_living');
var creator_deceased = $F('creator_deceased');
var creator_newtalent = $F('creator_newtalent');
var creator_adult = $F('creator_adult');
var creator_erotica = $F('creator_erotica');
if (creator_keyword == 'Enter Keyword') { creator_keyword = ""; }
var url = 'http://prismcomics.org/creator_search.php?creator_print='+creator_print+'&creator_web='+creator_web+'&creator_industry='+creator_industry+'&creator_keyword='+creator_keyword+'&creator_living='+creator_living+'&creator_deceased='+creator_deceased+'&creator_newtalent='+creator_newtalent+'&creator_erotica='+creator_erotica+'&creator_adult='+creator_adult;
// an extra line
var aj = new Ajax.Updater("creator_results", url, { method: 'get' , evalScripts: true });
} // end creator research function



function div_update(div_name, source_url) {
var aj = new Ajax.Updater(div_name, source_url, { method: 'get' });
} // end update div function


function count_words(textbox, limit, strict) {
var textbox_target = document.getElementById(textbox + '_COUNT');

var textcolor = "#009900";
var limittext = "";
if (limit > 0) { limittext = "/"+limit; }

var y=$F(textbox);
var r = 0;
a=y.replace(/\s/g,' ');
a=a.split(' ');
for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}

if (limit > 0 && (r > limit + 10 || r < limit - 10) && strict) { textcolor = "#FF0000"; }
if (limit > 0 && (r < limit) && !strict) { textcolor = "#FF0000"; }

if (textcolor == "#FF0000") { fontweight = "bold"; } else { fontweight = "normal"; }

textbox_target.innerHTML="<span class='fineprint' style='font-weight: "+fontweight+"; color:"+textcolor+"'>"+r+limittext+" words</span>";
} // end function
