if (top.location != document.location)
	top.location = document.location;
var haspreloaded = 1;


function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	{
		field.value = field.value.substring(0, maxlimit);
	}
	// otherwise, update 'characters left' counter
	else 
	{
		countfield.value = maxlimit - field.value.length;
	}
}

function getBody(){
	if(document.compatMode && document.compatMode!="BackCompat"){
		return document.documentElement;
	}else{
		return document.body;
	}
}
function showDetails( e, name, type, score  ){
	document.getElementById( "bubble" ).style.visibility = "visible";
	document.getElementById( "bubble" ).style.left = ( e.clientX - 10 + getBody().scrollLeft ) + "px";//- 23 + getBody().scrollLeft ) + "px";
	document.getElementById( "bubble" ).style.top = ( e.clientY + 15 + getBody().scrollTop )  + "px";//- 185 + getBody().scrollTop )  + "px";
	document.getElementById( "name" ).innerHTML = name;
	document.getElementById( "type" ).innerHTML = type;
	document.getElementById( "score" ).innerHTML = score;
	
}


function hideDetails(){
	//document.getElementById( "bubble" ).style.left = "0px";
	//document.getElementById( "bubble" ).style.top = "0px";
	document.getElementById( "bubble" ).style.visibility = "hidden";
}




function highlight(id)
{
   var pum1 = new Image();
   pum1.src ="images/star-lhl-h.gif";
   var pum2 = new Image();
   pum2.src =  "images/star-rhl-h.gif";	


	for( i =1; i<=id; i++)
	{
		if( i % 2 == 1)
		{
			document.getElementById('star'+i).src = pum1.src ;			
		}
		else
		{
			document.getElementById('star'+i).src = pum2.src ;	
		}
	}
	j = id + 1;

	while( j<=10)
	{
		if( j % 2 == 1)
		{
			document.getElementById("star"+j).src = "images/star-lhu.gif";			
		}
		else
		{
			document.getElementById("star"+j).src = "images/star-rhu.gif";	
		}
		j++;
	}

}
				
				

function unhighlight(id)
{
	id=Math.round(id);
	for( i =1; i<=id; i++)
	{
		if( i % 2 == 1)
		{
			document.getElementById("star"+i).src = "images/star-lhl.gif";			
		}
		else
		{
			document.getElementById("star"+i).src = "images/star-rhl.gif";	
		}
	}
	for( i =id+1; i<=10; i++)
	{
		if( i % 2 == 1)
		{
			document.getElementById("star"+i).src = "images/star-lhu.gif";			
		}
		else
		{
			document.getElementById("star"+i).src = "images/star-rhu.gif";	
		}
	}

		
}


/*AJAX*/
function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }

  if (!request)
    alert("Error initializing XMLHttpRequest!");
}
 function vote(id, value)
{
	createRequest();
	var url = "/scripts/vote.php?id=" + id + "&scr=" + value;
	request.open("GET", url, true);
	request.onreadystatechange = voteReturn;
	request.send(null);

}

function voteReturn()
{
	 if (request.readyState == 4) 
	{
	       if (request.status == 200) 
		{
			 var result = request.responseText.split("|"); 
			 

			document.getElementById("textvote").innerHTML = result[1];
			document.getElementById("starsvote").innerHTML = result[2];
			unhighlight(result[0]);
			
	       } 
	   }
   }
   
function Comment()
{
	 var comment =document.form1.list.value;
	 var id = document.form1.id.value;
	  var name =document.form1.name.value;
	 
	createRequest();
	var url = "/comment/comment.php?id=" + id + "&comment=" + comment+ "&name=" + name;
	request.open("GET", url, true);
	request.onreadystatechange = CommentReturn;
	request.send(null);
}

function CommentReturn()
{
	 if (request.readyState == 4) 
	{
	       if (request.status == 200) 
		{
			 var result = request.responseText.split("|"); 
			//document.getElementById("commentbox1").innerHTML = "<iframe width=400 height=120 src=\"http://www.extremefunnypictures.com/comment/" + result[0] + ".htm\" align=center frameborder=\"no\" > </iframe>";
			if (document.all)
			{
				var f = document.getElementById('commentboxframe');
				f.contentWindow.location.reload(true);
			}

			document.getElementById("mycomment").innerHTML = result[1];
			
	       } 
	       else
	       {
		       alert('bad status, sorry')
	       }
	}
}
   
function out(id)
{
	 
	createRequest();
	var url = "/plugger/out.php?id=" + id;
	request.open("GET", url, true);
	request.onreadystatechange = outReturn;
	request.send(null);
}

function outReturn()
{
	 if (request.readyState == 4) 
	{
	       if (request.status == 200) 
		{
			//alert(request.responseText);
		}
	}
}
   
function check()
{
	if (document.referrer != '')
	{
		createRequest();
		var url = "/plugger/ref.php?ref=" + document.referrer;
		request.open("GET", url, true);
		request.onreadystatechange = outReturn;
		request.send(null);
	}
}
   
var swear_words_arr=new Array("barack", "obama", "borock","barock","kunt","f~u~c~k", "  ","http","www",".com","beeatch","biatch", "beatch","/","\\","f!uck","fuc!k","d+ck","d'ck","d-ck","d_ck","d=ck","d@ck","d#ck","d$ck","d%ck","d^ck","d&ck","d*ck","d;ck","d/ck","d)ck","d(ck","d]ck","d[ck","d{ck","d}ck","fu!ck", "f!u!ck","fu!c!k","f!u!c!k","f!uc!k","f()ck","bich","~","d:ck","f/u/k","fu/ck","s/h/t","d!ck","d1ck","d|ck","dlck","dxck","dtck","d7ck","dck","fu/ck","f/ u c k","fxck","fvucker","fu~c~k","f~u~ck","f~uc~k","fuc~k","f~uck","puzzy","c.ock ","ssshhhiiittt","s~e~x","f c k","sh+t","BIT CH","peniz", "f/u/k","shiet","fuucck","dyck","vahgina","vaghina","f. u. c.k","FuuCCkk","f&ck","hotmail","$hit","shyt","di/ck", "di,ck","f/uck","f/u/ck","f/u/c/k","sh't","f\\uck","fu/c/k","fuc/k","fu\(k","f'u;c,k","f,u;c.k","f\"'uc k","f,uck","fu,ck","fuc,k","f,ck","fu,k","f'uck","fu'ck","fuc'k","f'ck","fu'k","fu&$","f.c.u.k","sh/t","f$ck","foock","sh/it","anal","F ck","W.H.O.R.E","fu .ck", "fu. ck","fruck","fk","cokz", "sh|t","f$uck","fuuck","fuuuck","fuuuuck","fa/g","pus.sy","$lut","s.crew","f..k","f.ck","fu.k","fu.ck","<", ">","5h1t","shlt","f^ck", "sh1t","f(u)ck","fck","b/i/t/c/h", "ashol", "pennis","5hit","fu'ck","shiit", "$ex", "pu$sy","pus$y", "s/h/i/t", "f/u/c/k","#","$hi+","fu.k","fook","pu55y","p.u.s.s.y","f.ck","quir", "§hÎt","§hit","$hit","bitc","dik","fgget","fu.c.k", "f.uck","f.u.ck","f.uc.k","fuc.k","sh.it","s.hit", "shi.t","s.h.it", "sh.i.t","niger","nigger","p|ss","freak","freack","@",".com","fvck","cox","$h!t","phuk","azz","hump","snatch","snach","f'ck","*","clit","dooky","-","_","f/ck","@", "squirt","shat","sht","sperm", "sex","organ","puss", "dingus","pu$$y","a$$", "fuc","fuk","f uck", "fcuk","f cuk", "fc uk", "fcu k","fu ck","fuc k","s hit", "sh it", "shi t","as s", "a ss","c unt","cu nt","cun t","masturbat", "@ss", "ashole","sh!t","masterbat","penis","vagina","blow","ass", "tit","a s s","a.s.s","bitch","b i t c h","b.i.t.c.h","butt","cock","c o c k","c.o.c.k","crap","c r a p","c.r.a.p","cunt","c u n t","c.u.n.t","cuck","c u c k","c.u.c.k","d i c k","d.i.c.k","fuck","f u c k","f.u.c.k","fucking","f u c k i n g","f.u.c.k.i.n.g","fuk","f u k","f.u.k","jackass","jack ass","j a c k a s s","j.a.c.k.a.s.s","jerk","j e r k","j.e.r.k","jerck","j e r c k","j.e.r.c.k","jerq","j e r q","j.e.r.q","shit","s h i t","s.h.i.t","suck","s u c k","s.u.c.k","dick","damn","dyke","@$$","b!+ch","b!tch","b17ch","b1tch","bastard","bi+ch","bi7ch","bitch","boiolas","bollock","breasts","buceta","butt-pirate","c0ck","cabron","cawk","cazzo","chink","chraa","chuj","cipa","clits","cum","cunt","dick","dike","dildo","ejackulate","fag","fcuk","feces","foreskin","Fu(k","fuk","Fut","gay","gook","guiena","h0r","h4x0r","hell","hore","jism","jizz","l3i+ch","l3itch","lesbian","lesbo","masturbat","merd","merde","mibun","monkleigh","motherfucker","nigga","nigger","nutsack","penis","phuck","porn","pr0n","preteen","preud","prick","pusse","pussy","puta","queef","queer","qweef","screw","scrotum","sh!t","slut","smut","sphencter","spic","splooge","suka","teets","teez","testicles","tits","titties","titty","twat","wank","wetback","whoar","whore");
var swear_alert_arr=new Array();
var swear_alert_count=0;

function reset_alert_count()
{
 swear_alert_count=0;
}

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function


function wordFilter(form,fields)
{
    reset_alert_count();
	var compare_text;
	var fieldErrArr=new Array();
	var fieldErrIndex=0;
	for(var i=0; i<fields.length; i++)
	{
		eval('compare_text=document.' + form + '.' + fields[i] + '.value;');
		if( compare_text == "" || compare_text == " " || compare_text == "  ")
			{
				alert( "You have left your name or comment blank. ");
				return false;
			}
		
		for(var j=0; j<swear_words_arr.length; j++)
		{
			for(var k=0; k<(compare_text.length); k++)
			{
				if(swear_words_arr[j]==compare_text.substring(k,(k+swear_words_arr[j].length)).toLowerCase())
				{
					swear_alert_arr[swear_alert_count]=compare_text.substring(k,(k+swear_words_arr[j].length));
					swear_alert_count++;
					fieldErrArr[fieldErrIndex]=i;
					fieldErrIndex++;
				}
			}
		}
	}
	var alert_text="";
	for(var k=1; k<=swear_alert_count; k++)
	{
		if (swear_alert_arr[k-1] == "  ")
			{
				swear_alert_arr[k-1] = "\"  \" - Can't have more than one space in a row due to abuse\n   please go back and check for places with more than one space in a row";
			}
		alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
		eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.focus();');
		eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.select();');
	}
	if(swear_alert_count>0)
	{
		alert("The form cannot be submitted.\nThe following illegal words were found:\n_______________________________\n" + alert_text + "\n_______________________________");
		return false;
	}
	else
	{
		Comment();
	}
}	


function wordFilter2(form,fields)
{
    reset_alert_count();
	var compare_text;
	var fieldErrArr=new Array();
	var fieldErrIndex=0;
	for(var i=0; i<fields.length; i++)
	{
		eval('compare_text=document.' + form + '.' + fields[i] + '.value;');
		if( compare_text == "" || compare_text == " " || compare_text == "  ")
			{
				alert( "You have left your name or comment blank. ");
				return false;
			}
		
		for(var j=0; j<swear_words_arr.length; j++)
		{
			for(var k=0; k<(compare_text.length); k++)
			{
				if(swear_words_arr[j]==compare_text.substring(k,(k+swear_words_arr[j].length)).toLowerCase())
				{
					swear_alert_arr[swear_alert_count]=compare_text.substring(k,(k+swear_words_arr[j].length));
					swear_alert_count++;
					fieldErrArr[fieldErrIndex]=i;
					fieldErrIndex++;
				}
			}
		}
	}
	var alert_text="";
	for(var k=1; k<=swear_alert_count; k++)
	{
		if (swear_alert_arr[k-1] == "  ")
			{
				swear_alert_arr[k-1] = "\"  \" - Can't have more than one space in a row due to abuse\n   please go back and check for places with more than one space in a row";
			}
		alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
		eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.focus();');
		eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.select();');
	}
	if(swear_alert_count>0)
	{
		alert("The form cannot be submitted.\nThe following illegal words were found:\n_______________________________\n" + alert_text + "\n_______________________________");
		return false;
	}
	else
	{
		Comment();
	}
}	


