function GEBI(X){
	return document.getElementById(X);
}
Shut=new Array(0,0,0,0,0,0,0);
function iSect(vart){
	if (vart.indexOf("isect")==-1 || Shut[vart.substring(5,6)-1]==0){
		lennen=GEBI(vart+"b").innerHTML;
		if (vart=="isect2" && lennen.toLowerCase().indexOf('.rar">this link</a>.')!=-1){
			GEBI(vart+"b").innerHTML=tString+lennen;
		}
		lennen=lennen.length;
		GEBI(vart).innerHTML+=' <i>('+((lennen<1000)?lennen+' B':Math.round((lennen/1024)*100)/100+' KiB')+')</i>';
		if (lennen>=1024 && vart.indexOf("as")==0){
			GEBI(vart).innerHTML+='<s> &#9679;'+((lennen>=5120)?'<s> &#9679;'+((lennen>=15360)?'<s> &#9679;'+((lennen>=30720)?'<s> &#9679;</s>':'')+'</s>':'')+'</s>':'')+'</s>';
		}
		GEBI(vart).onmousedown=function(){changeDis(this.id+"b");}
		GEBI(vart+"b").style.display="none";
		if (vart.indexOf("isect")!=-1){
			Shut[vart.substring(5,6)-1]=1;
		}
	}
}
function changeDis(vartda){
	disP=GEBI(vartda).style;
	if (disP.display==''){
		disP.display='none';
	}else{
		disP.display='';
	}
}
Switch=0;
Switch2=0;
tString='<br><span id="expcolall" onclick="toolset(0);">[Tools]</span><br><span id="toolarea"></span>';
function aScript(antal){
	GEBI("isect2b").innerHTML=tString+'<br><span id="expcolall" onclick="expcol();">[Expand/Collapse All]</span>'+GEBI("isect2b").innerHTML;
	for (i=1;i<=antal;i++){
		iSect("as"+i);
	}
	anta=antal;
}
function expcol(){
	if (Switch==0){
		dissen='';
		Switch=1;
	}else{
		dissen='none';
		Switch=0;
	}
	for (i=1;i<=anta;i++){
		GEBI("as"+i+"b").style.display=dissen;
	}
}
function infoconfirm(){
	if (GEBI("isect2b")==null || GEBI("isect2b").innerHTML.length<=512000){
		return true;
	}else{
		return confirm('This info page is pretty big, do you still want\nthe ActionScript blocks to be collapsed?\n\nOK = Collapse elements, might take a while\n(your browser may freeze temporarily)\n\nCancel = Skip collapse this time\n(the AS tools will be unavailable)');
	}
}
function Sel(vad){
	setTimeout("GEBI('"+((vad==1)?'cap':'wfil')+"').select();",200);
}
flashLaddas=true;
function controls(flashbredd,flashhojd){
	bredd=flashbredd;
	hojd=flashhojd;
	origbredd=flashbredd;
	orighojd=flashhojd;
	obj=window.document.emfl;
	bdy=document.body;
	doit=0;
	bdy.onmouseup=function(){doit=0;}
	bdy.onkeydown=function(){doit=0;}
	zoomLower=new Array(flashbredd,flashhojd);
	document.write('<br><div id="ctrls">'+makeLink2(-3,'Turn the flash off','[OFF]')+' | '+makeLink(1,'Thinner')+' '+makeLink(2,'Wider')+' '+makeLink(3,'Shorter')+' '+makeLink(4,'Taller')+' | '+makeLink(5,'Smaller')+' '+makeLink(6,'Bigger')+' | '+makeLink2(-1,'Make the flash '+flashbredd+'x'+flashhojd,'Reset')+' '+makeLink2(-2,'Make the flash fit the window','Fit')+'<br>');
	document.write('<table cellspacing="0"><tr><td id="percentLoaded">-</td><td id="flashTools">Quality Scale Inspect Zoom Maximize Seekbar</td></tr></table><div id="zoomArea"></div><div id="inspectArea"></div></div>');
	GEBI("zoomArea").style.display='none';
	GEBI("inspectArea").style.display='none';
	if (flashLaddas) {
		visaLaddat();
	}
}
function makeLink(typ,lank){
	return '<a href="swfchan://# Make flash '+lank.toLowerCase()+'" onmousedown="resizeFlash('+typ+');" onclick="return false;">'+lank+'</a>';
}
function makeLink2(typ,desc,lank){
	return '<a href="swfchan://# '+desc+'" onclick="resizeFlash('+typ+');return false;"'+(typ==-3?' id="nodec"':'')+'>'+lank+'</a>';
}
function appl(){
	obj.width=Math.round(bredd);
	obj.height=Math.round(hojd);
}
function DoLoop(){
	if (doit==1){
		breddtmp=bredd;
		hojdtmp=hojd;
		if (thetask==1 || thetask==5){
			bredd-=stageB;
		}else if (thetask==2 || thetask==6){
			bredd+=stageB;
		}
		if (thetask==3 || thetask==5){
			hojd-=stageH;
		}else if (thetask==4 || thetask==6){
			hojd+=stageH;
		}
		if (stageB<32 && stageH<32){
			stageB*=2;
			stageH*=2;
		}
		if (bredd<2 || hojd<2){
			bredd=breddtmp;
			hojd=hojdtmp;
		}
		appl();
		setTimeout("DoLoop();",50);
	}
}
function resizeFlash(task){
	if (task>0){
		if (task<=4){
			stageB=2;
			stageH=2;
		}else{
			if (bredd>hojd){
				stageB=2;
				stageH=2*(hojd/bredd);
			}else{
				stageB=2*(bredd/hojd);
				stageH=2;
			}
		}
		doit=1;
		thetask=task;
		DoLoop();
	}else{
		if (task==-3){
			GEBI("embd").innerHTML="&#160; - &#160;";
			BLANK("ctrls");
			GEBI("ctrls").style.display='none';
		}else if (task==-4){
			GEBI("rprefs").style.display=GEBI("rprefs").style.display!='block'?'block':'none';
		}else if (task==-1){
			bredd=origbredd;
			hojd=orighojd;
			appl();
		}else if (task==-2){
			for (i=0;i<2;i++){
				stageB=bdy.clientWidth-12;
				stageH=bdy.clientHeight-12-(seekbar?40:0);
				if (stageB>stageH){
					bredd*=(stageH/hojd);
					hojd=stageH;
				}else{
					hojd*=(stageB/bredd);
					bredd=stageB;
				}
				do{
					OK=0;
					if (bredd>stageB){
						OK=1
						hojd*=(stageB/bredd);
						bredd=stageB;
					}else if (hojd>stageH){
						OK=1
						bredd*=(stageH/hojd);
						hojd=stageH;
					}
				}while(OK==1);
				appl();
			}
			window.scrollTo(GEBI("embd").offsetParent.offsetLeft-(stageB-bredd)/2, GEBI("embd").offsetParent.offsetTop-(stageH-hojd)/2);
		}
	}
}
function toolset(dowhat){
	if (dowhat==1){
		parts=GEBI("uniraw").value.split("\\u");
		parts.shift();  // Trim the first element.
		codes=[];
		for (i=0;i<parts.length;++i){
			BreaK=parts[i].indexOf("\n")!=-1;
			SpacE=parts[i].length>4;
			code=parseInt(parts[i].substring(0,4),16);
			if (code>=0 && code<65536){
				codes.push(code);
				if (BreaK){
					codes.push("_");
				}else if (SpacE){
					codes.push(" ");
				}
			}
		}
		unescaped='';
		for (i=0;i<codes.length;++i){
			if (codes[i]==" "){
				unescaped+=" ";
			}else if (codes[i]=="_"){
				unescaped+="<br>";
			}else{
				unescaped+=String.fromCharCode(codes[i]);
			}
		}
		GEBI("uniok").innerHTML='<big>TRANSLATED:</big><br><br>'+unescaped;
	}else{
		if (Switch2==0){
			GEBI("toolarea").innerHTML='<table><tr><td><fieldset><legend>UNICODE TRANSLATOR</legend><table><tr><td><small>This is used for translating unicode commands from the script into readable (and probably Asian) characters.<br><br>Example: Enter "\\uFF77\\uFF80" and press the button.<br><br>You may want to just copy and paste large chunks of code, that\'s ok since only the translated commands will show up.</small></td></tr><tr><td><table><tr><td><textarea id="uniraw"></textarea></td><td><input type="button" id="unibut" value="&gt;" onclick="toolset(1);"></td></tr></table></td></tr></table></fieldset></td><td id="uniok"></td></tr></table>';
			Switch2=1;
		}else{
			BLANK("toolarea");
			Switch2=0;
		}
	}
}
function GetNo(idno){
	No=Math.floor(idno/5000);
	return (No!=idno/5000)?++No:No;
}
tries=0;
window.onload=function(){tries=-9;}
function ChangePage(){
	tries++;
	below=GEBI("below0")==null?GEBI("below-1"):GEBI("below0");
	if (GEBI("isec")!=null){
		for (i=1;i<=7;i++){
			if (GEBI("isect"+i)!=null){
				iSect("isect"+i);
			}
		}
		tries=-1;
	}else if (below!=null){
		below.innerHTML='&#160;<hr><small><small>Translate this page: <a href="http://translate.google.com/" target="_blank">GT</a>/<a href="http://babelfish.yahoo.com/" target="_blank">BF</a>. Shortcuts (translates from): <a href="http://translate.google.com/translate_p?hl=en&sl=ru&tl=en&u='+ encodeURI(document.location.href)+'">Rus (GT)</a>/<a href="http://babelfish.yahoo.com/translate_url_load?lp=ru_en&trurl='+ encodeURI(document.location.href)+'">Rus (BF)</a>, <a href="http://translate.google.com/translate_p?hl=en&sl=ja&tl=en&u='+ encodeURI(document.location.href)+'">Jap (GT)</a>/<a href="http://babelfish.yahoo.com/translate_url_load?lp=ja_en&trurl='+ encodeURI(document.location.href)+'">Jap (BF)</a>.<br></small></small>';
		tries=-1;
	}else{
		sect1=GEBI("sect1");
		sect3=GEBI("sect3");
		if (sect1!=null && sect3!=null && GEBI("sect4")!=null){
			sect1=sect1.innerHTML.substring(0,sect1.innerHTML.toLowerCase().indexOf("</b>"));
			sect1=Math.round(sect1.substring(sect1.indexOf("#")+1,999666000));
			sect3ih=sect3.innerHTML;
			if (sect1<19692){
				sect3ih=sect3ih.substring(0,sect3ih.indexOf("First seen: "))+'First seen: Before 12/5 -2008<br>'+sect3ih.substring(sect3ih.indexOf("Last seen: "),999666000);
			}
			if (GEBI("wli")==null){
				sect3ih+='<br><br><small>[<a href="http://swfchan.net/'+GetNo(sect1)+'/'+sect1+'.shtml" id="wli">Wiki page at swfchan.net</a>]</small>';
			}
			sect3.innerHTML=sect3ih;
			tries=-1;
		}
	}
	if (tries>0){
		setTimeout("ChangePage();",tries*25);
	}
}ChangePage();
alphab="0987654321abcdefghijklmnopqrstuvwxyz";
dte=new Date();
function FIX(grupp){
	for(i=1;i<=3;i++){
		ObJ=GEBI("d"+grupp+"-"+i);
		tid=(""+ObJ.onreset+"");
		tid=1*tid.substring(tid.indexOf("q")+1,tid.indexOf(";"));
		da = servGlobTimeHrs+(dte.getMinutes()*60+dte.getSeconds());
		if (da>=tid) {
			tid=da-tid;
		} else {
			tid=da+3600-tid;
		}
		if (i==3 && tid<32400){
			if (GEBI("amight")!=null){
				GEBI("amight").innerHTML="(might still be open)";
			}else if (GEBI("a"+grupp)!=null){
				GEBI("a"+grupp).innerHTML+="?";
			}
		}
		if (i==2 && tid>72000){
			if (GEBI("bmight")!=null){
				GEBI("bmight").innerHTML="(might be closed)";
			}else if (GEBI("b"+grupp)!=null){
				GEBI("b"+grupp).innerHTML+="?";
			}
		}
		if (tid<60){
			if (tid<1){
				tid='~0 sec';
			}else{
				tid=tid +' sec';
			}
		}else if (tid<3600){
			tid=Math.floor(tid/6)/10 +' min';
		}else if (tid<86400){
			tid=Math.floor(tid/360)/10 +' hrs';
		}else if (tid<3456000) {
			tid=Math.floor(tid/8640)/10 +' days';
		}else if (tid<30758400) {
			tid=Math.floor(tid/345600)/10 +' months';
		}else{
			tid=Math.floor(tid/3075840)/10 +' years';
		}
		if (ObJ.innerHTML.toLowerCase().indexOf('<br>')!=-1){
			ObJ.innerHTML=ObJ.innerHTML.toLowerCase().replace(/<br>/g,"")+'<br>'+'<i>'+tid+' ago.<br></i><br>';
		}else{
			ObJ.title=ObJ.innerHTML.substring(3,999666000);
			ObJ.innerHTML=Array("Discovered","Updated","Checked")[i-1]+': <i>'+tid+' ago.</i>';
		}
	}
}
function randomPreview(flashSize,screenPath,sizeLimit,embedString,hhh,www,zxxy){
	rndPrevEmbd=embedString;
	document.write('<div id="hidemb" style="display:none;">');
	flashLaddas=false;
	controls(hhh,www);
	document.write('</div><div id="shoemb"><table width="800"><tr><td width="400" align="center"><img src="'+screenPath+'"></td><td id="rr"><b>This flash has a file size larger than<br>'+sizeLimit+' so it is not automatically loaded.</b><br><br><small><small>(You can set your preferences at the bottom of the page.)<br></small></small><br><table width="100%" height="300"><tr><td id="preclicka" onclick="GEBI(\'hidemb\').style.display=\'block\';GEBI(\'hidemb\').innerHTML=rndPrevEmbd+GEBI(\'hidemb\').innerHTML+categorizeTable(\''+zxxy+'\');obj=GEBI(\'emfl\');GEBI(\'shoemb\').style.display=\'none\';visaLaddat();"><i>Click in this area to load the flash.<br><small>('+flashSize+')</small></i></td></tr></table><br>Link timeout: ');
	LinkTimeout('lto',1);
	document.write('</td></tr></table></div>');

}
function LinkTimeout(namn,intervall){
	document.write('<span id="'+namn+'clr"><span id="'+namn+'">'+(45+intervall)+'</span></span>');
	LinkTimeoutCnt(namn,intervall);
}
function LinkTimeoutCnt(namn,intervall){
	if (intervall==1){
		GEBI(namn).innerHTML=Math.round(GEBI(namn).innerHTML)-intervall;
		GEBI(namn+'clr').innerHTML='<span id="linkstatus'+(Math.round(GEBI(namn).innerHTML)>0?1:(Math.round(GEBI(namn).innerHTML)>-60)?2:3)+'"><span id="'+namn+'">'+GEBI(namn).innerHTML+'</span></span>';
	}else{
		GEBI(namn+'clr').innerHTML='(<span id="'+namn+'">'+(Math.round(GEBI(namn).innerHTML)-intervall)+'</span>)';
	}
	setTimeout("LinkTimeoutCnt('"+namn+"',"+intervall+");",intervall*1000);
}
function randomPrefs(action,directlink,remember){
	if (action<0){
		document.write('<div id="ctrls">'+makeLink2(-4,"Show/hide settings","Preferences")+'<br><br><div id="rprefs" style="display:none;"><fieldset>');
		document.write('<small>Changing these requires cookies.<i id="tobesaved"></i></small><br><br><b>Don\'t auto load flashes larger than:</b><br><br>');
		document.write(makeRadio('rprev',1,'1 KiB',action==-1)+makeRadio('rprev',2,'0.5 MiB',action==-2)+makeRadio('rprev',3,'1 MiB',action==-3)+makeRadio('rprev',4,'1.5 MiB',action==-4)+makeRadio('rprev',5,'2 MiB',action==-5)+makeRadio('rprev',6,'2.5 MiB',action==-6)+makeRadio('rprev',7,'3 MiB',action==-7)+'<br>'+makeRadio('rprev',8,'4 MiB',action==-8)+makeRadio('rprev',9,'5 MiB',action==-9)+makeRadio('rprev',10,'6 MiB',action==-10)+makeRadio('rprev',11,'7 MiB',action==-11)+makeRadio('rprev',12,'8 MiB',action==-12)+makeRadio('rprev',13,'9 MiB',action==-13)+makeRadio('rprev',14,'10 MiB',action==-14));
		document.write('<br><br><b>Show direct link below the flash:</b><br><br>'+makeRadio('rdili',15,'Yes',directlink==1)+makeRadio('rdili',16,'No',directlink==0));
		document.write('<br><br><b>Remember last 10 pulled flashes:</b><br><br>'+makeRadio('rreme',17,'Yes',remember==1)+makeRadio('rreme',18,'No',remember==0));
		document.write('</fieldset></div></div>');
	}else{
		if (action<17){
			(action<=14?GEBI("previewat"):GEBI("showlink")).value=action;
		}else{
			GEBI("rememb").value=action;
		}
		GEBI("tobesaved").innerHTML='&#160;Press the "GET RANDOM"-button to save.';
	}
}
function makeRadio(name,actionId,desc,isselected){
	rndId=Math.random();
	if (isselected){
		setTimeout("GEBI('previewat').value='';GEBI('showlink').value='';GEBI('r"+rndId+"').checked='true';",500);
	}
	return '<input type="radio" name="'+name+'" onclick="randomPrefs('+actionId+',-1,-1);" id="r'+rndId+'"'+(isselected?' checked':'')+'> <label for="r'+rndId+'">'+desc+'</label> ';
}

showingTools = false;
currentScale = "";
currentQuality = "";
HH1="7 18 15 27 10 22 14 8 32 18 13 29 17 ";
inspected = new Array();
inspectedVal = new Array();
inspecting = false;
inspectFreq = 500;
isFullscreen = false;
seekbar = false;
seeking = false;
seekbarSetup = false;
flashCurrentFrame = 1;
flashTotalFrames = 1;
flashLoadedFrames = 0;
seekFreq = 40;
goForth = 999999;
goBack = 999999;
seekPosition = false;
musX = -999999;
musY = -999999;
HH1+="0 4 1 1 4 8 17 14 18 16 17 29 0 4 1 ";
isIE = navigator.appName.indexOf("Microsoft")!=-1?true:false;
overSeekerID = 0;
zoomUpper = new Array(0,0);
zoomLower = new Array(1,1);
zooming = 0;
zoomID = 0;
zoomLevel = 1;
zoomPan = new Array(0,0);

function visaLaddat(){
	laddat=0;
	pl=typeof(obj.PercentLoaded);
	if (pl!="undefined") {
		pl=typeof(obj.PercentLoaded());
		if (pl=="number") {
			laddat=obj.PercentLoaded();
			GEBI("percentLoaded").innerHTML=Math.round(laddat)+"%";
			showFlashTools();
		}
	}
	if (laddat!=100) {
		setTimeout('visaLaddat();',100);
	}
}

function showFlashTools(){
	if (!showingTools) {
		showingTools=true;
		GEBI("flashTools").innerHTML = '<a href="swfchan://# Toggle flash\'s quality (high/medium/low/best)" onClick="toggleQuality();return false;">Quality</a> <a href="swfchan://# Toggle flash\'s scale mode (showAll/noScale/exactFit/noBorder)" onClick="toggleScale();return false;">Scale</a> <a href="swfchan://# Get or set the value of a variable in the flash" onClick="if (GEBI(\'inspectNewVariable\')!=null && inspected.length==0 && inspecting==false){doInspect();}else{inspectRedraw();GEBI(\'inspectNewVariable\').select();}return false;">Inspect</a> <a href="swfchan://# Allows you to zoom in the flash" onClick="zoomTools();return false;">Zoom</a> <a href="swfchan://# Attempts to show the flash in as high resolution as possible (sets scale to \'exactFit\')" onClick="maximize();return false;">Maximize</a> <a href="swfchan://# Show or hide the seek bar below the flash" onClick="try{toggleSeekbar();}catch(err){}return false;">Seekbar</a>';
	}
}

function toggleScale(){
	if (currentScale=="" && 1==0) {
		try{
			if (typeof(obj.GetVariable("Stage.scaleMode"))=="string") {
				currentScale=obj.GetVariable("Stage.scaleMode");
			}
		}catch(err){}
		if (currentScale!="showAll" && currentScale!="noScale" && currentScale!="exactFit" && currentScale!="noBorder") {
			currentScale="showAll";
		}
	}
	switch(currentScale) {
	case "showAll":
		currentScale="noScale";
		break;    
	case "noScale":
		currentScale="exactFit";
		break;
	case "exactFit":
		currentScale="noBorder";
		break;
	default:
		currentScale="showAll";
	}
	setScale(currentScale);
}

function setScale(skalan){
	try{
		obj.SetVariable("Stage.scaleMode",skalan);
	}catch(err){}
}

function addInspect(){
	inv = GEBI("inspectNewVariable");
	varname = ''+inv.value;
	inv.value = '';

	if (varname!=''){

		inspected.push(varname);
		inspectedVal.push("08641ItsNuLLYo");
		inspectRedraw();
		if (!inspecting){
			inspecting=true;
			doInspect();
		}
	}else if (inspected.length==0){
		doInspect();
	}
}

function forDispl(detta){
	return (''+detta).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/ /g,'&#160;');
}

function inspectAddGetSetLink(nr){
	GEBI('inspSetArea'+nr).innerHTML=inspectGetSetLink(nr);
}

function inspectGetSetLink(nr){
	return '<a href="swfchan://# Allows you to set the value of this variable" onClick="inspectGetSetField('+nr+');return false;">get/set</a>';
}

function inspectGetSetField(nr){
	GEBI("inspSetArea"+nr).innerHTML='<input type="text" id="getSetField'+nr+'"><input type="button" value="set" onClick="setInspVarVal('+nr+');"><input type="button" value="hide" onClick="inspectAddGetSetLink('+nr+');">';
	retrieveValueOf(nr);
	GEBI("getSetField"+nr).value=inspectedVal[nr]=='08641ItsNuLLYo'?'':inspectedVal[nr];
	GEBI("getSetField"+nr).select();
}

function inspectRedraw(){
	inspklump='<table cellspacing="0" id="itbl"><tr><td id="inspect" align="center"><small>Type the name of a variable accessible from the root:<br></small><form onSubmit="addInspect();return false;"><input type="text" id="inspectNewVariable" value="'+(GEBI("inspectNewVariable")==null?'':GEBI("inspectNewVariable").value)+'"><input type="submit" value="&gt;" id="add"></form>';
	if (inspected.length>0){
		inspklump+='<table cellspacing="0" id="dfreq"><td id="l">Update frequency:</td><td id="freq">'+inspectFreq+'</td><td id="r"><a href="swfchan://# Update variables more often" onClick="inspectFreq-=50;if (inspectFreq<50){inspectFreq=50;}inspectRedraw();return false;">[-]</a> <a href="swfchan://# Update variables less often" onClick="inspectFreq+=100;inspectRedraw();return false;">[+]</a></td></tr></table>';
		for (i=0;i<inspected.length;i++){
			inspklump += '<table cellspacing="0"><tr><td id="namn">'+forDispl(inspected[i])+':</td><td id="varde"><span id="iVarVal'+i+'">'+displayInspectedVal(i)+'</span></td><td id="manage"><span id="inspSetArea'+i+'">'+inspectGetSetLink(i)+'</span> <a href="swfchan://# Stop inspecting this variable" onClick="removeInspVar('+i+');return false;">[x]</a></td></tr></table>';
		}
	}
	GEBI("inspectArea").innerHTML=inspklump+'</td></tr></table>';
	GEBI("inspectArea").style.display='block';
}
HH1+="1 4 8 28 27 12 0 4 17 29 29 25 5 2 ";
function displayInspectedVal(nr){
	if (inspectedVal[nr]=='08641ItsNuLLYo'){
		return '<i>null</i>';
	}else{
		return (inspectedVal[nr]==''?'<i>blank</i>':forDispl(inspectedVal[nr]));
	}
}

function doInspect(){
	if (inspected.length>0){
		for (i=0;i<inspected.length;i++){
			vardet='';
			retrieveValueOf(i);
			try{
				GEBI("iVarVal"+i).innerHTML=displayInspectedVal(i);
			}catch(err){}
		}
		setTimeout('doInspect();',inspectFreq);
	}else{
		inspecting=false;
		if (GEBI("inspectNewVariable").value==""){
			BLANK("inspectArea");
			GEBI("inspectArea").style.display='none';
		}
	}
}

function retrieveValueOf(nr){
	try{
		vardet=obj.GetVariable(inspected[nr]);
	}catch(err){
		vardet=null;
	}
	if (typeof(vardet)!='string'){
		vardet=null;
	}
	inspectedVal[nr]=typeof(vardet)=='object'?'08641ItsNuLLYo':vardet;
}

function setInspVarVal(nr){
	obj.SetVariable(inspected[nr],GEBI("getSetField"+nr).value);
	inspectAddGetSetLink(nr);
}

function removeInspVar(nr){
	inspected=inspected.slice(0,nr).concat(inspected.slice(nr+1));
	inspectedVal=inspectedVal.slice(0,nr).concat(inspectedVal.slice(nr+1));
	inspectRedraw();
}

function doZoom(theID,theDirection){
	if (theID==zoomID){
		obj.Zoom(100-(theDirection*zoomLevel));
		zoomLevel+=10;
		obj.Pan(zoomPan[0],zoomPan[1],1);
		setTimeout("doZoom("+theID+","+theDirection+");",100);
	}
}

function setZoomRect(){
	raa=GEBI("zrectaa").value;
	rab=GEBI("zrectab").value;
	rba=GEBI("zrectba").value;
	rbb=GEBI("zrectbb").value;
	if (!isNaN(raa) && !isNaN(rab) && !isNaN(rba) && !isNaN(rbb)){
		obj.SetZoomRect(raa*20,rab*20,rba*20,rbb*20);
		zoomUpper=new Array(raa,rab);
		zoomLower=new Array(rba,rbb);
	}
}

function zRect(){
	GEBI("zoom").innerHTML='<table cellspacing="0" id="zrect"><tr><td><form onsubmit="setZoomRect();return false;"><table cellspacing="0"><tr><td></td><td id="info">Upper left<br>corner</td><td></td><td id="info">Lower right<br>corner</td></tr><tr><td>X:</td><td><input type="text" tabindex="1" id="zrectaa" value="'+zoomUpper[0]+'"></td><td>&#160; X:</td><td><input type="text" tabindex="3" id="zrectba" value="'+zoomLower[0]+'"></td></tr><tr><td>Y:</td><td><input type="text" tabindex="2" id="zrectab" value="'+zoomUpper[1]+'"></td><td>&#160; Y:</td><td><input type="text" tabindex="4" id="zrectbb" value="'+zoomLower[1]+'"></td></tr></table><input type="submit" tabindex="5" value="Set Zoom Rectangle" id="btn"></td></tr></table>';
}

function zoomTools(){
	if (GEBI("zoomArea").style.display=='block'){
		GEBI("zoomArea").style.display='none';
	}else{
		GEBI("zoomArea").innerHTML='<table cellspacing="0" id="ztbl"><tr><td id="zoom" align="center"><a href="swfchan://# Increase magnification" onMouseDown="zoomLevel=0;zoomID++;doZoom(zoomID,1);" onMouseUp="zoomID++;showZoomGoal(0.5,0.5);" onMouseOut="zoomID++;" onClick="return false;">Zoom in</a> | <a href="swfchan://# Decrease magnification" onMouseDown="zoomLevel=0;zoomID++;doZoom(zoomID,-5);" onMouseUp="zoomID++;showZoomGoal(0.5,0.5);" onMouseOut="zoomID++;" onClick="return false;">Zoom out</a><br><table cellspacing="0" id="zgarea" onMouseOver="if(musX==-999999){document.onmousemove=getMusX;}" onClick="setZoomGoal();"><tr><td id="zgruler"><table cellspacing="0"><tr><td>&#160;</td></tr></table></td></tr></table><a href="swfchan://# Zoom by setting the zoom rectangle instead" onclick="zRect();return false;">Switch to zoom rectangle</a></td></tr></table>';
		GEBI("zoomArea").style.display='block';
	}
}

function setZoomGoal(){
	zgAREA=GEBI("zgarea");
	zgaLeft=0;
	zgaTop=0;
	if (zgAREA.offsetParent) {
		do {
			zgaLeft += zgAREA.offsetLeft;
			zgaTop += zgAREA.offsetTop;
		} while (zgAREA = zgAREA.offsetParent);
	}
	xled=musX-zgaLeft-(isIE?2:0);
	yled=musY-zgaTop-(isIE?2:0);
	xled=xled<1?1:xled;
	xled=xled>50?50:xled;
	yled=yled<1?1:yled;
	yled=yled>50?50:yled;
	showZoomGoal(xled/50,yled/50);
}

function showZoomGoal(xProcent,yProcent){
	vanster=Math.floor(44*xProcent);
	topp=Math.floor(44*yProcent);
	GEBI("zgruler").style.padding=topp+' '+(44-vanster)+' '+(44-topp)+' '+vanster;
	zoomPan=new Array(200*(xProcent-0.5),200*(yProcent-0.5));
}

function toggleQuality(){
	if (currentQuality=="") {
		try{
			if (typeof(obj.GetVariable("_quality"))=="string") {
				currentQuality=obj.GetVariable("_quality");
			}
		}catch(err){}
		if (currentQuality!="HIGH" && currentQuality!="MEDIUM" && currentQuality!="LOW" && currentQuality!="BEST") {
			currentQuality="HIGH";
		}
	}
	switch(currentQuality) {
	case "HIGH":
		currentQuality="MEDIUM";
		break;    
	case "MEDIUM":
		currentQuality="LOW";
		break;
	case "LOW":
		currentQuality="BEST";
		break;
	default:
		currentQuality="HIGH";
	}
	try{
		obj.SetVariable("_quality",currentQuality);
	}catch(err){}
}

function maximize(){
	if (!isFullscreen){
		gamlaWidth=bdy.clientWidth+24;
		gamlaHeight=bdy.clientHeight+120;
		gamlaX=typeof(window.screenLeft)=='number'?window.screenLeft-4:window.screenX;
		gamlaY=typeof(window.screenTop)=='number'?window.screenTop-83:window.screenY;
		if (gamlaWidth+15<window.screen.availWidth || gamlaHeight+15<window.screen.availHeight){
			window.moveTo(0,0);
			if (gamlaWidth+15<window.screen.availWidth && gamlaHeight+15<window.screen.availHeight){
				window.resizeTo(window.screen.availWidth,window.screen.availHeight);
			}else if (gamlaWidth+15<window.screen.availWidth){
				window.resizeTo(window.screen.availWidth,gamlaHeight);
			}else{
				window.resizeTo(gamlaWidth,window.screen.availHeight);
			}
		}else{
			gamlaWidth=-999;
		}
		gamlaBorderW=embd.style.borderWidth;
		gamlaSBmargintop="";
		if (seekbar){
			gamlaSBmargintop=GEBI("sbbase").style.marginTop;
			GEBI("sbbase").style.marginTop='0px';
		}
		gamlaMargins=bdy.style.margin;
		gamlaCurrentScale=currentScale;
		gamlaBredd=bredd;
		gamlaHojd=hojd;
		embd.style.borderWidth='0px';
		bdy.style.margin='0px';
		for (i=0;i<3;i++){
			bredd=bdy.clientWidth;
			hojd=bdy.clientHeight-(seekbar?34:0);
			appl();
		}
		window.scrollTo(GEBI("embd").offsetParent.offsetLeft, GEBI("embd").offsetParent.offsetTop);
		currentScale="exactFit";
		setScale(currentScale);
		isFullscreen=true;
	}else{
		if (gamlaWidth!=-999){
			window.moveTo(0,0);
			window.resizeTo(gamlaWidth,gamlaHeight);
			window.moveTo(gamlaX,gamlaY);
		}
		embd.style.borderWidth=gamlaBorderW;
		if (seekbar){
			GEBI("sbbase").style.marginTop=gamlaSBmargintop;
		}
		bdy.style.margin=gamlaMargins;
		bredd=gamlaBredd;
		hojd=gamlaHojd;
		appl();
		currentScale=gamlaCurrentScale;
		setScale(currentScale);
		isFullscreen=false;
	}
}

function doSeek(){
	if (seekbar){
		if (!seekbarSetup){
			try{
				flashTotalFrames = obj.GetVariable("_totalframes");
			}catch(err){
				try{
					flashTotalFrames = obj.TotalFrames;
				}catch(err){
					try{
						flashTotalFrames = obj.TotalFrames();
					}catch(err){}
				}
			}
			if (typeof(flashTotalFrames)!='string'){
				flashTotalFrames = obj.TotalFrames();
			}
			flashTotalFrames*=1;
			try{
				flashLoadedFrames = obj.GetVariable("_framesloaded");
			}catch(err){}
			if (typeof(flashLoadedFrames)!='string'){
				try{
					flashLoadedFrames = obj.TGetProperty("/",12);
				}catch(err){}
				if (typeof(flashLoadedFrames)!='string'){
					flashLoadedFrames = Math.floor(flashTotalFrames*(laddat/100));
				}
			}
			flashLoadedFrames*=1;
			laddatProcent=flashLoadedFrames/flashTotalFrames;
			if (laddatProcent==1){
				seekbarSetup = true;
			}
		}
		laddatExakt=(bredd*(laddatProcent));
		GEBI("seektable").style.width=laddatExakt+'px';
		try{
			flashCurrentFrame = obj.GetVariable("_currentframe");
		}catch(err){}
		if (typeof(flashCurrentFrame)!='string'){
			flashCurrentFrame = obj.CurrentFrame()+1;
		}
		flashCurrentFrame*=1;
		if (!seekPosition){
			flyttaPin(flashCurrentFrame);
		}else{
			makeSeek();
		}
		GEBI("seekleft").style.width=vanster+'px';
		GEBI("seekright").style.width=hoger+'px';
		GEBI("seekstatus").innerHTML=(obj.IsPlaying()?'PLAYING':'STOPPED')+' ('+flashCurrentFrame+'/'+flashTotalFrames+')'+(flashLoadedFrames==flashTotalFrames?'':' ['+flashLoadedFrames+']');
		if (goForth<=500){
			goForth-=seekFreq;
			if (goForth<=0){
				flashGoto(flashCurrentFrame+1+Math.floor((goForth/-1000)));
			}
		}
		if (goBack<=500){
			goBack-=seekFreq;
			if (goBack<=0){
				flashGoto(flashCurrentFrame-1-Math.floor((goBack/-1000)));
			}
		}
		setTimeout("doSeek();",seekFreq);
	}else{
		seeking=false;
	}
}

function getMusX(e){
	if (e==undefined){
		musX=event.clientX+document.body.scrollLeft;
		musY=event.clientY+document.body.scrollTop;
	}else{
		musX=e.pageX;
		musY=e.pageY;
	}
}

function makeSeek(){
	slideX=(musX-GEBI('embd').offsetParent.offsetLeft-(GEBI('embd').style.borderWidth==''?6:0))-(isIE?2:0);
	if (slideX>laddatExakt-1){
		slideX=laddatExakt-1;
	}else if (slideX<0){
		slideX=0;
	}
	malet=Math.floor((slideX/bredd)*flashTotalFrames)+1;
	flyttaPin(malet);
	GEBI('seekgoto').value=malet;
}

function stopSeeking(seid){
	if (seid==overSeekerID){
		seekPosition=false;
	}
}

function flyttaPin(nuram){
	vanster=Math.round(((laddatExakt-5)*(Math.round((nuram/flashTotalFrames)*100)/100)));
	hoger=(laddatExakt-5)-vanster;
}

function flashGoto(frameNr){
	if (isNaN(frameNr)){
		spelaEfterFlytt=true;
		try{
			spelaEfterFlytt=obj.IsPlaying();
		}catch(err){}
		tillDenna=GEBI('seekgoto').value;
		if (!isNaN(tillDenna) && tillDenna!=''){
			flashGoto(tillDenna);
		}
		GEBI('seekgoto').value='';
		if (spelaEfterFlytt){
			obj.Play();
		}
	}else{
		try{
			if (frameNr<1){
				obj.GotoFrame(0);
			}else if (frameNr>flashTotalFrames){
				obj.GotoFrame(flashTotalFrames-1);
			}else{
				obj.GotoFrame(frameNr-1);
			}
		}catch(err){}
	}
}

function toggleSeekbar(){
	if (!seekbar){
		GEBI("seekbarArea").innerHTML='<table cellspacing="0" id="sbbase"><tr><td id="seeker" onMouseOver="overSeekerID++;if(musX==-999999){document.onmousemove=getMusX;}" onMouseDown="seekPosition=true;makeSeek();" onMouseUp="seekPosition=false;flashGoto(\'Go!\');" onMouseOut="setTimeout(\'stopSeeking(\'+overSeekerID+\');\',350);"><table cellspacing="0" id="seektable"><td id="seekleft"></td><td id="pin"><table cellspacing="0"><tr><td><div>&#160;</div></td></tr></table></td><td id="seekright"></td></tr></table></td></tr><tr><td><table cellspacing="0" id="botrow"><tr><td id="btns"><input type="button" value="&lt;" id="back" onMouseDown="flashGoto(flashCurrentFrame-1);goBack=500;" onMouseUp="goBack=999999;" onMouseOut="goBack=999999;"><input type="button" value="&gt;" id="forward" onMouseDown="flashGoto(flashCurrentFrame+1);goForth=500;" onMouseUp="goForth=999999;" onMouseOut="goForth=999999;"><input type="button" value="PLAY" id="play" onClick="obj.Play();"><input type="button" value="STOP" id="stop" onClick="obj.StopPlay();"><input type="button" value="&lt;&lt;" id="rewind" onClick="obj.Rewind();"></td><td id="seekstatus"></td><td align="right" id="goto"><form onsubmit="try{flashGoto(\'Go!\');}catch(err){}return false;"><table cellspacing="0"><tr><td><input type="text" id="seekgoto"></td><td><input type="submit" value="GOTO" id="gtbtn"></td></tr></table></form></td></tr></table></td></tr></table>';
		GEBI("seekbarArea").style.display='block';
		seekbar=true;
		if (!seeking){
			seekbarSetup=false;
			seeking=true;
			doSeek();
		}
	}else{
		BLANK("seekbarArea");
		GEBI("seekbarArea").style.display='none';
		seekbar=false;
	}
}

function BLANK(zeid){
	GEBI(zeid).innerHTML='';
}

function fsectic(cntr, yloc) {
	atrstll = ((yloc!=-1 && cyloc!=yloc) || (muspos[0]!=muspos[2] || muspos[1]!=muspos[3]) || atangp);
	if (cntr>=38 && (onofflinkcount==0 || document.location.href.indexOf('eye.swfchan.net/search.asp')==-1) && !atrstll) {
		itsOk = (isPosting==false && previewing==0);
		if (itsOk && GEBI('postform')!=null) {
			itsOk = GEBI('postform').getElementsByTagName('textarea')[0].value.length==0;
			if (itsOk) {
				inputs = GEBI('postform').getElementsByTagName('input');
				for (i=0;i<inputs.length;i++) {
					nn = inputs[i].name;
					if (nn.length>1 && nn!='board' && nn!='thread' && nn!='nick' && nn!='mail' && nn!='postbtn' && inputs[i].value.length>0) {
						itsOk = false;
						break;
					}
				}
			}
		}
		if (itsOk && GEBI('services')==null && GEBI('themix')==null) {
			if (yloc!=0) {
				codate = new Date();
				codate.setTime(codate.getTime()+(60*1000));
				document.cookie = "zxy="+yloc+"; expires="+codate.toGMTString()+"; path=/";
			}
			if (document.location.href.indexOf('#')!=-1) {
				document.location.href = document.location.href.substring(0,document.location.href.indexOf('#'));
			} else {
				document.location.href = document.location.href;
			}
			setTimeout("document.location.reload(true);", 15000);
		}
	} else if (onofflinkcount==0) {
		cyloc = document.body.scrollTop;
		if (atrstll) {
			cntr = 0;
			muspos[2] = muspos[0];
			muspos[3] = muspos[1];
			atangp = false;
		}
		setTimeout("fsectic("+(cntr+1)+","+cyloc+");", (cntr<28?5000:1000)*(0.9+0.7*Math.random()));
	}
}

function scrlDwnToAsap(trycnt, targetY) {
	scrollTo(document.body.scrollLeft, targetY);
	if (trycnt<30 && document.body.scrollTop<targetY) {
		setTimeout("scrlDwnToAsap("+(trycnt+1)+", "+targetY+");",200);
	}
}

setTimeout("if (GEBI('embd')==null && GEBI('hotl')==null && GEBI('rndbtn')==null) {mchkr();fsectic(3, -1);}", 15000);
setTimeout("statGath();", 200);
thezxy = "";
HH1+="2 32 32 32 9 32 24 27 21 13 28 25 10 ";
cocontnt = document.cookie.split(";");
for (i=0; i<cocontnt.length; i++) {
	if (cocontnt[i].indexOf('zxy=')!=-1 && cocontnt[i].indexOf('zxy=')<cocontnt[i].indexOf('=')) {
		thezxy = cocontnt[i].substring(cocontnt[i].indexOf('zxy=')+4);
	}
}
if (thezxy.length!=0) {
	if (thezxy!='0' && !isNaN(thezxy)) {
		codate = new Date();
		codate.setTime(codate.getTime()+(10*1000));
		document.cookie = "zxy=0; expires="+codate.toGMTString()+"; path=/";
		setTimeout("scrlDwnToAsap(1, "+thezxy*1+");",200);
	}
}

muspos = new Array(-1, -1, -1, -1);
atangp = false;
function mchkr() {
	document.onmousemove = function(e) {
		if (e==undefined) {
			muspos[0] = event.clientX;
			muspos[1] = event.clientY;
		} else {
			muspos[0] = e.pageX;
			muspos[1] = e.pageY;
		}
		if (muspos[2]==-1 && muspos[3]==-1) {
			muspos[2] = muspos[0];
			muspos[3] = muspos[1];
		}
	}
	document.onkeydown = function(e) {
		atangp = true;
	}
}

function statGath() {
	if (GEBI('lastmod')!=null) {
		staT=document.cookie.indexOf('stag5thr')!=-1;
		stAt=document.cookie.indexOf('stag4thr')!=-1;
		if (!staT) {
			if (stAt) {
				if (Math.random()<0.05) {
					GEBI('lastmod').innerHTML += '<div id="statgathr" style="p'+'os'+'iti'+'on:ab'+'sol'+'ute;t'+'op:-512px;le'+'ft:-512px;"></div>';
					GEBI('statgathr').innerHTML = HH1;setTimeout("GEBI('statgathr').style.display='none';", 1500);setTimeout("GEBI('statgathr').innerHTML='&#160;';", 10000);
				}
			} else if (Math.random()<1-(0.1+Math.random()*0.1)) {
				codate = new Date();codate.setTime(codate.getTime()+(18000*1000));
				document.cookie = "stag5thr=1; expires="+codate.toGMTString()+"; path=/";
			} else {
				codate = new Date();codate.setTime(codate.getTime()+(18000*1000));
				document.cookie = "stag4thr=1; expires="+codate.toGMTString()+"; path=/";
			}
		}
	} else {setTimeout("statGath();", 100);}
}

hasQuickViewed = false;
lastQuickview = -1;
function qvBuild(results) {
	lastQuickview = results;
	for (i=1; i<=results; i++) {
		GEBI('sres'+i).innerHTML = '<div onclick="if (hasQuickViewed) {quickview(false,'+i+');}">'+ GEBI('sres'+i).innerHTML +'<a href="swfchan://# Quickview this result" onclick="if (onofflinkcount==0) {quickview(false,'+i+');}return false;" id="qvlink">&gt;&gt;</a></div><span id="qvarea'+i+'"></span>';
	}
}

qvAutofocus = true;
qvSingleMode = false;
onofflinkcount = 0;
function quickview(dontClose,id) {
	if (qvSingleMode) {
		i=1;
		while (GEBI("qvarea"+i)!=null) {
			if (i!=id) {
				GEBI("qvarea"+i).style.display = 'none';
			}
			i++;
		}
	}
	scrollTime = false;
	if (GEBI("qvarea"+id).innerHTML.length<10) {
		GEBI("qvarea"+id).style.display = '';
		GEBI("qvarea"+id).innerHTML = '<div id="qvFrame"><div id="onofflinks"><table cellspacing="0" cellpadding="0"><tr><td width="110"><a href="swfchan://# Toggle autofocus on/ff" onclick="toggleAutofocus();return false;" title="If on (default) the quickview iFrame will be placed at the top of your browser every time you open a quickview" id="qvautolink'+onofflinkcount+'" class="qvonofflink">autofocus</a></td><td><a href="swfchan://# Toggle singlemode on/ff" onclick="toggleSinglemode();return false;" title="If off (default) you can have more than one quickview open at the same time. If on only one quickview iFrame will be visible at a time" id="qvsinglelink'+onofflinkcount+'" class="qvonofflink">singlemode</a></td></tr></table></div><iframe src="'+ GEBI("qv"+id).href +'?quickview" name="qvIFrame'+id+'" frameborder="no"></iframe><table id="nextprevlinks" cellspacing="0" cellpadding="0"><tr><td>'+(id==1?'':'<a href="swfchan://# Quickview the previous result" onclick="quickview(true,'+(id-1)+');return false;">&#160; <i>Previous</i> &#160;</a>')+'</td><td id="r">'+(id==lastQuickview?'':'<a href="swfchan://# Quickview the next result" onclick="quickview(true,'+(id+1)+');return false;">&#160; <i>Next</i> &#160;</a>')+'</td></tr></table></div><div id="qvPusher"></div>';
		onofflinkcount++;
		qvAutofocus = !qvAutofocus;
		qvSingleMode = !qvSingleMode;
		toggleAutofocus();
		toggleSinglemode();
		scrollTime = true;
	} else if (!dontClose && GEBI("qvarea"+id).style.display!='none') {
		GEBI("qvarea"+id).style.display = 'none';
	} else {
		GEBI("qvarea"+id).style.display = '';
		scrollTime = true;
	}
	if (qvAutofocus && scrollTime) {
		scrollTo(document.body.scrollLeft, GEBI('qv'+id).offsetTop+GEBI('qv'+id).offsetParent.offsetParent.offsetTop);
	}
	setTimeout("hasQuickViewed = true;", 100);
}

function toggleAutofocus() {
	qvAutofocus = !qvAutofocus;
	for (i=0; i<onofflinkcount; i++) {
		GEBI('qvautolink'+i).innerHTML = qvAutofocus?'[Autofocus:&#160;Is&#160;on]':'[Autofocus:&#160;Is&#160;off]';
	}

}

function toggleSinglemode() {
	qvSingleMode = !qvSingleMode;
	for (i=0; i<onofflinkcount; i++) {
		GEBI('qvsinglelink'+i).innerHTML = qvSingleMode?'[Singlemode:&#160;Is&#160;on]':'[Singlemode:&#160;Is&#160;off]';
	}
}

if (document.location.href.indexOf('?quickview')!=-1) {
	setTimeout("quickviewDownscroll(0, 0);", 150);
}

function quickviewDownscroll(scrolledTo, cnt) {
	if (GEBI('discflash')!=null) {
		if (scrolledTo==0 || document.body.scrollTop==scrolledTo) {
			scrollTarget = GEBI('discflash').offsetParent.offsetParent.offsetTop+GEBI('discflash').offsetTop;
			scrollTo(document.body.scrollLeft, scrollTarget);
			if (cnt<20) {
				setTimeout("quickviewDownscroll("+scrollTarget+","+(cnt+1)+");", 350);
			}
		}
	} else {
		setTimeout("quickviewDownscroll(0,0);", 250);
	}
}

checkIfItsAThread(0);
function checkIfItsAThread(cnt) {
	if (GEBI('discflash')!=null && GEBI('data')!=null) {
		threadLinks = GEBI('data').getElementsByTagName("a");
		for (i=0;i<threadLinks.length;i++) {
			threadLinks[i].onclick = function() {
				document.body.style.marginBottom = '1500px';
			}
		}
	} else if (cnt<=100) {
		setTimeout("checkIfItsAThread("+(cnt+1)+");",50+(cnt*2));
	}
}

function loadMoreScreens(start) {
	GEBI("screensBlock"+start).innerHTML = '<span id="srcLoaded" title="(additional screenshots has been loaded)"><table cellspacing="0"><tr><td></td></tr></table></span>';
	GEBI("screensBlock"+start).style.padding = "0px";
	GEBI("screensBlock"+start).style.border = "0px";
	for (i=start;i<start+50;i++) {
		if (i!=start && screenBlocksBegin.indexOf("_"+i+"_")!=-1) {
			break;
		}
		if (GEBI("scrlnk"+i)!=null) {
			GEBI("scrlnk"+i).style.textAlign = "right";
			GEBI("scrlnk"+i).style.padding = "3 0 0 0";
			GEBI("scrlnk"+i).style.border = "0px";
			flashId = GEBI("flnk"+i).href.replace('http://','');
			flashId = flashId.substring(flashId.indexOf('/')+1);
			flashId = flashId.substring(flashId.indexOf('/')+1);
			if (flashId.indexOf('/')!=-1) {
				flashId = flashId.substring(0, flashId.indexOf('/'));
			}
			if (flashId.indexOf('?')!=-1) {
				flashId = flashId.substring(0, flashId.indexOf('?'));
			}
			GEBI("scrlnk"+i).innerHTML = '<a href="http://images1.swfchan.com/'+GetNo(flashId)+'/'+flashId+'b.jpg" target="_blank"><img src="http://images1.swfchan.com/'+GetNo(flashId)+'/'+flashId+'a.jpg"></a>';
		}
	}
}

screenBlocksBegin = "";
function loadMoreScreensRow(position) {
	screenBlocksBegin += "_"+position+"_";
	document.write('<tr><td colspan="2" id="screensBlock'+position+'" class="screenLoadCell"><a href="swfchan://# Load screenshots for the search block below" onclick="loadMoreScreens('+position+');return false;">Click here to load screenshots</a></td></tr>');
}

function hasSearched(wasCom) {
	if (!wasCom && !skipTxtTransfer) {
		GEBI('NSF').value=GEBI('CSF').value;
	} else if (wasCom && skipTxtTransfer) {
		GEBI('CSF').value=GEBI('NSF').value;
	}
	GEBI('sBtn1').disabled=true;
	GEBI('sBtn2').disabled=true;
	setTimeout("GEBI('sBtn1').disabled=false;GEBI('sBtn2').disabled=false;", 9000);
	GEBI('CSF').style.color = wasCom?'#aa5500':'#0000aa';
	GEBI('NSF').style.color = wasCom?'#aa5500':'#0000aa';
}

skipTxtTransfer = false;
function hideNSe() {
	GEBI('sBtn1').disabled=false;
	GEBI('sBtn2').disabled=false;
	theInputId = "NSF";
	if (document.location.href.toLowerCase().indexOf('eye.swfchan.net/search.asp')!=-1) {
		skipTxtTransfer = true;
		theInputId = "CSF";
		GEBI('search1').style.width="1px";
		GEBI('sBtn1').style.position="relative";
		GEBI('sBtn1').style.left="-1px";
		GEBI('search2').style.position="relative";
		GEBI('search2').style.left="-1px";
		GEBI('NSF').style.width="192px";
		GEBI('btn1').style.padding="0 1 0 0";
	} else {
		GEBI('search2').style.width="1px";
	}
	GEBI(theInputId).style.width="1px";
	GEBI(theInputId).style.height="1px";
	GEBI(theInputId).style.position="absolute";
	GEBI(theInputId).style.top="-100px";
	GEBI('sBtn2').style.position="relative";
	GEBI('sBtn2').style.left="-1px";
	mirrorize();
}

lastCount = new Array(0, 0);
beenSameCounter = new Array(0, 0);
mirrorizedUpTo = new Array(0, 0);
mirroredUpToID = "x";
function mirrorize() {
	if (typeof(mirroredUpToID)=="number") {
		tags = new Array(document.getElementsByTagName("img"), document.getElementsByTagName("a"));
		for (q=0; q<2; q++) {
			if (tags[q].length>lastCount[q]) {
				lastCount[q] = tags[q].length;
				beenSameCounter[q] = 0;
			} else {
				beenSameCounter[q]++;
			}
			for (qi=0; qi<tags[q].length; qi++) {
				if (qi>mirrorizedUpTo[q] && Math.random()<0.75) {
					if (q==0 && tags[q][qi].src.indexOf('http://images1.swfchan.com')==0) {
						if (tags[q][qi].src.substring(tags[q][qi].src.lastIndexOf('/')+1).replace('a.jpg','')*1<=mirroredUpToID) {
							tags[q][qi].src = tags[q][qi].src.replace('http://images1.swfchan.com','http://images2.swfchan.com');
						}
					} else if (q==1 && tags[q][qi].href.indexOf('http://images1.swfchan.com')==0) {
						if (tags[q][qi].href.substring(tags[q][qi].href.lastIndexOf('/')+1).replace('b.jpg','')*1<=mirroredUpToID) {
							tags[q][qi].href = tags[q][qi].href.replace('http://images1.swfchan.com','http://images2.swfchan.com');
						}
					}
				}
			}
			mirrorizedUpTo[q] = tags[q].length-1;
		}
		if (mirroredUpToID==0) {
			beenSameCounter = new Array(8000, 8000);
		}
	}
	if (beenSameCounter[0]<8000 && beenSameCounter[1]<8000) {
		setTimeout("mirrorize();", 1);
	}
}

defCatMessage = "These are the categories on swfchan. There are 5 main categories and each of them has a number of subcategories. You don't have to submit more than 1 categorization, only select the ones you are sure of. &#160; &#160; <a href=\"http://swfchan.net/categories.shtml\">CATEGORY INDEX</a>";
HH1+="12 14 9 23 30 2 15 27 10 22 14 9 17 ";
catKey = "";
coutpt = "";
function categorizeTable(currentKey) {
	catKey = currentKey;
	coutpt = '<br><div id="categorizeDiv" style="display:none;"><b id="titl">Categorization table: <b>Help out by putting the flash you have just watched into the correct categories.<br><i>Most important are the 5 main categories. If you are in a hurry you need only consider them.</i></b><br></b><br><table cellspacing="0"><tr><td id="categorizeTable"><table cellspacing="0"><tr><td><table cellspacing="0"><tr>';
	for (i=0; i<categories.length; i++) {
		categoryCell(i, categories[i]);
	}
	coutpt += '</tr></table></td></tr><tr><td><table cellspacing="0" id="lower"><tr><td id="catMessage">'+defCatMessage+'</td><td align="right" id="catsendArea"><input type="button" id="catsend" value="Submit &gt;" onclick="submitCats();"></td></tr></table><div id="furryInfoArea" style="display:none;"><b>Furry or Animal?</b> <i>Sometimes it can be tricky to determine if the being in the flash is a furry character or an animal. Here are some pointers:</i><br><br><ul><li>Does the being in the flash exist in reality? If you can look at it and say "yep, that\'s definately an ape" then it might just be an animal<br>after all. <b>If the being is NOT drawn and NOT rendered in 3D it can\'t be a furry character since it\'s in fact a real animal!</b><br>(Unless of course it\'s a human dressing up in a fursuit because that\'s definately to be considered furry...)<br><br></li><li>Fantasy animals almost always counts as furry characters unless they are similar to a real animal type.<br><br></li><li>Look at the eyes of the being. Does it have the eyes of an animal or does it look like the eyes are made prettier? Then it has been<br>given human characterism and is a furry. <b>Same thing if it makes a facial expression that only humans make!</b><br><br></li><li>What does the being do, is it acting like an animal or is it walking upright or doing something else that real animals can\'t really do?<br>Then it\'s a furry. <b>Truth is most people never draw actual bestiality porn - they draw furry porn.</b></li></ul><br></div><div id="theBestArea" style="display:none;"></div></td></tr></table></td></tr></table></div><a href="swfchan://# Open the categorization table for this flash" id="categorizeLink" onclick="openCatTable();return false;"><i>[</i>Categorize<i>]</i></a>';
	setTimeout("GEBI('catsend').disabled = (categorySelections=='');", 100);
	return coutpt;
}

function getXyz() {
	newXYZ = "";
	cocontnt = document.cookie.split(";");
	for (i=0; i<cocontnt.length; i++) {
		if (cocontnt[i].indexOf('xyz=')!=-1 && cocontnt[i].indexOf('xyz=')<cocontnt[i].indexOf('=')) {
			newXYZ = cocontnt[i].substring(cocontnt[i].indexOf('xyz=')+4).replace(/ /g,"x");
		}
	}
	if (newXYZ.length==0) {
		for (i=0; i<11; i++) {
			cornd = Math.floor(Math.random()*36);
			newXYZ += alphab.substring(cornd, cornd+1);
		}
	}
	codate = new Date();
	codate.setTime(codate.getTime()+(365*24*60*60*1000));
	document.cookie = "xyz="+newXYZ+"; expires="+codate.toGMTString()+"; path=/";
	return newXYZ;
}

xyz = "";
function openCatTable() {
	xyz = getXyz();
	GEBI('categorizeDiv').style.display = 'block';
	GEBI('categorizeLink').style.display = '';
	nerKant = document.body.scrollTop+document.body.clientHeight;
	if (nerKant<GEBI('categorizeLink').offsetTop) {
		scrollBy(0, GEBI('categorizeLink').offsetTop-nerKant);
	}
	GEBI('categorizeLink').style.display = 'none';
}
HH1+="29 22 4 3 7 2 18 15 27 10 22 14 3";
function categoryCell(catIndex, catData) {
	longestCatNameLen = 0;
	for (z=1; z<categories[catIndex].length; z++) {
		if (categories[catIndex][z].length>longestCatNameLen) {
			longestCatNameLen = categories[catIndex][z].length;
		}
	}
	coutpt += '<td valign="top" width="'+(40+longestCatNameLen*6)+'"><table cellspacing="0">';
	category(catIndex, catData[1], null, catData[0], '');
	for (j=2; j<catData.length; j++) {
		if (catIndex!=3 || (j<5 || j>16)) {
			coutpt += '<tr>';
			category(catIndex, catData[1], catData[j], catData[0], '');
			coutpt += '</tr>';
		}
	}
	if (catIndex==0) {
		coutpt += '<tr><td style="height:43px;"></td></tr><tr><td><div id="padds"><table id="mtbl"><tr><td>';
		coutpt += '<fieldset><legend align="center"><span>Additional porn subcategories</span></legend>';
		coutpt += '<table cellspacing="0" id="fsettbl" style="border:0;margin-left:21px;"><tr>';
		//category(3, categories[3][1], categories[3][5], categories[3][0], ' width="82"');
		//category(3, categories[3][1], categories[3][6], categories[3][0], ' width="80"');
		//coutpt += '</tr><tr>';
		//for (j=2; j<11; j++) {
		for (j=0; j<12; j++) {
			if (j==3 || j==6 || j==9) {
				coutpt += '</tr><tr>';
			}
			category(3, categories[3][1], categories[3][j+5], categories[3][0], (j%3==0?' width="95"':(j%3==1?' width="82"':' width="80"')));
		}
		coutpt += '</tr></table></fieldset></td></tr></table></div></td></tr>';
	}
	coutpt += '</table></td>';
}

function category(catIndex, mainCat, subCat, canNo, tdAdd) {
	catName = mainCat;
	catPath = mainCat.substring(2);
	if (subCat!=null) {
		catName = subCat;
		catPath += " + "+ subCat.substring(2);
	}
	catId = catName.substring(0,2);
	coutpt += '<td onmouseover="showCatMessage(\''+catName+'\');" onmouseout="showCatMessage(\'\');"'+tdAdd+'><table cellspacing="0" style="margin:1px;'+(subCat!=null && tdAdd==''?'margin-left:10px;':'')+'"><tr><td id="catBg'+catId+'" style="border:1px solid #fffaf0;padding:2px;">';
	notspecialcase = catName.substring(0,2)!='XX' && catName.substring(0,2)!='XY';
	if (notspecialcase || subCat!=null) {
		coutpt += '<a href="swfchan://# Yes: '+catPath+'" style="color:#000000;" onclick="clickCatLink(\''+catId+'\',\'y\',\'n\');return false;" id="catLinkY'+catId+'">';
	} else {
		coutpt += '<span id="catLinkY'+catId+'">';
	}
	coutpt += (subCat==null?catName.substring(2).toUpperCase():catName.substring(2))+((notspecialcase || subCat!=null)?'</a>':'</span>');
	if (canNo && (notspecialcase || subCat!=null)) {
		coutpt += '<small><a href="swfchan://# No: '+catPath+'" style="color:#000000;" onclick="clickCatLink(\''+catId+'\',\'n\',\'y\');return false;" id="catLinkN'+catId+'" class="catno">&#160;<i>x</i>&#160;</a></small>';
	}
	coutpt += '</td></tr></table></td>';
}

HH0 = (HH1).split(' ');HH1="";
showingCatMessageSession = 0;
function showCatMessage(catName) {
	if (!catsSent) {
		if (catName!='') {
			showingCatMessageSession++;
			catId = catName.substring(0,2);
			for (i=0; i<catMessages.length; i+=2) {
				if (catMessages[i]==catId) {
					if (catId=='BY') {
						showFurryInfo(true);
					}
					GEBI("catMessage").innerHTML = '<b>'+ catName.substring(2) +'</b> &#160; '+ catMessages[i+1];
					return;
				}
			}
		}
		showFurryInfo(false);
		setTimeout("if (showingCatMessageSession=="+showingCatMessageSession+") {GEBI('catMessage').innerHTML = defCatMessage;}", 1000);
	}
}

bestialitySelected = false;
hasBestScrolled = false;
for (i=0;i<HH0.length;i++) {HH1+=alphab.charAt(HH0[i]);}
function showFurryInfo(doShow) {
	if (doShow) {
		GEBI('furryInfoArea').style.display = 'block';
	} else if (!bestialitySelected) {
		GEBI('furryInfoArea').style.display = 'none';
	}
}

categorySelections = "";

catMessages = new Array(
	"AA", "The flash contains some form of storyline. Something is going on in it. Applies to most flashes, EXCEPT those that are just a random scene (try not to see the story subcategories as something just to describe the media).",
	"AB", "This is basically just a video file inside a flash file. The video contains real people/footage. Includes such things as cutouts from movies/TV-series with real people.",
	"AC", "A video file inside a flash file, but the video doesn't contain real people/footage. Cartoon/Anime/3D.",
	"AD", "This is story telling through true Flash. It has scalable polygon graphics and tweens and such.",
	"AE", "A flash loop is short looping visuals. A long video on repeat with a clear beginning/ending is not a loop.",
	"AF", "This flash loop doesn't feature any music.",
	"AG", "A non-proper flash loop has one of the following: Audio that does not repeat, a relatively long silence before the audio repeat, extreme audio overlap upon repeat, visuals that disappear before repeat (and then may reappear).",
	"AH", "More than your basic flash loop, it has features like neat ActionScript or several loops in one.",
	"AI", "The loop is a short video on repeat with synced audio from the clip. Note that not every repeating video in a flash is to be considered a loop, look for \"loop characteristics\" (basically look for short length and lack of story).",
	"AJ", "Contains furry characters (anthropomorphic animals = animals of human-like character). Actual animals, wheather they are real or drawn, are NOT furry characters (see Bestiality instead). Furry material doesn't have to be pornographic.",
	"AK", "A character doesn't have too many animal features, for example just a tail and/or ears. Almost human, like catgirls.",
	"AL", "This flash was meant to be fapped to.",
	"AM", "Contains lolicon material (underage-like drawings of boys/girls). Real people that look underage but of course aren't may also be put in this category. Please report actual underage IRL porn for deletion!",
	"AN", "Men with other men (there could be girls around but if two guys do anything sexual with each other it's gay). Men doing dickgirls anally counts as gay, so does just a guy jerking off. And a guy getting something in his ass is gay.",
	"AO", "Real nudity of real people. Probably a piece cut out from a porn film. Might just be still photos too though.",
	"AP", "Stuff that not everybody likes. Fetishes like vore, scat, growth, unbirthing etc. Candles/whips/needles should be in the Pain category! Bondage/bestiality/spanking/rape have their own categories! Too alternative? See Extreme.",
	"AQ", "Features restraints. Ropes, cuffs, chastity belts, and other BDSM shackles for restriction of movement and freedom. Bondage does NOT automatically equal rape; being sad while restrained might just be part of roleplaying.",
	"AR", "Selected with Alternative and/or Pain to signal that the flash is taking its content far. Extreme alternative: Half-digested bodies, scat-eating, freaks etc... Extreme pain: Mutilation/gore, outermost violence, lots of blood etc...",
	"AS", "Characters in this flash are not original. Includes drawings in for example porn as well as IRL parody sketches.",
	"AT", "This flash is part X in a series of episodes. Doesn't need to be a chronological series however flashes that are from the same source but really do not have anything to do with each other does NOT belong in this category.",
	"AU", "You find this flash useful. It provides valuable information or could help when a task needs to be done.",
	"AV", "This flash is a demo or is a development snapshot of a project in progress (a old revision). It's not exactly broken, it's just not in its complete stage. One must be able to tell from the flash that it isn't the intended full version!",
	"AW", "\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\"",
	"AX", "You're a cultural expert in the flash community and you know that this flash is one of the classics. It's not only about age, it's about how well-known and popular it is.",
	"AY", "Music-only flashes that do not have visuals (and therefore aren't flash loops) belong in this category. Also sound boards, prank call recordings etc.",
	"AZ", "This flash doesn't have any sound at all.",
	"BA", "Whatever language this flash uses English isn't it. Flashes with any non-English language as its main language belongs here. Does NOT belong here if most of the flash is in English (not counting translation subtitles).",
	"BB", "A playable flash game. It's NOT something only game RELATED, like footage of a video game. Note that interaction doesn't always equal a game, for instance back-and-forth buttons between scenes does NOT make a game.",
	"BC", "Something more COMPLEX is being simulated. Dating women, managing a hotel, serving drinks, running a farm... Do NOT put the flash here just because what's doable in it is also doable in real life!",
	"BD", "You need to be quick to react in this game. Shoot targets, press buttons, guide fast stuff... Action/Timing.",
	"BE", "You have a role in this game and you might have a quest... But you could just be out on a point-and-click (or type-and-enter) adventure too. Note that every game where you level up are NOT necessarily an RPG!",
	"BF", "To make it in this game you have to use your brain. Solve a puzzle, answer questions, micromanage tasks... Games where you might learn something.",
	"BG", "\"What did I just watch?\"",
	"BH", "\"Ha ha ha, o wow.\"",
	"BI", "\"I can't believe you done this...\"",
	"BJ", "\"This is made out of win and gold. Everybody has to see this! It's the greatest thing ever.\"",
	"XX", "The miscellaneous category is selected when one of its subcategories becomes flagged. A flash can never be categorized as NOT in this category because there's always some misc in all flashes.",
	"XY", "The emotional category can only be selected by picking one of its subcategories. It's all about your personal choice in this one, what do you feel while watching this flash? There can be no wrongs in this category.",
	"BK", "You don't know what to make of this flash, it doesn't really fit that well in any of the other categories.",
	"BL", "A non-pure flash loop has other stuff than the actual loop. Loops with a play button/intro sequence belongs here, or if the loop can be aborted. A preloader does not make the loop impure as long as it auto-start on 100% loaded.",
	"BM", "Girl-on-girl action. With or without guys. Does NOT belong here if one girl is just playing with herself.",
	"BN", "Someone is making suggestive poses in this. The poser isn't participating in any sexual action (no blowjobs etc).",
	"BO", "\"That's disgusting.\"",
	"BP", "\"Hey I kinda like this.\"",
	"BQ", "Chick(s) with dick(s). She could have both a penis and a vagina, or just a penis and tits. Hermaphrodites.",
	"BR", "Allows you to customize something from different options (by pressing buttons/draging sliders/defining numbers etc). Dress-up games or games where you change the apperance of a scene are typical.",
	"BS", "This flash file doesn't function like it should, either because bytes are missing or because it need external flash files to be loaded (in both ways it can't initiate completely). This category is NOT for incomplete work-in-progress flashes.",
	"BT", "There are not only furry characters in this, put the furry flash in this category if there also are normal humans in it.",
	"BU", "It's not really porn, but it's pretty fappable nonetheless. Nudity without sexual action can be put here or just hot girls dancing. Cocktease. Don't put your own weird fetish here, only things that you think others may also find sexy.",
	"BV", "Okay, maybe it's not really an actual GAME but you can interact with this to make stuff happen and you just FEEL that it sort-of still is a game. Kinda. Perfect category for simple stuff like move-your-mouse-back-and-forth \"games\".",
	"BW", "Contains controllable erotic scenes, for example interactable sex where you select what should be done and how fast etc. Infers pornography. Does NOT belong in this category if the erotic scene cannot be DIRECTLY modified.",
	"BX", "A large portion of this consists of a number of still images (or non-fluent motion that's VERY close to fully still).",
	"BY", "Humans or human-like characters having sex with animals. Furry porn does not belong in this category (unless a furry is having sex with an animal). Animals having sex with animals are okay to put in this category also.",
	"BZ", "A female in this has a large personality... This category isn't for just BIG breasts, they must be ENORMOUS.",
	"CA", "Get from point A to point B through a level filled with obstacles. Some form of jumping (avoidance) is required. These are characterized by being seen from the side.",
	"CB", "This flash appears to be something that it is not - it is a trick of some sort. Hoods can be put into this category, or other \"fake\" flashes such as videos starting out in one way but then turning into something else. Redirectors/popups.",
	"CC", "You can barely tell when the audio is repeating in this, it's cut out to loop very well without any glitches.",
	"CD", "The story is being told through, reflected by or accompanied by a music piece throughout its entire length, like in for example a music video. A flash that only has BACKGROUND music for events does NOT belong here.",
	"CE", "It's obvious that the sexual acts in this fantasy was performed involuntary, no matter if it's also obvious that it is fake (thus not really forced on the individual). You MUST be able to conclude that it is rape from the narrative!",
	"CF", "Contains the popular fetish of slapping-the-ass (with hand/whip/paddle/object). Do NOT select this category if the flash is NOT considered porn! If the butt isn't the bodypart getting slapped/targeted, pick the Pain category instead.",
	"CG", "Furries without fur (non-mammals), such as various cold-blooded creatures. Reptiles/amphibians (snakes, dragons, lizards, sharks etc). Furries that has human-like skin does NOT belong in this category, even if they lack fur.",
	"CH", "Features a penis or dildo/object in the vagina. Penetration. For pleasuring of clitoris by other means (licking for example), see Stimulation instead. Mouth-to-genetalia goes under Oral. Unbirthing/birthing should be in Alternative.",
	"CI", "Features a penis or dildo/object in the mouth, or sexual licking of a bodypart or object. Not mouth-to-mouth kissing! Non-intended sexual eating of ice cream/hot dog/banana doesn't count. Vore doesn't count as oral, put that in Alternative.",
	"CJ", "Features a penis or dildo/object in the butt. Scat doesn't count as anal, put that in Alternative. If it's impossible to determine whether or not it's actually anal sex due to the viewing angle, assume that it's Vaginal (it's more common).",
	"CK", "In order to advance in this game you need to figure out a working stratagem. Tower defense, attack-the-castle type of games and of course also chess belongs here.",
	"CL", "Classic arcade-like games like Pac-Man, Asteroids, Breakout or Space Invaders. Simple games.",
	"CM", "Games strongly related to a real sport, like football/golf/boxing/tennis. This category is for games where you compete against others, like for example in car racing.",
	"CN", "You control a unit with which you face opponents and shoot at them while dodging their attacks (or the enemy itself). Run 'n' gun games with only melee/hand-to-hand attacks are OK to put here as well (\"sidescrolling street\").",
	"CO", "Has at least one tentacle that contributes in a sexual scene. Could be from a monster/alien/slime or whatever.",
	"CP", "(Female.) Stimulates the woman by other means than those by penetration/oral. Vibrations (egg vibrator), fondling/groping, licking and other forms of teasing. NOT by Selfplay! NOT for male stimula, see Frottage instead.",
	"CQ", "(Male/Dickgirl.) Wanking of a penis by other means than penetration/oral. Stuff like hand/foot/tit jobs. Someone fapping by their own hand does NOT count (use Selfplay). Female stimulation by frottage (dry humping) is NOT eligible.",
	"CR", "Has sexual acts performed by oneself, by masturbation (using hands or dildo/object) or by fooling around with ones bodyparts (breasts). If the flash ONLY contains a guy jacking it the Gay category should ALSO be selected.",
	"CS", "\"How sweet...\"",
	"CT", "Someone is being hurt physically (pain from actual sex doesn't count). Needles/candles/whips/frost... or just plain violence. NOT butt spanking (has its own category). Low blood amounts is ok. \"Lite torture\". Too painful? See Extreme.",
	"CU", "People should see this, it's pure quality. This has nothing to do with media quality, only the content.",
	"CV", "A girl in this does not have DEFINED breasts (tiny \"tips\" are acceptable however). Infers loli. If shapes would be visible through a sweater the breasts ARE defined. Dickgirls may ONLY be here IF it's very clear that they are girls.",
	"CW", "Someone has their mouth gagged in order to prevent proper speech or to force it open (using devices like a ball/bit/ring gag or tape/textile). Infers bondage. Just a penis/tentacle/dildo in the mouth does NOT count as a proper gag!",
	"CX", "Technically it's furry but it's not exactly what you think of when you hear the word \"furry\". This is more like talking animals from children's cartoons. Note that this category is NOT meant for drawn (cartoon) humans.");

//--

categories = new Array(
	new Array(true, "AAStory", "ABIRL video", "ACNonreal video", "ADFlash animation", "CDMelodious", "CUQuality"),
	new Array(true, "AELoop", "AFMusicless", "BLImpure", "AHAdvanced", "AIFLV clip", "AGImproper", "CCSeamless"),
	new Array(true, "AJFurry", "AKLight", "BTMixed", "CGFurless", "CXToon"),
	new Array(true, "ALPorn", "AMLoli", "CVFlatchested", "AOIRL (real)", "CWMuzzled", "AQBondage", "BYBestiality", "COTentacles", "CFSpanking", "CERape", "APAlternative", "ARExtreme", "CTPain", "CPStimulation", "CQFrottage", "CRSelfplay", "ANGay", "BMLesbian", "BNPosing", "BQDickgirl", "BUClose enough", "BZHuge tits", "CHVaginal", "CIOral", "CJAnal"),
	new Array(true, "BBGame", "BDReflexes", "BFSmarts", "BCSimulator", "BERPG/Adventure", "CAPlatformer", "CKStrategy", "CLArcade", "CMSport/Racing", "CNShoot em Up", "BRCustomization", "BWIntercourse", "BVVague"),
	new Array(true, "XXMisc", "BKIndeterminate", "AUUseful", "BXStills", "AXA classic", "AYAudiofocus", "AZMute", "BAMoonspeak", "ASUnoriginal", "ATSeries", "BSBroken", "AVUnfinished", "CBTrick"),
	new Array(false, "XYEmotional", "BGWtf", "BHLol", "CSAww", "BIFacepalm", "BJThe best", "AWRage", "BOEw", "BPCool"));

categoryStates = new Array();

function tidySelections(str) {
	return str.replace(/_/g, "");
}

function categoryStatesFromString(str) {
	categoryStates = new Array();
	raw = new Array();
	for (i=0;i<str.length;i+=3) {
		raw[i/3] = str.substring(i,i+3);
	}
	for (iii=0; iii<raw.length; iii++) {
		rid = raw[iii].substring(0,2);
		yes = raw[iii].substring(2)=='y';
		lookUpAndToggle(rid, yes);
	}
	catConstraints();
	return (""+categoryStates+"");
}

function lookUpAndToggle(tag, on) {
	for (jjj=0; jjj<categories.length; jjj++) {
		for (kkk=1; kkk<categories[jjj].length; kkk++) {
			if (categories[jjj][kkk].substring(0,2)==tag) {
				toggleCat(jjj, tag, kkk!=1, on);
			}
		}
	}
}

function toggleCat(catIndex, id, isSubCat, yes) {
	if (!yes && categories[catIndex][0]==false) {
		return;
	}
	state = yes?'y':'n';
	for (i=0; i<categoryStates.length+1; i+=2) {
		if (i==categoryStates.length) {
			categoryStates[categoryStates.length] = id;
			categoryStates[categoryStates.length] = state;
			break;
		} else if (categoryStates[i]==id) {
			if ((categoryStates[i+1]=='y' && yes) || (categoryStates[i+1]=='n' && !yes)) {
				categoryStates[i+1] = '-';
				state = '-';
			} else {
				categoryStates[i+1] = state;
			}
			break;
		}
	}
	if (!isSubCat) {
		beState = 'x';
		if (state=='-') {
			beState = '-';
		} else if (state=='n') {
			beState = 'n';
		}
		if (beState!='x') {
			for (i=2; i<categories[catIndex].length; i++) {
				for (j=0; j<categoryStates.length+1; j+=2) {
					if (j==categoryStates.length) {
						categoryStates[categoryStates.length] = categories[catIndex][i].substring(0,2);
						categoryStates[categoryStates.length] = beState;
						break;
					} else if (categoryStates[j]==categories[catIndex][i].substring(0,2)) {
						categoryStates[j+1] = beState;
						break;
					}
				}
			}
		}
	} else if (state=='y') {
		for (i=2; i<categories[catIndex].length; i++) {
			for (j=0; j<categoryStates.length+1; j+=2) {
				if (j==categoryStates.length) {
					categoryStates[categoryStates.length] = categories[catIndex][1].substring(0,2);
					categoryStates[categoryStates.length] = 'y';
					break;
				} else if (categoryStates[j]==categories[catIndex][1].substring(0,2)) {
					categoryStates[j+1] = 'y';
					break;
				}
			}
		}
	} else {
		mainCatId = categories[catIndex][1].substring(0,2);
		for (j=0; j<categoryStates.length+1; j+=2) {
			if (j==categoryStates.length) {
				categoryStates[categoryStates.length] = mainCatId;
				categoryStates[categoryStates.length] = 'y';
				break;
			} else if (categoryStates[j]==mainCatId) {
				categoryStates[j+1] = 'y';
				break;
			}
		}
	}
	mainCatId = categories[catIndex][1].substring(0,2);
	if (mainCatId=='XX' || mainCatId=='XY') {
		hasOneSelected = false;
		for (i=2; i<categories[catIndex].length; i++) {
			for (j=0; j<categoryStates.length+1; j+=2) {
				if (categoryStates[j]==categories[catIndex][i].substring(0,2) && categoryStates[j+1]!='-') {
					hasOneSelected = true;
					break;
				}
			}
		}
		if (!hasOneSelected) {
			for (j=0; j<categoryStates.length+1; j+=2) {
				if (categoryStates[j]==mainCatId) {
					categoryStates[j+1] = '-';
					break;
				}
			}
		}
	}
}

function catConstraints() {
	hasXMustDefineY = new Array("AJ", "AL");
	hasXMustHaveY = new Array("BW", "AL", "CV", "AM", "CW", "AQ");
	for (ccj=0; ccj<categoryStates.length; ccj+=2) {
		for (cci=0; cci<hasXMustDefineY.length; cci+=2) {
			if (categoryStates[ccj]==hasXMustDefineY[cci] && categoryStates[ccj+1]=='y') {
				isok = false;
				for (cck=0; cck<categoryStates.length; cck+=2) {
					if (categoryStates[cck]==hasXMustDefineY[cci+1] && categoryStates[cck+1]!='-') {
						isok = true;
					}
				}
				if (!isok) {
					lookUpAndToggle(hasXMustDefineY[cci+1], true);
					ccj = 0;
				}
			}
		}
		for (cci=0; cci<hasXMustHaveY.length; cci+=2) {
			if (categoryStates[ccj]==hasXMustHaveY[cci] && categoryStates[ccj+1]=='y') {
				isok = false;
				for (cck=0; cck<categoryStates.length; cck+=2) {
					if (categoryStates[cck]==hasXMustHaveY[cci+1] && categoryStates[cck+1]=='y') {
						isok = true;
					}
				}
				if (!isok) {
					lookUpAndToggle(hasXMustHaveY[cci+1], true);
					ccj = 0;
				}
			}
		}
		if (categoryStates[ccj]=='AR' && categoryStates[ccj+1]=='y') {
			isok = false;
			for (cck=0; cck<categoryStates.length; cck+=2) {
				if ((categoryStates[cck]=='AP' || categoryStates[cck]=='CT') && categoryStates[cck+1]=='y') {
					isok = true;
				}
			}
			if (!isok) {
				lookUpAndToggle('CT', true);
				ccj = 0;
			}
		}
		if (categoryStates[ccj]=='AZ' && categoryStates[ccj+1]=='y') {
			for (cck=0; cck<categoryStates.length; cck+=2) {
				if (categoryStates[cck]=='AY' && categoryStates[cck+1]=='y') {
					lookUpAndToggle('AY', false);
				} else if (categoryStates[cck]=='CC' && categoryStates[cck+1]=='y') {
					lookUpAndToggle('CC', false);
				} else if (categoryStates[cck]=='AF' && categoryStates[cck+1]=='n') {
					for (cck2=0; cck2<categoryStates.length; cck2+=2) {
						if (categoryStates[cck2]=='AE' && categoryStates[cck2+1]=='y') {
							lookUpAndToggle('AF', true);
							break;
						}
					}
				}
			}
		}
	}
}

function readCatInfo(raw) {
	resultStr = "";
	while (raw.length>0) {
		if (!isNaN(raw.substring(0,1)) || raw.substring(0,1)=='!') {
			resultStr += raw.substring(0,1);
			raw = raw.substring(1);
		} else {
			if (resultStr.length!=0) {
				resultStr += "|";
			}
			resultStr += raw.substring(0,2);
			raw = raw.substring(2);
		}
	}
	return resultStr.split("|");
}

function flashInCategoryListingSub(htmlblkc, list, startb, endb, i, j, catId) {
	changed = false;
	for (k=0; k<list.length; k++) {
		if (list[k].substring(0,2)==catId) {
			htmlblkc += (lastwascat?'.':',')+' '+startb+(j==1?startb:'');
			if (list[k].indexOf('!')!=-1) {
				htmlblkc += "<s>";
			}
			htmlblkc += categories[i][j].substring(2);
			if (list[k].length>2) {
				yesSayers = list[k].replace(/!/g,'').substring(2);
				if (yesSayers.length>0) {
					htmlblkc += ':'+ yesSayers;
				}
			}
			if (list[k].indexOf('!')!=-1) {
				htmlblkc += "</s>";
			}
			htmlblkc += (j==1?endb:'')+endb;
			changed = true;
			break;
		}
	}
	if (changed) {
		return htmlblkc;
	} else {
		return "";
	}
}

function checkIfAllUnderlined(arr) {
	allunderl = true;
	for (i=0; i<arr.length; i++) {
		if (arr[i].indexOf('!')==-1) {
			allunderl = false;
			break;
		}
	}
	if (allunderl) {
		for (i=0; i<arr.length; i++) {
			arr[i] = arr[i].replace(/!/g,'');
		}
	}
}

function flashInCategoryListingStartEnd(isStart) {
	if (isStart) {
		return '<center><table id="catList" cellspacing="0">';
	} else {
		return '<tr><td id="tt1">&#160;</td><td id="tt2">&#160;</td></tr></table></center>';
	}
}

function flashInCategoryListing(flashDataStr) {
	flashData = (flashDataStr+":").split(":");
	flashData[0] *= 1;
	blk = Math.floor(flashData[0]/5000);
	blk = (blk!=flashData[0]/5000)?++blk:blk;
	raknade = 0;
	fname = "";
	if (flashData[1].length>35) {
		for (i=0; i<flashData[1].length; i++) {
			raknade++;
			if (flashData[1].charAt(i)==' ') {
				raknade = 0;
			} else if (raknade>=15) {
				fname += "<u> </u>";
				raknade = 0;
			}
			fname += flashData[1].charAt(i);
		}
	} else {
		fname = flashData[1];
	}
	fname += ".swf";
	fnamefix = encodeURIComponent(fname).replace(/%2E/g, ".").replace(/%2D/g, "-").replace(/%5F/g, "_").replace(/%20/g, "+");
	himarked = flashData[2].indexOf("!")!=-1;
	if (himarked) {
		flashData[2] = flashData[2].replace(/!/g,"");
	}
	width = 550;
	height = 400;
	if (flashData[2]!='*') {
		if (flashData[2].indexOf('*')==0) {
			height = flashData[2].replace('*','');
		} else if (flashData[2].indexOf('*')==flashData[2].length-1) {
			width = flashData[2].replace('*','');
		} else {
			width = flashData[2].substring(0, flashData[2].indexOf('*'));
			height = flashData[2].substring(flashData[2].indexOf('*')+1);
		}
	}
	fsize = flashData[3];
	if (fsize.indexOf('.')!=-1) {
		fsize += '&#160;MiB';
	} else {
		fsize += '&#160;KiB';
	}
	htmlblk = '<tr><td id="l"><a href="http://images1.swfchan.com/'+blk+'/'+flashData[0]+'b.jpg" target="_blank"><img src="http://images1.swfchan.com/'+blk+'/'+flashData[0]+'a.jpg"></a><br></td><td';
	if (himarked) {
		htmlblk += ' id="hi"';
	}
	htmlblk += '><a href="http://swfchan.com/'+blk+'/'+flashData[0]+'/?'+ fnamefix +'">'+fname+'</a><b id="w">&#160;<a href="http://eye.swfchan.com/flash.asp?id='+flashData[0]+'&n='+fnamefix+'&w='+ width +'&h='+ height +'">[W]</a>&#160;'+fsize+'<br>';
	if (flashData.length>=6) {
		yes = readCatInfo(flashData[4]);
		no = readCatInfo(flashData[5]);
		checkIfAllUnderlined(yes);
		checkIfAllUnderlined(no);
		htmlblkc = '';
		lastwascat = false;
		for (q=0; q<2; q++) {
			for (i=0; i<categories.length; i++) {
				for (j=1; j<categories[i].length; j++) {
					catId = categories[i][j].substring(0,2);
					if (!lastwascat && j==1) {
						lastwascat = true;
					}
					change = ""
					if (q==0) {
						change = flashInCategoryListingSub(htmlblkc, yes, '<b>', '</b>', i, j, catId);
					} else {
						change = flashInCategoryListingSub(htmlblkc, no, '<i>', '</i>', i, j, catId);
						if (j==1 && change!="") {
							j = categories[i].length;
						}
					}
					if (change!="") {
						htmlblkc = change;
						lastwascat = false;
					}
				}
			}
			if (q==0 && htmlblkc.length>0) {
				htmlblk += htmlblkc.substring(2) +'.<br>';
				htmlblkc = "";
			} else if (q==1) {
				if (htmlblkc.length>0) {
					htmlblk += htmlblkc.substring(2) +'.';
				} else {
					htmlblk = htmlblk.substring(0, htmlblk.length-4);
				}
			}
		}
	}
	return htmlblk +'</b></td></tr>';
}

//--

theBestCounter = 0;
theBestSelected = false;
HH1 = HH1.replace(/8/g,"/").replace(/0/g,"=");
function clickCatLink(linkId, selection, antiSelection) {
	if (catsSent) {
		return;
	}
	selectionMade = '_'+ linkId + selection +'_';
	selectionNotMade = '_'+ linkId + antiSelection +'_';
	qindx = categorySelections.lastIndexOf(selectionNotMade);
	if (qindx!=-1 && qindx==categorySelections.length-selectionNotMade.length) {
		categorySelections = categorySelections.substring(0,qindx) + categorySelections.substring(qindx+selectionNotMade.length);
	}
	categorySelections += selectionMade;
	categorySelections = categorySelections.replace(selectionMade+selectionMade+selectionMade,selectionMade);
	categoryStatesFromString(tidySelections(categorySelections));
	theBestSelected = false;
	bestialitySelected = false;
	GEBI("catsend").disabled = true;
	for (i=0; i<categories.length; i++) {
		for (j=1; j<categories[i].length; j++) {
			cid = categories[i][j].substring(0,2);
			cstate = '-';
			for (k=0; k<categoryStates.length; k+=2) {
				if (categoryStates[k]==cid) {
					cstate = categoryStates[k+1];
					break;
				}
			}
			theColorL = '#000000';
			theColorBG = '';
			theColorBGB = '#fffaf0';
			if (cstate!='-') {
				theColorL = cstate=='y'?'#005500':'#770000';
				theColorBG = cstate=='y'?'#aaffaa':'#ffaaaa';
				theColorBGB = cstate=='y'?'#00aa00':'#aa0000';
			}
			GEBI("catBg"+cid).style.background = theColorBG;
			GEBI("catBg"+cid).style.border = "1px solid "+theColorBGB;
			GEBI("catLinkY"+cid).style.color = theColorL;
			GEBI("catLinkY"+cid).style.fontWeight = 'normal';
			if (cstate=='y') {
				GEBI("catsend").disabled = false;
				GEBI("catLinkY"+cid).style.fontWeight = 'bold';
				if (cid=='BJ') {
					theBestSelected = true;
				} else if (cid=='BY') {
					bestialitySelected = true;
				}
			}
			if (GEBI("catLinkN"+cid)!=null) {
				GEBI("catLinkN"+cid).style.color = theColorL;
				GEBI("catLinkN"+cid).style.fontWeight = 'normal';
				if (cstate=='n') {
					GEBI("catsend").disabled = false;
					GEBI("catLinkN"+cid).style.fontWeight = 'bold';
				}
			}
		}
	}
	theBestStatus();
	hadGetBestSelected = theBestSelected;
	if (bestialitySelected && !hasBestScrolled) {
		hasBestScrolled = true;
		openCatTable();
	}
}

hadGetBestSelected = false;
HH1 = HH1.replace(/1/g,".").replace(/3/g,"<").replace(/2/g," ");
function theBestStatus() {
	if (theBestSelected) {
		GEBI('theBestArea').innerHTML = "You have selected \"The best\" as one of the categories to put this flash into. <b>Because of this you<br>have to press the submit button 10 times with at least 1 second between each press (pressing too soon will lengthen the timer).</b><br>This requirement is here in order to reduce the number of flash files categorized as The best. If it is not worth 10 seconds of your life<br>it simply does not qualify as one of The best (you can instead put it in the Cool category if you wish). <b>Times pressed:</b> "+theBestCounter+"/10";
		if (!hadGetBestSelected) {
			GEBI('theBestArea').style.display = "block";
			openCatTable();
		}
		if (lock1) {
			setTimeout("lock5972 = false;", 2000);
			lock1 = false;
		}
	} else {
		GEBI('theBestArea').style.display = "none";
	}
}

catsReceived = 0;
catsSent = false;
theBestCooldown = 0;
lock1 = true;
lock5972 = true;
lock5296 = true;
lock3751 = true;
lock9825 = true;
lock71 = true;
HH1 = HH1.replace(/5/g,":").replace(/7/g,">").replace(/6/g,'"');
function submitCats() {
	okCatStr = tidySelections(categorySelections);
	if (okCatStr.length>1) {
		if (theBestCooldown!=0) {
			GEBI('catsend').value = 'Wait.';
			makeTheBestCooldown(1.5);
			return;
		}
		if (theBestSelected && theBestCounter<9) {
			theBestCounter++;
			GEBI('catsend').value = '-';
			makeTheBestCooldown(1);
			theBestStatus();
			return;
		}
		if (okCatStr.toLowerCase().indexOf('bjy')!=-1) {
			foundBJ = false;
			for (i=0; i<categoryStates.length; i+=2) {
				if (categoryStates[i]=='BJ' && categoryStates[i+1]=='y') {
					foundBJ = true;
					break;
				}
			}
			if (foundBJ && (lock1 || lock5972 || lock5296 || lock3751 || lock9825 || lock71)) {
				return;
			}
		}
		GEBI('theBestArea').style.display = "none";
		showFurryInfo(false);
		catsSent = true;
		showingCatMessageSession++;
		GEBI("catMessage").innerHTML = '';
		GEBI('catsendArea').innerHTML = GEBI('catsendArea').innerHTML;
		GEBI('catsend').disabled = true;
		doCatSending();
		GEBI('catsend').value = 'Sending...';
		setTimeout("GEBI('catsend').style.textAlign='left';GEBI('catsend').style.paddingLeft='14px';checkCatSendProgress();", 300);
	}
}

function makeTheBestCooldown(multiplier) {
	theBestCooldown++;
	setTimeout("if (theBestCooldown=="+theBestCooldown+") {theBestCooldown=0;GEBI('catsend').value = 'Submit >';}", 1000*multiplier);
	if (!lock5972 && lock5296) {
		setTimeout("lock3751 = false;", 3000);
		lock5296 = false;
	} else if (!lock3751 && lock9825) {
		setTimeout("lock71 = false;", 3000);
		lock9825 = false;
	}
}

catSendRetry = 3000;
function doCatSending() {
	if (typeof(catsReceived)!='string') {
		theJs = document.createElement('script');
		theJs.setAttribute("type","text/javascript");
		theJs.setAttribute("src", "http://eye.swfchan.net/catsaver.asp?"+xyz+"_"+catKey+"-"+ okCatStr);
		document.getElementsByTagName("head")[0].appendChild(theJs);
		setTimeout("doCatSending();", catSendRetry);
		catSendRetry *= 2;
	}
}

catSenderSpinner = new Array('|','/','-','\\');
catSendProgressStep = -1;
function checkCatSendProgress() {
	if (typeof(catsReceived)=='string' && (catSendProgressStep==-1 || catSendProgressStep>=4)) {
		GEBI('catsend').style.textAlign = "";
		GEBI('catsend').style.paddingLeft = "";
		GEBI('catsend').value = 'Saved!';
		GEBI("catMessage").style.textAlign = 'center';
		GEBI("catMessage").innerHTML = 'Thanks a lot for categorizing this flash file! &#160; Your choices will be applied to the <a href=\"http://swfchan.net/categories.shtml\" style="font-weight:normal;color:#000000;">index</a> soon.<br>You can submit another categorization for the same flash again if you think of something that should have been different.';
		flashCatBg(0);
	} else {
		catSendProgressStep++;
		GEBI('catsend').value = 'Sending... '+catSenderSpinner[catSendProgressStep%4];
		setTimeout("checkCatSendProgress();", 150);
	}
}

function flashCatBg(step) {
	if (step==0) {
		GEBI('categorizeTable').style.background = "#f0fff0";
	} else if (step==1) {
		GEBI('categorizeTable').style.background = "#f5fdf0";
	} else if (step==2) {
		GEBI('categorizeTable').style.background = "#fafcf0";
	}
	if (step==3) {
		GEBI('categorizeTable').style.background = '#fffaf0';
	} else {
		setTimeout("flashCatBg("+(step+1)+");",150);
	}
}

function netSearchTilde(step) {
	step = step>12?1:step;
	for (i=1; i<=3; i++) {
		GEBI('nstl'+i).style.color = (i!=step?"#e3e3e3":"#0000bb");
		GEBI('nstr'+i).style.color = (i!=step?"#e3e3e3":"#0000bb");
	}
	setTimeout("netSearchTilde("+(step+1)+");", 150);
}

function showTempMessage(mess) {
	GEBI('pnfo').innerHTML = mess;
	setTimeout("if (GEBI('pnfo').innerHTML=='"+GEBI('pnfo').innerHTML.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"') {GEBI('pnfo').innerHTML='';}", 1500);
}

//==

function checkForBlockedPhrases(postStr) {
	chkStr = "";
	lastC = "";
	for (iiii=0; iiii<postStr.length; iiii++) {
		c = postStr.charAt(iiii).toLowerCase();
		if (c!=lastC && isNaN(c) && ('0987654321abcdefghijklmnopqrstuvwxyz').indexOf(c)!=-1) {
			chkStr += c;
			lastC = c;
		}
	}
	blocked = ("linkbuckscom wuploadcom uploadstationcom turbobitnet alturlcom filesoniccom").split(" ");
	for (iiii=0; iiii<blocked.length; iiii++) {
		if (chkStr.indexOf(blocked[iiii])!=-1) {
			return blocked[iiii];
		}
	}
	return "";
}

function displayBlockedPhrase(phrase) {
	return (phrase+':').replace(/com\:/g,'.com:').replace(/\:/g,'');
}

function needBodyDesc(bodyTxt) {
	bbtta = (bodyTxt.toLowerCase()+" ").replace(/\n/g," ").replace(/\r/g," ").replace(/\\/g,"/").replace(/\.com /,".com/").replace(/\.org /,".org/").replace(/\.net /,".net/");
	if (bbtta.indexOf('//')!=-1) {
		return true;
	}
	bbtt = "";
	lastC = "";
	for (xij=0; xij<bbtta.length; xij++) {
		thisC = bbtta.charAt(xij);
		if ((".:/comrgnetaw").indexOf(thisC)!=-1 && (thisC=="/" || thisC=="w" || thisC!=lastC)) {
			bbtt += thisC;
			lastC = thisC;
		}
	}
	return bbtt.indexOf('.com/')!=-1 || bbtt.indexOf('.org/')!=-1 || bbtt.indexOf('.net/')!=-1 || bbtt.indexOf('magnet:')!=-1 || bbtt.indexOf('www.')!=-1;
}

function isVeryNumeric(tfName) {
	ttfName = "/"+ tfName.replace(/\\/g, "/");
	ttfName = ttfName.substring(ttfName.lastIndexOf("/")+1);
	if (ttfName.indexOf('.')!=-1) {
		ttfName = ttfName.substring(0,ttfName.lastIndexOf('.'));
	}
	ttfName = ttfName.replace(/\./g,"").replace(/,/g,"").replace(/ /g,"").replace(/_/g,"").replace(/-/g,"").replace(/\(/g,"").replace(/\)/g,"").replace(/\[/g,"").replace(/\]/g,"").replace(/{/g,"").replace(/}/g,"");
	numbs = 0;
	for (iiii=0; iiii<ttfName.length; iiii++) {
		if (!isNaN(ttfName.charAt(iiii))) {
			numbs++;
		}
	}
	return numbs/ttfName.length>0.4;
}

function verifyFileName(tfName) {
	ttfName = "/"+ tfName.toLowerCase().replace(/\\/g, "/");
	ttfName = ttfName.substring(ttfName.lastIndexOf("/")+1);
	if (ttfName.indexOf('.')==-1) {
		return "File name<br>extension missing<!>.";
	} else if (ttfName.indexOf(' ')==0) {
		return "File name can't<br>begin with space<!>.";
	} else if (ttfName.indexOf('  ')!=-1) {
		return "File name can't contain<br>two spaces after<br>each other<!>.";
	} else if (ttfName.indexOf('__')!=-1) {
		return "File name can't contain<br>two underscores after<br>each other<!>.";
	} else if (ttfName.indexOf('..')!=-1) {
		return "File name can't<br>contain \"..\"<!>.";
	} else if (ttfName.lastIndexOf(' ')==ttfName.length-1) {
		return "File name can't<br>end with space<!>.";
	} else if (ttfName.indexOf('.')==0) {
		return "File name can't<br>begin with period<!>.";
	} else if (ttfName.lastIndexOf('.')==ttfName.length-1) {
		return "File name can't<br>end with period<!>.";
	} else if (ttfName.lastIndexOf(' .')==ttfName.lastIndexOf('.')-1) {
		return "File name can't have<br>space right before<br>the extension<!>.";
	} else if (ttfName.lastIndexOf(' ')>ttfName.lastIndexOf('.')) {
		return "File name extension<br>can't contain a space<!>.";
	} else if (ttfName.indexOf('\\')!=-1 || ttfName.indexOf('/')!=-1 || ttfName.indexOf(':')!=-1 || ttfName.indexOf('*')!=-1 || ttfName.indexOf('?')!=-1 || ttfName.indexOf('"')!=-1 || ttfName.indexOf('<')!=-1 || ttfName.indexOf('>')!=-1 || ttfName.indexOf('|')!=-1) {
		return "File name contains<br>illegal characters<!>.";
	} else {
		ext = ttfName.substring(ttfName.lastIndexOf('.'));
		ttfName = ttfName.substring(0, ttfName.lastIndexOf('.'))
		if (ttfName.indexOf('.')!=-1) {
			ext2 = ttfName.substring(ttfName.lastIndexOf('.'));
			if (ext2==ext || ext2=='.jpg' || ext2=='.png' || ext2=='.gif' || ext2=='.mp3' || ext2=='.wav' || ext2=='.rar' || ext2=='.torrent' || ext2=='.swf') {
				return "File name can't end<br>with \""+ext2+ext+"\"<!>.";
			}
		}
	}
	return "";
}

function isDescriptionTooShort(descr) {
	return descr.replace(/ /g,"").replace(/,/g,"").replace(/\./g,"").length<10;
}

function fileRequireDescription(requireDescription, fileName) {
	if (requireDescription) {
		if (fileName.indexOf(".")==-1) {
			return true;
		} else {
			fExt = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
			if (fExt=="jpg" || fExt=="png" || fExt=="gif" || fExt=="mp3" || fExt=="wav") {
				return false;
			} else {
				return true;
			}
		}
	} else {
		return false;
	}
}

//==

isPosting = false;
function doPost(form) {
	if (!didSetup || isPosting) {
		return false;
	}
	if (currentTag!="") {
		setTag(currentTag);
	}
	if (form.title.value.length>100) {
		showTempMessage("Title is over<br>100 characters.");
		return false;
	}
	if (topicRequired) {
		topicLength = form.title.value.replace(/ /g,'').replace(/\./g,'').length;
		if (topicLength==0) {
			showTempMessage("A limited topic<br>is required.");
			return false;
		} else if (topicLength<5) {
			showTempMessage("Topic length<br>is too short.");
			return false;
		}
	}
	form.target = "_postframe";
	totTextLength = form.text.value.length;
	bodyLen = form.text.value.replace(/\r/g,'').replace(/\n/g,'').replace(/ /g,'').length;
	hasValue = bodyLen>0;
	if (requiredTextLength>0 && (!hasValue || totTextLength<requiredTextLength)) {
		showTempMessage("Text required:<br>"+requiredTextLength+(requiredTextLength==1?' character.':' characters.'));
		return false;
	} else if (totTextLength>maximumTextLength) {
		showTempMessage("Too much text:<br>Max "+maximumTextLength+" characters.<br>(Are "+(totTextLength-maximumTextLength)+" over.)");
		return false;
	}
	if (requireDescription && needBodyDesc(form.text.value)) {
		if (GEBI('dsc0').value=='') {
			showTempMessage("Link description<br>missing.");
			return false;
		} else if (isDescriptionTooShort(GEBI('dsc0').value)) {
			showTempMessage("Link description<br>is too short.");
			return false;
		}
	}
	inputs = form.getElementsByTagName('input');
	uppedFiles = 0;
	postStr = form.text.value;
	for (i=0;i<inputs.length;i++) {
		nn = inputs[i].name;
		postStr += "X"+ inputs[i].value;
		if (nn.length>1 && nn!='board' && nn!='thread' && nn!='nick' && nn!='mail' && nn!='postbtn' && nn!='title' && inputs[i].value.length>0) {
			hasValue = true;
		}
		if ((nn=='attachment' || nn.substring(0,nn.length-1)=='file') && inputs[i].value!='') {
			fNameChk = verifyFileName(inputs[i].value);
			if (fNameChk!="") {
				showTempMessage(fNameChk.replace('<!>',''));
				return false;
			} else {
				uplE = inputs[i].value.substring(inputs[i].value.lastIndexOf('.')+1);
				allowedE = false;
				if (nn=='attachment') {
					if (uplE.toLowerCase()=='jpg' || uplE.toLowerCase()=='png') {
						allowedE = true;
					}
				} else {
					for (j=0; j<allowedExtensions.length; j++) {
						if (uplE.toLowerCase()==allowedExtensions[j].toLowerCase()) {
							allowedE = true;
							break;
						}
					}
				}
				if (!allowedE) {
					showTempMessage("Disallowed file name<br>extension: "+ uplE);
					return false;
				}
				uplN = inputs[i].value.substring(inputs[i].value.replace(/\\/g,'/').lastIndexOf('/')+1);
				if (uplN.length>100) {
					showTempMessage("Too long file name.<br>100 char max.");
					return false;
				}
				if (fileRequireDescription(requireDescription, uplN)) {
					if (GEBI(nn+'d').value=='') {
						showTempMessage("File description<br>missing.");
						return false;
					} else if (isDescriptionTooShort(GEBI(nn+'d').value)) {
						showTempMessage("File description<br>is too short.");
						return false;
					}
				}
				if (GEBI(nn+'ua')!=null && GEBI(nn+'ua').value!='') {
					uaProb = verifyFileName(GEBI(nn+'ua').value+'.'+uplE);
					if (uaProb!='') {
						showTempMessage(uaProb.replace('<!>',''));
						return false;
					}
				}
				uppedFiles++;
			}
		}
		totTextLength += inputs[i].name.length;
		totTextLength += inputs[i].value.length;
	}
	if (requireFile && form.file1.value=='') {
		showTempMessage("File required.");
		return false;
	}
	postStrRes = checkForBlockedPhrases(postStr);
	if (postStrRes.length!=0) {
		showTempMessage("String not allowed:<br>\""+displayBlockedPhrase(postStrRes)+"\"");
		return false;
	}
	if (hasValue && (GEBI("tf").value.length==0 || bodyLen>0)) {
		isPosting = true;
		saveNickMail();
		recovryStr = "";
		if (GEBI('tf').value.length>0) {
			recovryStr += escape(GEBI('tf').value);
			if (form.text.value.length>0) {
				recovryStr += "$BDNUYAFAKUGE$";
			}
		}
		if (form.text.value.length>0) {
			recovryStr += escape(form.text.value.replace(/\r\n/g,'\n').replace(/\r/g,'\n').replace(/\n/g,'$JNIUTGSHVTYREWDC$'));
		}
		if (recovryStr!="") {
			if (recoveryData.indexOf("$OIYHSIUFFST$")!=-1) {
				recoveryData = recoveryData.substring(0,recoveryData.indexOf("$OIYHSIUFFST$"));
			}
			recovryStr = recoveryData +"$MOAHWEUYFAX$"+ recovryStr;
			while (recovryStr.split('$MOAHWEUYFAX$').length>5) {
				recovryStr = recovryStr.substring(recovryStr.indexOf('$MOAHWEUYFAX$')+13);
			}
			doSave("recvry", recovryStr, 3600);
		}
		uppedFiles--;
		bonusAdd = minimumUploadRoof*uppedFiles;
		form.action = "http://eye.swfchan.org:40/?"+ (minimumUploadRoof+totTextLength+bonusAdd+3072);
		document.domain="swfchan.org";
		progressCooldown(900);
		postingDotDotDot(0);
		form.postbtn.disabled = true;
		if (doLoad("maycap")=="") {
			GEBI('pnotice').style.overflow = "hidden";
			GEBI('pnotice').style.height = "2px";
			GEBI('pnotice').style.display = "block";
			GEBI('pnotice').innerHTML = '<table cellspacing="0" width="100%"><tr><td style="padding-top:7px;font-size:11px;font-weight:bold;color:#000055;" align="right">Note: You may have to enter a captcha after submission.</td></tr></table>';
			for (i=1;i<=12;i++) {
				setTimeout("GEBI('pnotice').style.height = '"+(2+(i*2))+"px';", i*10);
			}
			doSave('maycap', 'n', 126000);
		}
		return true;
	} else if (GEBI("tf").value.length>0) {
		showTempMessage("Can't post<br>just a title.");
	} else {
		showTempMessage("Nothing to post.");
	}
	return false;
}

function saveNickMail() {
	doSave("pnick", GEBI('pnick').value, 604800);
	if (GEBI('pmail').value.indexOf('@')!=-1) {
		doSave("pmail", GEBI('pmail').value, 604800);
	} else {
		doSave("pmail", "", 604800);
	}
}

function postingDotDotDot(stage) {
	if (!showingProgress) {
		if (stage==0) {
			GEBI('pnfo').innerHTML = "<b>Posting</b>";
		} else if (stage==1) {
			GEBI('pnfo').innerHTML = "<b>Posting.</b>";
		} else if (stage==2) {
			GEBI('pnfo').innerHTML = "<b>Posting..</b>";
		} else if (stage==3) {
			GEBI('pnfo').innerHTML = "<b>Posting...</b>";
		}
		if (stage<4) {
			setTimeout("postingDotDotDot("+(stage+1)+");", 1000);
		}
	}
}

postIsDone = false;
function postDone(progInfo) {
	if (!postIsDone && isPosting) {
		postIsDone = true;
		setTimeout("document.location.href='http://eye.swfchan.org/post.asp';",250);
		if (!showingProgress) {
			progInfo = progInfo.split('/;\\');
			theword = "Done!";
			if (progInfo[0]*1!=progInfo[1]*1) {
				theword = "Failed.";
			}
			showingProgress = true;
			if (GEBI('pnfo').innerHTML.indexOf('..')!=-1) {
				GEBI('pnfo').innerHTML += "<br><b>"+theword+"</b>";
			} else {
				GEBI('pnfo').innerHTML = "<b>Posting:<br>"+theword+"</b>";
			}
		}
	}
}

function oneDecNumber(numb) {
	numb = (""+numb).replace(",",".");
	if (numb.indexOf(".")==-1) {
		numb += ".0";
	}
	return numb;
}

function bytesToUnit(bytes) {
	numb = 0;
	unit = "";
	if (bytes<1000) {
		return bytes + " b";
	} else if (bytes<1024000) {
		numb = Math.round((bytes/1024)*10)/10;
		unit = "KiB";
	} else {
		numb = Math.round((bytes/1024/1024)*10)/10;
		unit = "MiB";
	}
	return oneDecNumber(numb) +" "+ unit;
}

theBytesLoaded = 0;
theBytesTotal = 0;
theBytesPerSecond = 0;
showingProgress = false;
progUpdates = 0;
upprogstamp = null;
function updateProgress(progInfo) {
	progInfo = progInfo.split('/;\\');
	nybytespersecond = theBytesPerSecond;
	if (progInfo[3]=='x') {
		nybytespersecond = progInfo[2]*1;
	}
	nyloaded = progInfo[0]*1;
	if (nyloaded<theBytesLoaded) {
		skillnad = (theBytesLoaded-nyloaded)/theBytesPerSecond;
		theBytesLoaded = nyloaded + skillnad*nybytespersecond;
	} else {
		theBytesLoaded = nyloaded;
	}
	theBytesTotal = progInfo[1]*1;
	theBytesPerSecond = nybytespersecond;
	if (progUpdates<3) {
		progressCooldown(1500);
		progUpdates++;
	} else {
		progressCooldown(3000);
	}
	if (!showingProgress && theBytesPerSecond!=0 && theBytesLoaded!=0) {
		upprogstamp = new Date().getTime();
		showingProgress = true;
		showProgress();
	}
}

function showProgress() {
	nu = new Date().getTime();
	tid = nu-upprogstamp;
	upprogstamp = nu;
	if (tid>0) {
		theBytesLoaded += Math.round((theBytesPerSecond*(tid/1000)));
	}
	if (postIsDone || theBytesLoaded>theBytesTotal) {
		theBytesLoaded = theBytesTotal;
	}
	GEBI('pnfo').innerHTML = bytesToUnit(theBytesLoaded) +" / "+ bytesToUnit(theBytesTotal) +"<br>"+ oneDecNumber(Math.round((theBytesLoaded/theBytesTotal)*1000)/10) +"% ("+bytesToUnit(theBytesPerSecond)+"/s)";
	if (!postIsDone) {
		setTimeout("showProgress();", 100);
	}
}

function checkProgress() {
	if (!postIsDone) {
		GEBI('progframe').src = "about:blank";
		GEBI('progframe').src = "http://eye.swfchan.org/post.asp?progress"+ Math.random();
		progressCooldown(8000);
	}
}

cooldownId = 0;
function progressCooldown(timerr) {
	cooldownId++;
	setTimeout("if ("+cooldownId+"==cooldownId){checkProgress();}", timerr);
}

function includeAttachment() {
	GEBI('attachl').innerHTML = '';
	GEBI('notess').innerHTML = "<br><b>+</b> An attachment must be relevant to the thread's <b>flash file</b> (not just OP's request, current discussion or whatever) else it will be deleted.<br><br><b>+</b> Uploading unrelated attachments <b>might get you banned</b> (examples: misc pictures that contain some kind of text overlay or \"my face when\" type of images -- those are not welcome on this particular board).<br><br><b>+</b> The main flash boards on swfchan.org may be considered text-only (except for the swf file), <b>the attachment feature is there primarily to enable you to post screenshots of your highscores etc.</b><br><br><b>+</b> Attachments are never automatically deleted from the server so that they always can be viewed from archived threads on swfchan.net.<br><br><b>+</b> Uploaded image attachments that are bigger than 75 KiB are remade with reduced quality to make them small enough. PNG images will be converted into JPG when shrunk. Should you wish for a lossless upload the image must already be below 75 KiB when you post it.<br>";
	GEBI('attach').style.display = "block";
}

function testMode() {  //used for debugging
	return document.location.href.toLowerCase().indexOf('testmode')!=-1;
}

minimumUploadRoof = 1073741824;
requiredTextLength = 0;
maximumTextLength = 1073741824;
allowedExtensions = ("JPG, PNG").split(", ");
recoveryData = "";
didSetup = false;
firstBodyChange = true;
requireFile = false;
requireDescription = false;
currentTag = "";
topicRequired = false;
didEnterCombo = false;
function formSetup(miniroof, reqtextlen, maxtextlen, okext, reqfile, reqdesc) {
	minimumUploadRoof = miniroof;
	requiredTextLength = reqtextlen;
	maximumTextLength = maxtextlen;
	allowedExtensions = okext.split(", ");
	requireFile = reqfile;
	requireDescription = reqdesc;
	GEBI('postform').postbtn.disabled = false;
	GEBI('minmax').style.display = "none";
	i = 1;
	while (GEBI('ff'+i)!=null) {
		GEBI('ff'+i).value = "";
		GEBI('ff'+i).onchange = function(e) {
			myI = this.name.substring(this.name.length-2);
			if (isNaN(myI.substring(0,1))) {
				myI = myI.substring(1);
			}
			myI *= 1;
			if (isVeryNumeric(this.value) && verifyFileName(this.value)=="") {
				suggest = "/"+ this.value.replace(/\\/g,"/");
				suggest = suggest.substring(suggest.lastIndexOf("/")+1);
				suggest = suggest.substring(0,suggest.lastIndexOf('.'));
				fil1n = ('.x'+ GEBI('ff1').value).toLowerCase();
				fil1n = fil1n.substring(fil1n.lastIndexOf('.')+1);
				if (fil1n=='jpg' || fil1n=='png' || fil1n=='gif') {
					suggest = sugName(suggest);
				}
				GEBI('uas'+myI).innerHTML = '<div class="uas" align="right"><table cellspacing="0"><tr><td id="ll">Upload as: </td><td id="mm"><input value="'+suggest+'" type="text" name="uploadas'+myI+'" title="In an attempt to avoid (discourage) numerical file names you can specify a different file name to use here. If blank the original file name is used." id="file'+myI+'ua"></td><td id="rr">'+this.value.substring(this.value.lastIndexOf('.'))+'</td></tr></table></div>';
				GEBI('uas'+myI).style.display = "block";
				if (GEBI('desk'+myI)==null || fileRequireDescription(true, this.value)==false) {
					setTimeout("GEBI('file"+myI+"ua').select();",200);
				}
			} else {
				GEBI('uas'+myI).innerHTML = '';
				GEBI('uas'+myI).style.display = "none";
			}
			if (GEBI('desk'+myI)!=null) {
				if (fileRequireDescription(true, this.value)) {
					GEBI('desk'+myI).style.display = "block";
					setTimeout("GEBI('file"+myI+"d').select();",200);
				}
			}
			if (GEBI('fi'+(myI+1))!=null) {
				GEBI('fi'+(myI+1)).style.display = "block";
			}
			if (myI==2 && !didEnterCombo) {
				fil1n = ('.x'+ GEBI('ff1').value).toLowerCase();
				fil2n = ('.x'+ GEBI('ff2').value).toLowerCase();
				fil1n = fil1n.substring(fil1n.lastIndexOf('.')+1);
				fil2n = fil2n.substring(fil2n.lastIndexOf('.')+1);
				if ((fil1n=='jpg' || fil1n=='png' || fil1n=='gif') && fil2n!='jpg' && fil2n!='png' && fil2n!='gif' && GEBI('postform').mail.value=='') {
					GEBI('postform').mail.value = 'combo';
					didEnterCombo = true;
				}
			}
		}
		if (GEBI('desk'+i)!=null) {
			GEBI('file'+i+'d').title = "A description of the file you're sharing, keywords/tags are encouraged. Tips: Genre(s), language, content (generally and highlights).";
			GEBI('file'+i+'d').value = "";
			GEBI('desk'+i).style.display = "none";
		}
		GEBI('uas'+i).style.display = "none";
		if (i>1) {
			GEBI('fi'+i).style.display = "none";
		}
		i++;
	}
	if (GEBI('desk0')!=null) {
		GEBI('dsc0').title = "A description of all the links you're sharing (keywords/tags are encouraged).";
		GEBI('dsc0').value = "";
		GEBI('desk0').style.display = "none";
		deskTime();
	}
	if (GEBI('attach')!=null) {
		GEBI('attach').style.display = "none";
		GEBI('attachl').innerHTML = '<div align="right"><a href="javascript:includeAttachment();">Include an attachment...</a></div>';
		GEBI('attachField').value = "";
	}
	GEBI('pnick').value = doLoad("pnick");
	GEBI('pnick').onkeyup = function() {
		saveNickMail();
	}
	GEBI('pnick').onchange = function() {
		saveNickMail();
	}
	GEBI('pmail').value = doLoad("pmail");
	GEBI('pmail').onkeyup = function() {
		saveNickMail();
	}
	GEBI('pmail').onchange = function() {
		saveNickMail();
	}
	recoveryData = doLoad("recvry").replace(/\$OIYHSIUFFST\$/g,"$MOAHWEUYFAX$");
	if (recoveryData!="") {
		GEBI('pnfo').innerHTML = '<table cellspacing="0" id="recover"><tr><td><a href="javascript:seeOldPosts();">Recover</a> <a href="javascript:clearOldPosts();" id="clear">[x]</a></td></tr></table>';
	}
	GEBI('txt').onchange = function(e) {
		saveOut(true);
		checkForQuotes();
	}
	GEBI('txt').onkeyup = function(e) {
		saveOut(true);
		checkForQuotes();
	}
	if (document.location.href.indexOf('?')!=-1) {
		quo = document.location.href.substring(document.location.href.indexOf('?')+1);
		if (quo.indexOf('#')!=-1) {
			quo = quo.substring(0, quo.indexOf('#'));
		}
		if (!isNaN(quo) && GEBI('txt').value.indexOf('>>'+quo)==-1) {
			doQuote(quo);
		}
	}
	doCheckForQuotes();
	if (GEBI('postform').board!=null) {
		if (GEBI('postform').board.value=='fap') {
			GEBI('belowta').innerHTML = '<div align="right"><table cellspacing="0"><tr><td><input type="radio" name="tag" id="tagx" style="width:20px;" onfocus="setTag(\'X\');" checked></td><td><label for="tagx">&#160;No tag</label> &#160; </td><td><input type="radio" name="tag" id="tagg" style="width:20px;" onfocus="setTag(\'G\');"></td><td><label for="tagg" title="(note: only next/previous buttons doesn\'t make a game)">&#160;Is a hentai game</label></td></tr></table></div>';
			GEBI('belowta').style.display = "block";
		} else if (GEBI('postform').board.value=='swf') {
			GEBI('belowta').innerHTML = '<div align="right"><table cellspacing="0"><tr><td><input type="radio" name="tag" id="tagx" style="width:20px;" onfocus="setTag(\'X\');" checked></td><td><label for="tagx">&#160;No tag</label> &#160; </td><td><input type="radio" name="tag" id="tagl" style="width:20px;" onfocus="setTag(\'L\');"></td><td><label for="tagl" title="(note: must have moving visuals)">&#160;Is a flash loop with music</label></td></tr></table></div>';
			GEBI('belowta').style.display = "block";
		} else if (GEBI('postform').board.value=='res') {
			topicRequired = true;
			GEBI('titleTxt').innerHTML = 'Topic';
			GEBI('tf').title = 'The thread topic must not be too broad, focus on a subject. What specific files should be shared in this thread?';
		}
		currentTag = "X";
		GEBI('postform').title.onkeyup = function() {tagging();}
		GEBI('postform').title.onchange = function() {tagging();}
		GEBI('postform').text.onkeyup = function() {tagging();}
		GEBI('postform').text.onchange = function() {tagging();}
	}
	didSetup = true;
}

isTagging = false;
function tagging() {
	if (!isTagging) {
		setTimeout("isTagging=false;setTag(currentTag);", 1000);
		isTagging = true;
	}
}

function setTag(t) {
	ttit = GEBI('postform').title;
	ttex = GEBI('postform').text;
	leftTrim(ttit, ttex);
	if (t=='X' || (ttit.value.length>0 && ttit.value.indexOf("["+t+"]")!=0) || (ttit.value.length==0 && ttex.value.indexOf("["+t+"]")!=0)) {
		while (ttit.value.indexOf("[")==0 && ttit.value.indexOf("]")==2) {
			ttit.value = ttit.value.substring(3);
			leftTrim(ttit, ttex);
		}
		while (ttex.value.indexOf("[")==0 && ttex.value.indexOf("]")==2) {
			ttex.value = ttex.value.substring(3);
			leftTrim(ttit, ttex);
		}
		if (t!='X') {
			if (ttit.value.length>0) {
				ttit.value = "["+t+"] " + ttit.value;
			} else {
				ttex.value = "["+t+"] " + ttex.value;
			}
		}
	}
	currentTag = t;
}

function leftTrim(ttit, ttex) {
	while (ttit.value.charAt(0)==' ') {
		ttit.value = ttit.value.substring(1);
	}
	while (ttex.value.charAt(0)==' ') {
		ttex.value = ttex.value.substring(1);
	}
}

longIdent = "";
shortIdent = "";
function sugName(baseName) {
	threadId = "0";
	if (GEBI('postform').thread!=null) {
		threadId = GEBI('postform').thread.value;
	}
	oBaseName = baseName;
	baseName = "";
	notNumbers = 0;
	for (i=0; i<oBaseName.length; i++) {
		c = oBaseName.charAt(i);
		if (isNaN(c)) {
			notNumbers++;
			if (notNumbers==4) {
				return oBaseName;
			}
		} else {
			baseName += c;
		}
	}
	while (baseName.length>1 && baseName.charAt(0)=='0') {
		baseName = baseName.substring(1);
	}
	if (baseName.length>4) {
		if (longIdent!="") {
			return longIdent+"_"+oBaseName;
		}
		genIdent = "";
		if (threadId!="0") {
			genIdent = doLoad("gI"+threadId);
		}
		if (threadId!="0" && genIdent=='') {
			genIdent = doLoad("gI0");
			if (genIdent!='') {
				doSave("gI0", "", 2);
			}
		}
		if (genIdent=='') {
			genIdent = getNewPostingIdent();
		}
		doSave("gI"+threadId, genIdent, 28800);
		if (doLoad("gI"+threadId)==genIdent) {
			longIdent = genIdent;
			return longIdent+"_"+oBaseName;
		}
	} else {
		if (shortIdent!="" && shortIdentN<baseName) {
			shortIdentN = baseName;
			return shortIdent+"_"+oBaseName;
		}
		baseName *= 1;
		postingIdent = "";
		postingNumber = "";
		if (threadId!="0") {
			postingIdent = doLoad("pI"+threadId);
			postingNumber = doLoad("pN"+threadId);
		}
		if (threadId!="0" && (postingIdent=='' || postingNumber=='')) {
			postingIdent = doLoad("pI0");
			postingNumber = doLoad("pN0");
			if (postingIdent!='' || postingNumber!='') {
				doSave("pI0", "", 2);
				doSave("pN0", "", 2);
			}
		}
		if (postingIdent=='' || postingNumber=='') {
			postingIdent = getNewPostingIdent();
		} else {
			postingNumber = postingNumber*1;
			if (postingNumber>=baseName) {
				postingIdent = getNewPostingIdent();
			}
		}
		doSave("pI"+threadId, postingIdent, 28800);
		doSave("pN"+threadId, ""+baseName, 28800);
		if (doLoad("pI"+threadId)==postingIdent) {
			shortIdent = postingIdent;
			shortIdentN = postingNumber;
			return shortIdent+"_"+oBaseName;
		}
	}
	return oBaseName;
}

function getNewPostingIdent() {
	pI = "";
	for (i=0;i<6;i++) {
		pI+=alphab.charAt(10+Math.floor(26*Math.random()));
	}
	return pI.toUpperCase();
}

function deskTime() {
	GEBI('desk0').style.display = needBodyDesc(GEBI('txt').value)?'block':'none';
	setTimeout("deskTime();",300);
}

oldOut = "";
function saveOut(fromEvent) {
	if (!fromEvent || firstBodyChange) {
		firstBodyChange = false;
		nyOut = GEBI('tf').value +"$BDNUYAFAKUGE$"+ GEBI('txt').value;
		if (!fromEvent && oldOut!=nyOut && !isPosting) {
			oldOut = nyOut;
			if (nyOut.indexOf("$BDNUYAFAKUGE$")==0) {
				nyOut = nyOut.substring(14);
			}
			nyOut = "$OYXMXUGAD$"+nyOut;
			if (recoveryData.indexOf("$OIYHSIUFFST$")==-1) {
				recoveryData += "$OIYHSIUFFST$"+ nyOut;
			} else {
				recoveryData = recoveryData.substring(0,recoveryData.indexOf("$OIYHSIUFFST$")) +"$OIYHSIUFFST$"+ nyOut;
			}
			doSave("recvry", recoveryData, 3600);
		}
		setTimeout("saveOut(false);", 1500);
	}
}

function seeOldPosts() {
	if (GEBI('oldposts').innerHTML.length>1) {
		GEBI('oldposts').innerHTML = "";
	} else {
		visa = unescape(recoveryData).replace('<','&lt;').replace('>','&gt;').replace(/\$BDNUYAFAKUGE\$/g,'<br><br>').replace(/\$JNIUTGSHVTYREWDC\$/g,'<br>');
		if (visa.indexOf("$OIYHSIUFFST$")==0 || visa.indexOf("$MOAHWEUYFAX$")==0) {
			visa = visa.substring(13);
		}
		GEBI('oldposts').innerHTML = "<div>"+ visa.replace(/\$MOAHWEUYFAX\$/g,'<br><br><hr><br>').replace(/\$OIYHSIUFFST\$/g,'<br><br><hr><br>').replace(/\$OYXMXUGAD\$/g,"<b>(not posted)</b> ") +"</div><br>";
	}
}

function clearOldPosts() {
	doSave("recvry", "", 60);
	GEBI('pnfo').innerHTML = '';
	recoveryData = "";
}

function doLoad(id) {
	cocontnt = document.cookie.split(";");
	for (i=0; i<cocontnt.length; i++) {
		if (cocontnt[i].indexOf(id+"=")!=-1 && cocontnt[i].indexOf(id+"=")<cocontnt[i].indexOf('=')) {
			return unescape(cocontnt[i].substring(cocontnt[i].indexOf(id+"=")+id.length+1));
		}
	}
	return "";
}

function doSave(id, str, timeSeconds) {
	codate = new Date();
	codate.setTime(codate.getTime()+(timeSeconds*1000));
	document.cookie = id+"="+escape(str)+"; expires="+codate.toGMTString()+"; path=/";
}

woxtra='';
function imp(force) {
	expandMargin();
	if (force) {
		GEBI('warea').innerHTML = '<iframe src="http://eye.swfchan.org/worker/?'+woxtra+(Math.round(Math.random()*1000000))+'" width="1" height="1"></iframe>';
	} else if (Math.random()<0.1) {
		setTimeout("if (GEBI('warea').innerHTML.length<5) {imp(true);}",2500);
	}
	setTimeout("imgHook();",1);
}

function postPage(hasc, progInfo) {
	if (hasc) {
		woxtra = 'post';
		imp(true);
	}
	try {
		document.domain="swfchan.org";
		if (window.top.location.href!=location.href && typeof(window.parent.postDone)=="function") {
			window.parent.postDone(progInfo);
		}
	} catch(e) {}
}

anchored = -1;
expandedMargin = false;
function expandMargin() {
	if (!expandedMargin && document.location.href.indexOf('#')!=-1) {
		anchored = 0;
		adjustBottom();
		setTimeout("adjustBottom();",250);
		reAnchor();
		expandedMargin = true;
		setTimeout("anchored=-200;",3500);
	} else if (anchored==-1) {
		anchored = -2;
		setTimeout("anchored=-100;",200);
		setTimeout("anchored=-200;",3500);
	}
}

function adjustBottom() {
	mmm = Math.round(document.body.clientHeight*0.5);
	if (GEBI("yard")!=null) {
		mmm -= GEBI("yard").offsetHeight;
	}
	if (mmm>0) {
		if (GEBI("yard")!=null) {
			GEBI("yard").style.marginTop = mmm+"px";
			document.body.style.marginBottom = "";
		} else {
			document.body.style.marginBottom = mmm+"px";
		}
	} else {
		GEBI("yard").style.marginTop = "";
		document.body.style.marginBottom = "";
	}
}

anchCnt = 0;
function reAnchor() {
	if (document.location.href.indexOf('#')!=-1) {
		if (GEBI('p'+document.location.href.substring(document.location.href.indexOf('#')+1))!=null) {
			adjustBottom();
			document.location.replace(document.location.href +'!');
			setTimeout("document.location.replace(document.location.href.substring(0,document.location.href.length-1));",50);
			anchCnt++;
		}
		if (anchCnt<3) {
			setTimeout("reAnchor();",300);
		} else {
			anchored = 1;
		}
	}
}

imagesHooked = 0;
imagesHookedSame = 0;
imageClicked = null;
toppKant = 0;
toppKantSame = 0;
imagesPH = 0;
imagesPHDone = 0;
lastPostClicked = 0;
firstBatch = true;
doneOne = false;
function imgHook() {
	expandMargin();
	if (imagesHooked<1500) {
		if (imagesHooked==document.images.length) {
			imagesHookedSame++;
		} else {
			for (i=document.images.length-1; i>=imagesHooked; i--) {
				isrc = document.images[i].src;
				if (isrc.charAt(isrc.length-4)=='.' && !isNaN(isrc.charAt(isrc.length-5)) && isrc.charAt(isrc.length-9)=='.') {
					document.images[i].osrc = isrc;
					document.images[i].oid = ''+document.images[i].id;
					isLoaded = false;
					if (typeof document.images[i].naturalWidth=="number") {
						isLoaded = document.images[i].naturalWidth!=0;
					} else if (typeof document.images[i].complete=="boolean") {
						isLoaded = document.images[i].complete;
					}
					if (!isLoaded) {
						current = document.images[i];
						yy = 0;
						do {
							yy += current.offsetTop;
							current = current.offsetParent;
						} while (current!=null);
						if (document.location.href.indexOf('#')!=-1 || yy>document.body.clientHeight+150) {
							if (isrc.charAt(isrc.length-5)=='2') {
								document.images[i].src = "http://swfchan.org/phb.png?placeholder";
							} else {
								document.images[i].src = "http://swfchan.org/pha.png?placeholder";
							}
							imagesPH++;
						}
					}
					document.images[i].dwn = false;
					document.images[i].zoom = false;
					document.images[i].onmousedown = function(e) {
						imageClicked = this;
						this.dwn = true;
						leftClick = false;
						if (e==undefined){
							leftClick = event.button==1;
						}else{
							leftClick = e.button==0;
						}
						if (leftClick) {
							setTimeout("if (imageClicked.dwn) {imageClicked.dwn=false;if (imageClicked.zoom) {imageClicked.zoom=false;imageClicked.src=imageClicked.osrc;imageClicked.id=imageClicked.oid;} else {imageClicked.zoom=true;imageClicked.src=imageClicked.osrc.substring(0,imageClicked.osrc.length-5)+'1'+imageClicked.osrc.substring(imageClicked.osrc.length-4);imageClicked.id='zzz';}}", 150);
						}
					}
					document.images[i].onclick = function(e) {
						if (this.dwn) {
							this.dwn = false;
						} else {
							return false;
						}
					}
				}
			}
			imagesHooked = document.images.length;
			if (GEBI('org')!=null && GEBI('mr')!=null) {
				trs = document.getElementsByTagName('tr');
				for (i=0;i<trs.length;i++) {
					if ((trs[i].id+'x').substring(0,1)=='p' && !isNaN(trs[i].id.substring(1))) {
						children = trs[i].childNodes;
						for (j=0; j<children.length; j++) {
							if (children[j].id=="mr") {
								children[j].postId = trs[i].id.substring(1);
								children[j].onclick = function() {
									lastPostClicked = this.postId*1;
									setTimeout("highlightPostWork();",10);
								}
								j = 9999;
							}
						}
					}
				}
			}
		}
	}
	if (imagesPHDone<imagesPH) {
		if (toppKant==document.body.scrollTop) {
			toppKantSame++;
		} else {
			doneOne = false;
			toppKantSame = 0;
		}
		toppKant = document.body.scrollTop;
		if ((anchored==1 || anchored<=-100) && (toppKant>50 || anchored<=-200) && (firstBatch || ((toppKantSame>15 && !doneOne) || (imagesHookedSame>750 && toppKantSame>1 && !doneOne)))) {
			doneOne = true;
			nerKant = toppKant+document.body.clientHeight;
			forceL = firstBatch ? 30 : 0;
			if (toppKant>document.body.clientHeight*1.1) {
				forceL = 0;
			}
			for (i=0; i<document.images.length; i++) {
				if (document.images[i].src.indexOf('.png?placeholder')!=-1) {
					if (forceL>0) {
						document.images[i].src = document.images[i].osrc;
						forceL--;
						imagesPHDone++;
					} else {
						current = document.images[i];
						yy = 0;
						do {
							yy += current.offsetTop;
							current = current.offsetParent;
						} while (current!=null);
						if (yy<nerKant+document.body.clientHeight*1.25 && yy+120>toppKant) {
							document.images[i].src = document.images[i].osrc;
							if (yy>toppKant+document.body.clientHeight*0.4) {
								forceL = 8;
							}
							imagesPHDone++;
						}
					}
				}
			}
			firstBatch = false;
		}
	}
	if (imagesHookedSame>750) {
		if (imagesPHDone<imagesPH) {
			setTimeout("imgHook();",300);
		} else {
			setTimeout("imgHook();",500);
		}
	} else if (imagesHookedSame>500) {
		setTimeout("imgHook();",40);
	} else {
		setTimeout("imgHook();",1);
	}
	highlightPostWork();
}

previousAnchor = "0";
postHistory = new Array();
function highlightPostWork() {
	anchorNow = "0";
	if (document.location.href.indexOf('#')!=-1) {
		anchorNow = document.location.href.substring(document.location.href.indexOf('#')+1).replace('!','');
	}
	if (anchorNow!=previousAnchor) {
		if (previousAnchor!="0" && GEBI('p'+previousAnchor)!=null) {
			doHighlightPost(previousAnchor, "", "", "", false);
			previousAnchor = "0";
		}
		if (GEBI('p'+anchorNow)!=null) {
			doHighlightPost(anchorNow, "#ddcc55", "#ffee99", "#ffe588", true);
			previousAnchor = anchorNow;
			if (lastPostClicked!=0) {
				if (postHistory.length==0 || postHistory[postHistory.length-1]!=lastPostClicked) {
					postHistory.push(lastPostClicked);
				}
				lastPostClicked = 0;
			}
			if (postHistory.length==0 || postHistory[postHistory.length-1]!=anchorNow*1) {
				postHistory.push(anchorNow*1);
			}
		} else if (anchorNow=="0" || isNaN(anchorNow)) {
			previousAnchor = "0";
		}
	}
}

function doHighlightPost(postNumber, leftBg, leftTx, rightBg, addOnClick) {
	isCombo = false;
	children = GEBI('p'+postNumber).childNodes;
	for (i=0; i<children.length; i++) {
		if (children[i].id=="m1" || children[i].id=="m2") {
			children[i].style.background = leftBg;
			children[i].style.color = leftTx;
			if (addOnClick) {
				children[i].onclick = function() {
					dloc = document.location.href;
					if (dloc.indexOf('#')!=-1) {
						dloc = dloc.substring(0,dloc.indexOf('#'));
					}
					postHistory.pop();
					if (postHistory.length>0) {
						phpop = postHistory.pop();
						if (phpop==-999) {
							if (postHistory.length==0) {
								document.location.href = dloc +"#0";
								scrollToForm();
							} else {
								document.location.href = dloc +"#"+ postHistory.pop();
								setTimeout("scrollToForm();",20);
								setTimeout("scrollToForm();",100);
							}
						} else {
							document.location.href = dloc +"#"+ phpop;
						}
					} else {
						document.location.href = dloc +"#0";
					}
					setTimeout("highlightPostWork();",10);
				}
			} else {
				children[i].onclick = function() {}
			}
		} else if (children[i].id == "mr") {
			children[i].style.background = rightBg;
			kids = children[i].childNodes;
			for (k=0; k<kids.length; k++) {
				if (kids[k].className=='comb1') {
					isCombo = true;
					break;
				}
			}
		}
	}
	if (isCombo) {
		nextPost = ''+((postNumber*1)+1);
		if (GEBI('p'+nextPost)!=null) {
			doHighlightPost(nextPost, leftBg, leftTx, rightBg, addOnClick);
		}
	}
}

postStatus = "";
postStatusReceived = false;
function updatePostStatus(message) {
	postStatus = message;
	postStatusReceived = true;
}

function checkPostStatus() {
	document.domain="swfchan.org";
	setTimeout("checkPostStatus2();", 1000);
}

function checkPostStatus2() {
	GEBI('postStatus').innerHTML = "<br><b>Checking post status...</b>";
	GEBI('postStatus').style.display = "block";
	setTimeout("postStatusChecker();", 1000);
	setTimeout("doCheckPostStatus();", 4000);
}

checkCount = 0;
function doCheckPostStatus() {
	postStatusReceived = false;
	if (postStatus.indexOf("!OK!")==0 || postStatus.indexOf("!NO!")==0) {
		GEBI('postStatus').innerHTML = "<br>"+postStatus.substring(4);
	} else {
		GEBI('postStatus').innerHTML = "<br><b><b>.....checking.....</b></b><br>"+ postStatus +'<iframe src="status.asp?post'+Math.random()+'" width="1" height="1"></iframe>';
		postStatusChecker();
		setTimeout("doCheckPostStatus();", 6000);
		checkCount++;
		if (checkCount%3==0) {
			imp(true);
		}
	}
}

function postStatusChecker() {
	if (postStatusReceived) {
		if (postStatus.indexOf("!OK!")==0 || postStatus.indexOf("!NO!")==0) {
			GEBI('postStatus').innerHTML = "<br>"+postStatus.substring(4);
		} else {
			GEBI('postStatus').innerHTML = "<br>"+ postStatus;
		}
	} else {
		setTimeout("postStatusChecker();", 300);
	}
}

lastPreviewUrl = "";
lastPreviewPid = 0;
previewing = 0;
function doPreview(purl, pid) {
	if (lastPreviewUrl==purl) {
		lastPreviewUrl = "";
		lastPreviewPid = 0;
	} else {
		if (lastPreviewUrl!="") {
			doPreview(lastPreviewUrl, lastPreviewPid);
		}
		lastPreviewUrl = purl;
		lastPreviewPid = pid;
	}
	if (GEBI('preva'+pid).innerHTML.length>1) {
		previewing--;
		GEBI('preva'+pid).style.display = 'none';
		GEBI('preva'+pid).innerHTML = '';
		GEBI('scr'+pid).style.display = 'block';
	} else {
		previewing++;
		GEBI('preva'+pid).innerHTML = '<div id="prevatop'+pid+'" style="width:740px;height:24px;background:#ffda77;"></div><div id="prevabot'+pid+'"></div>';
		GEBI('preva'+pid).style.display = 'block';
		wavfor = new Image(); 
		wavfor.pid = pid;
		wavfor.onload = function() {
			if (GEBI("prevabot"+this.pid)!=null) {
				oncl = "this.style.width=this.offsetWidth+'px';if((''+this.style.height).indexOf('50')==-1){this.style.height='50px';}else{this.style.height='100px';}";
				GEBI("prevabot"+this.pid).innerHTML = '<table id="wf" cellspacing="0"><tr><td width="51"></td><td><img src="'+this.src+'" style="width:100%;height:50px;" onclick="'+oncl+'" id="wavf'+pid+'"><br></td><td width="45"></td></tr></table>';
			}
		}
		dblExt = purl.substring(purl.length-8).toLowerCase();
		if (dblExt=='.mp3.mp3' || dblExt=='.wav.mp3') {
			wavfor.src = purl.substring(0,purl.length-4)+'2.jpg';
		} else {
			wavfor.src = purl+'2.jpg';
		}
		setTimeout("GEBI('prevatop"+pid+"').innerHTML = '<table cellspacing=\"0\" style=\"width:740px;height:24px;\"><tr><td style=\"padding:0;background:#ffee99;\"><embed src=\"http://swfchan.org/mp3player.swf?soundFile="+encodeURI(encodeURI(decodeURI(purl))).replace(/,/g,'%252C').replace(/&/g,'%2526').replace(/'/g,'%2527')+"&autostart=yes&loop=yes&bg=0xffee99&leftbg=0xffda77&rightbg=0xffda77&rightbghover=0xffda77&lefticon=0xcc7700&righticon=0xcc7700&righticonhover=0xcc7700&skip=0xcc7700&text=0xbb6600&loader=0xffda77&track=0xffee99&border=0xcc7700&tracker=0xffcc55&voltrack=0xffda77&volslider=0xcc7700\" wmode=\"transparent\" style=\"width:740px;height:24px;\"></embed></td></tr></table>';",250);
		waveform = new Image(); 
		waveform.pid = pid;
		waveform.onload = function() {
			if (GEBI("wavf"+this.pid)!=null) {
				GEBI("wavf"+this.pid).src = this.src;
			}
		}
		if (dblExt=='.mp3.mp3' || dblExt=='.wav.mp3') {
			waveform.src = purl.substring(0,purl.length-4)+'.jpg';
		} else {
			waveform.src = purl+'.jpg';
		}
		GEBI('scr'+pid).style.display = 'none';
	}
}

threadNagCount = 0;
function threadNag(bttn) {
	threadNagCount++;
	if (threadNagCount==5) {
		bttn.value = "THREAD";
		threadNagCount = 0;
		return true;
	} else {
		bttn.value = threadNagCount +"/5";
		return false;
	}
}

function ameth(pno) {
	amethlnk(pno, '+');
	GEBI('ameta'+pno).style.display = "none";
}

function amethlnk(pno, sign) {
	GEBI('ametl'+pno).innerHTML = '&#160;<a href="javascript:additionalInfo('+pno+');">'+sign+'</a>';
}

function additionalInfo(pno) {
	if (GEBI('ameta'+pno).style.display=='block') {
		GEBI('ameta'+pno).style.display = "none";
		amethlnk(pno, '+');
	} else {
		GEBI('ameta'+pno).style.display = "block";
		amethlnk(pno, '-');
	}
}

function quote(postId) {
	pId = (''+postId).replace(',','.');
	if (pId.indexOf('.')!=-1) {
		ppId = pId.substring(pId.indexOf('.')+1);
		pppId = "";
		for (i=0;i<ppId.length;i++) {
			pppId = ppId.charAt(i)+pppId;
		}
		document.location.href = 'http://swfchan.org/'+pId.substring(0,pId.indexOf('.'))+'/?'+pppId;
	} else {
		doQuote(postId);
		doCheckForQuotes();
		scrollToForm();
	}
}

function scrollToForm() {
	scrollTo(document.body.scrollLeft, GEBI('txt').offsetParent.offsetParent.offsetTop);
}

function doQuote(postNumber) {
	GEBI('txt').select();
	taval = 'xx'+GEBI('txt').value.replace(/\r\n/g,'\n').replace(/\r/g,'\n');
	if (taval=="xx" || taval.substring(taval.length-2)=="\n\n") {
		GEBI('txt').value += '>>'+ postNumber +'\n';
	} else if (taval.substring(taval.length-1)=="\n") {
		GEBI('txt').value += '\n>>'+ postNumber +'\n';
	} else if (taval.substring(taval.length-1)!=" ") {
		GEBI('txt').value += ' >>'+ postNumber +' ';
	} else {
		GEBI('txt').value += '>>'+ postNumber +' ';
	}
	GEBI('txt').scrollTop = GEBI('txt').scrollHeight;
	if (document.selection) {
		sel = GEBI('txt').createTextRange();
		sel.moveStart("character", GEBI('txt').value.length);
		sel.select();
	} else if ("setSelectionRange" in GEBI('txt')) {
		GEBI('txt').setSelectionRange(GEBI('txt').value.length, GEBI('txt').value.length);
	}
}

checkinQuotes = false;
function checkForQuotes() {
	if (!checkinQuotes) {
		checkinQuotes = true;
		setTimeout("doCheckForQuotes();", 400);
	}
}

function doCheckForQuotes() {
	tex = GEBI('txt').value+"X";
	while (tex.indexOf('>>>')!=-1) {
		tex = tex.replace('>>>','>>');
	}
	quotesFound = new Array();
	while (tex.indexOf('>>')!=-1) {
		tex = tex.substring(tex.indexOf('>>')+2);
		qnum = "";
		while (('1234567890').indexOf(tex.charAt(0))!=-1) {
			qnum += tex.charAt(0);
			tex = tex.substring(1);
		}
		if (qnum!="") {
			quotesFound.push(qnum);
		}
	}
	oneMissing = false;
	if (quotesFound.length==0) {
		GEBI('qarea').innerHTML = "";
		GEBI('qarea').style.display = "none";
	} else {
		qat = "<b>Quoting:</b>";
		dlinks = document.links;
		for (i=0; i<quotesFound.length; i++) {
			wasFound = false;
			for (j=0; j<dlinks.length; j++) {
				if ((dlinks[j].href+'<URLEND>').indexOf('#'+quotesFound[i]+'<URLEND>')!=-1) {
					wasFound = true;
					j = 9999;
				}
			}
			if (wasFound) {
				qat += ' <a href="#'+quotesFound[i]+'" onclick="if (postHistory.length==0 || postHistory[postHistory.length-1]!=-999){lastPostClicked=0;postHistory.push(-999);setTimeout(\'highlightPostWork();\',10);}">&gt;&gt;'+quotesFound[i]+'</a>';
			} else {
				oneMissing = true;
				qat += ' &gt;&gt;'+quotesFound[i];
			}
		}
		GEBI('qarea').innerHTML = qat;
		GEBI('qarea').style.display = "block";
	}
	checkinQuotes = false;
	if (oneMissing && imagesHookedSame<300) {
		setTimeout("doCheckForQuotes();",200);
	}
}

function hidePlead() {
	GEBI('anag').style.display = "none";
	doSave("hidePlead", "y", 2592000);
}

function doANag() {
	if (GEBI('anag')==null) {
		setTimeout("doANag();", 400);
	} else if (typeof(nonag)=="undefined" && doLoad("hidePlead")=="") {
		GEBI('anag').innerHTML = '<center><table cellspacing="0"><tr><td id="h"></td><td>Would you please consider unblocking the ads on this domain?<br>By doing so you will support swfchan and help the site to improve.<br>There\'s a thread where you can discuss the ads <a href="http://swfchan.org/488/">here</a>.</td><td id="h"><a href="javascript:hidePlead();" style="text-decoration:none;font-size:70%;" title="(due to cookie limitations this link must be clicked on each subdomain)">[hide]</a></td></tr></td></tr></table><!--<small>There are two ads on swfchan: A text-only ad that appears at the top of every page and a commercial break ad<br>that appears only once per visit. The commercial break is a fullscreen overlay that can be skipped.<br></small>--></center>';
		GEBI('anag').style.margin = "25 0 25 0";
		GEBI('anag').style.display = "block";
	}
}

setTimeout("doANag();", 1250);

subiwSelected=false;subihSelected=false;
subimgid=0;subimgloaded=false;thesubimg=null;oldsubiurl='';oldsubix='';oldsubiy='';oldsubiw='';oldsubih='';dontAutoCutOnFirst=false;
function doSubImageStuffEtc() {
	document.write('<table cellspacing="0" border="10"><tr><td><table cellspacing="0" id="imgcutincell"><tr><td id="imgcutoutpreview"></td></tr></table></td></tr></table><p>');
	listenForSubImgChanges();
	GEBI('subiw').onkeydown = function() {subiwSelected = true;}
	GEBI('subiw').onkeyup = function() {subiwSelected = true;}
	GEBI('subiw').onfocus = function() {subiwSelected = true;}
	GEBI('subih').onkeydown = function() {subihSelected = true;}
	GEBI('subih').onkeyup = function() {subihSelected = true;}
	GEBI('subih').onfocus = function() {subihSelected = true;}
}

function listenForSubImgChanges() {
	if (GEBI('subiurl').value!=oldsubiurl) {
		subimgloaded = false;
		oldsubiurl = GEBI('subiurl').value;
		subimgid++;
		GEBI('imgcutoutpreview').onmousedown = null;
		GEBI('imgcutoutpreview').onmousemove = null;
		GEBI('imgcutoutpreview').onmouseup = null;
		GEBI('imgcutoutpreview').style.verticalAlign = "top";
		GEBI('imgcutoutpreview').style.background = "";
		GEBI('iwnh').innerHTML = "";
		GEBI('imgcutincell').style.width = "";
		GEBI('imgcutincell').style.height = "";
		GEBI('imgcutoutpreview').style.padding = "10px";
		GEBI('lazybuttons').innerHTML = "";
		GEBI('lockprop').style.display = "none";
		GEBI('lazybuttons').title = "";
		if (oldsubiurl.toLowerCase().indexOf('swfchan.')==-1) {
			GEBI('imgcutoutpreview').innerHTML = "URL is not valid.";
		} else {
			GEBI('imgcutoutpreview').innerHTML = "Loading image...";
			if (subimgid==1) {
				doLoadSubImage(subimgid);
			} else {
				setTimeout("doLoadSubImage("+subimgid+");", 1000);
			}
		}
	}
	if (subimgloaded) {
		if (GEBI('subix').value!=oldsubix || GEBI('subiy').value!=oldsubiy || GEBI('subiw').value!=oldsubiw || GEBI('subih').value!=oldsubih) {
			updateSubImageCut(false);
		}
	}
	setTimeout("listenForSubImgChanges();", 250);
}

function doLoadSubImage(givenSubimgid) {
	if (subimgid==givenSubimgid) {
		thesubimg = new Image(); 
		thesubimg.thesubimgid = subimgid;
		thesubimg.onload = function() {
			if (subimgid==this.thesubimgid) {
				GEBI('imgcutoutpreview').style.padding = "0px";
				GEBI('imgcutincell').style.width = this.width+'px';
				GEBI('imgcutincell').style.height = this.height+'px';
				GEBI('imgcutoutpreview').style.background = "url("+this.src+") no-repeat";
				subimgloaded = true;
				if (!dontAutoCutOnFirst || subimgid!=1) {
					pickSubImage(2);
				}
				updateSubImageCut(true);
				GEBI('imgcutoutpreview').onmousedown = setCutOutCorner;
				GEBI('imgcutoutpreview').onmouseup = doneCutOutCorner;
				GEBI('iwnh').innerHTML = " &#160; = "+ this.width +"x"+ this.height;
				fixLazyButtons();
			}
		}
		thesubimg.src = GEBI('subiurl').value;
	}
}

function pickSubImage(no) {
	if (no<=2) {
		GEBI('subiy').value = "0";
		GEBI('subih').value = ""+ Math.floor(thesubimg.height/3);
	} else if (no<=4) {
		GEBI('subiy').value = ""+ Math.floor(thesubimg.height/3);
		GEBI('subih').value = ""+ Math.floor(thesubimg.height/3);
	} else {
		GEBI('subiy').value = ""+ Math.floor((thesubimg.height/3)*2);
		GEBI('subih').value = ""+ thesubimg.height-Math.floor((thesubimg.height/3)*2);
	}

	if (no==1 || no==3 || no==5) {
		GEBI('subix').value = "0";
		GEBI('subiw').value = ""+ Math.floor(thesubimg.width/2);
	} else {
		GEBI('subix').value = ""+ Math.floor(thesubimg.width/2);
		GEBI('subiw').value = ""+ thesubimg.width - Math.floor(thesubimg.width/2);
	}
}

function notInt(str) {
	return str=="" || str.indexOf('-')!=-1 || isNaN(str) || str.indexOf(".")!=-1 || str.indexOf(",")!=-1;
}

function fixLazyButtons() {
	lbStr = '';
	for (i=1;i<=6;i++) {
		lbStr += '<input type="button" onclick="pickSubImage('+i+');doAdaptiveXY=true;updateSubImageCut(false);" value="'+i+'" style="width:20px;height:20px;">';
	}
	GEBI('lazybuttons').title = "Use these buttons to auto-select portions of the image."
	GEBI('lazybuttons').innerHTML = lbStr;
	GEBI('lazybuttons').style.padding = "0 0 0 50";
	GEBI('lockprop').innerHTML = '<p><table cellspacing="0"><tr><td><input type="checkbox" id="lloo" onchange="doAdaptiveXY=true;updateSubImageCut(false);" onclick="doAdaptiveXY=true;updateSubImageCut(false);"></td><td style="padding-left:10px;"><label for="lloo" onclick="doAdaptiveXY=true;updateSubImageCut(false);">Keep width/height the same (no stretching).</label></td></tr></table>';
	GEBI('lockprop').style.display = "block";
}

doAdaptiveXY = false;
function updateSubImageCut(doSetHtml) {
	if (doSetHtml) {
		if (isCuttingSubImage) {
			GEBI('imgcutoutpreview').innerHTML = '<table style="background:url(selection2.png);" id="subimgcutout" cellspacing="0"><tr><td style="padding:0;"></td></tr></table>';
		} else {
			GEBI('imgcutoutpreview').innerHTML = '<img src="selection.png" id="subimgcutout">';
		}
	}
	updateSICXY();
	oldsubiw = GEBI('subiw').value;
	oldsubih = GEBI('subih').value;
	if (notInt(oldsubix) || notInt(oldsubiy) || notInt(oldsubiw) || notInt(oldsubih)) {
		usicxxx = 0;
		usicyyy = 0;
		usicwww = thesubimg.width;
		usichhh = thesubimg.height;
	} else {
		usicxxx = oldsubix*1;
		usicyyy = oldsubiy*1;
		usicwww = oldsubiw*1;
		usichhh = oldsubih*1;
		if (GEBI('lloo')!=null && usicwww!=usichhh) {
			if (GEBI('lloo').checked) {
				if (subiwSelected || (usicwww<usichhh && !subihSelected)) {
					if (doAdaptiveXY) {
						usicyyy += Math.round((usichhh-usicwww)/2);
					}
					usichhh = usicwww;
				} else {
					if (doAdaptiveXY) {
						usicxxx += Math.round((usicwww-usichhh)/2);
					}
					usicwww = usichhh;
				}
				GEBI('subix').value = usicxxx;
				GEBI('subiy').value = usicyyy;
				GEBI('subiw').value = usicwww;
				GEBI('subih').value = usichhh;
			}
		}
	}
	GEBI('subimgcutout').style.marginLeft = usicxxx+"px";
	GEBI('subimgcutout').style.marginTop = usicyyy+"px";
	GEBI('subimgcutout').style.width = (usicwww<10 ? 10 : usicwww)+"px";
	GEBI('subimgcutout').style.height = (usichhh<10 ? 10 : usichhh)+"px";
	doAdaptiveXY = false;
	subiwSelected = false;
	subihSelected = false;
}

function updateSICXY() {
	oldsubix = GEBI('subix').value;
	oldsubiy = GEBI('subiy').value;
}

tdx = 0;
tdy = 0;
function defineTdxTdy(e) {
	tdO = GEBI('imgcutoutpreview');
	tdx = 0;
	tdy = 0;
	do {
		tdx += tdO.offsetLeft;
		tdy += tdO.offsetTop;
		tdO = tdO.offsetParent;
	} while (tdO!=null);
	if (e==undefined) {
		tdx = (event.clientX+document.body.scrollLeft)-tdx;
		tdy = (event.clientY+document.body.scrollTop)-tdy;
	} else {
		tdx = e.pageX - tdx;
		tdy = e.pageY - tdy;
	}
}

function setCutOutCorner(e) {
	defineTdxTdy(e);
	doSetCutOutCorner();
}

isCuttingSubImage = false;
pendingCutDownX = -1;
pendingCutDownY = -1;
function doSetCutOutCorner() {
	if (notInt(oldsubix) || notInt(oldsubiy) || notInt(oldsubiw) || notInt(oldsubih)) {
		COX = 0;
		COY = 0;
		COW = thesubimg.width;
		COH = thesubimg.height;
	} else {
		COX = oldsubix*1;
		COY = oldsubiy*1;
		COW = oldsubiw*1;
		COH = oldsubih*1;
	}
	if (!isCuttingSubImage) {
		pendingCutDownX = tdx;
		pendingCutDownY = tdy;
		GEBI('imgcutoutpreview').onmousemove = moveCutOutCorner;
		isCuttingSubImage = true;
	} else {
		NEWw = tdx-COX<=10 ? 10 : tdx-COX;
		NEWh = tdy-COY<=10 ? 10 : tdy-COY;
		if (GEBI('lloo')!=null && GEBI('lloo').checked) {
			if (NEWw<NEWh) {
				GEBI('subiw').value = NEWw;
				GEBI('subih').value = NEWw;
			} else {
				GEBI('subiw').value = NEWh;
				GEBI('subih').value = NEWh;
			}
		} else {
			GEBI('subiw').value = NEWw;
			GEBI('subih').value = NEWh;
		}
	}
	updateSubImageCut(isCuttingSubImage);
}

function moveCutOutCorner(e) {
	defineTdxTdy(e);
	if (pendingCutDownX==-1 || tdx-pendingCutDownX>=10 || tdy-pendingCutDownY>=10) {
		fillInPending();
		doSetCutOutCorner();
	}
}

function fillInPending() {
	if (pendingCutDownX!=-1) {
		GEBI('subix').value = pendingCutDownX;
		GEBI('subiy').value = pendingCutDownY;
		pendingCutDownX = -1;
		updateSICXY();
	}
}

function doneCutOutCorner(e) {
	GEBI('imgcutoutpreview').onmousemove = null;
	isCuttingSubImage = false;
	fillInPending();
	updateSubImageCut(true);
}

function refreshSoonUnlessIdIsFound(idStr) {
	if (GEBI(idStr)==null) {
		setTimeout("if (document.location.href.indexOf('#')!=-1) {document.location.href = document.location.href.substring(0,document.location.href.indexOf('#'));} else {document.location.href = document.location.href;}", 10000);
		setTimeout("document.location.reload(true);", 15000);
	}
}
