<!--
var ignore_preview = 0;
var counter = 0;
var un = unescape(readCookie('user','username'));
var uh = unescape(readCookie('user','hash'));
var id = readCookie('user','user%5Fid');
var ul = unescape(readCookie('user','user%5Flevel'));
var pl = unescape(readCookie('plime','list'));
var disablerefreshajx = 1;
var fi = 1;
var maxwidth = 398;
var tagfield;

function dbug(n) {
         //debug function so we can perform debug alerts without annoying our users
         if (id == "2" || id == "2534" || id == "2633") {
	    alert(n);
         }
}

//document.write('<div style="position:fixed;bottom:0px;right:0px;bgcolor:#fff;z-index:45024523402340"><a href="/rebuild.p?pid=' + plime + '">rebuild?</a></div>');
function ago(sdate) {
   document.write(getago(sdate));
}

function forumimage(n,id) {
    var img = document.createElement('img');

    img.onload = function (evt) {
        document.getElementById(id).src=this.src;
        document.getElementById(id).title=this.src;
        document.getElementById(id).alt=this.src;
        if (this.width > maxwidth) {
          document.getElementById(id).width=maxwidth;
          document.getElementById(id).height=(maxwidth * this.height) / this.width;
        } else {
          document.getElementById(id).width=this.width;
          document.getElementById(id).height=this.height;
        }
    }
    img.src = n;

  //document.getElementById('fi'+fi).innerHTML=<img border="0" src="'+pImageURL+'">;
  //document.write("<div class='imagecontainer'><img src='" + n + "' border='0'></div>");
  fi++;
}

function getago(sdate) {

	if (isDate(sdate) && isDate(currenttime)) {

		var varYear =  (60 * 60 * 24 * 365) - 1;
		var varMonth = (60 * 60 * 24 * 30) - 1;
		var varWeek = (60 * 60 * 24 * 7) - 1;
		var varDay = (60 * 60 * 24) - 1;
		var varHour = (60 * 60) - 1;
		var varMinute = (60) - 1;
		var varSecond = 1;
		var vago = '';

		var intdateDiff = dateDiff('s',sdate,currenttime)

		if (intdateDiff < 0) {
                   intdateDiff = "0"
                }

		if (intdateDiff == 0) {
			vago = "on&nbsp;" + sdate;
		} else if (intdateDiff >= 1 && intdateDiff < varMinute) {
			vago = intdateDiff + "&nbsp;" + "second" + plural(Math.round(intdateDiff / varSecond)) + "&nbsp;" + "ago";
		} else if (intdateDiff >= varMinute && intdateDiff < varHour) {
			vago = Math.round(intdateDiff / varMinute) + "&nbsp;" + "minute" + plural(Math.round(intdateDiff / varMinute)) + "&nbsp;" + "ago";
		} else if (intdateDiff >= varHour && intdateDiff < varDay) {
			vago = Math.round(intdateDiff / varHour) + "&nbsp;" + "hour" + plural(Math.round(intdateDiff / varHour)) + "&nbsp;" + "ago";
		} else if (intdateDiff >= varDay && intdateDiff < varWeek) {
			vago = Math.round(intdateDiff / varDay) + "&nbsp;" + "day" + plural(Math.round(intdateDiff / varDay)) + "&nbsp;" + "ago";
		} else if (intdateDiff >= varWeek && intdateDiff < varMonth) {
			vago = Math.round(intdateDiff / varWeek) + "&nbsp;" + "week" + plural(Math.round(intdateDiff / varWeek)) + "&nbsp;" + "ago";
		} else if (intdateDiff >= varMonth && intdateDiff < varYear) {
			vago = Math.round(intdateDiff / varMonth) + "&nbsp;" + "month" + plural(Math.round(intdateDiff / varMonth)) + "&nbsp;" + "ago";
		} else {
			vago = Math.round(intdateDiff / varYear) + "&nbsp;" + "year" + plural(Math.round(intdateDiff / varYear)) + "&nbsp;" + "ago";
		}

	} else {

		vago = sdate
	}

	return vago;

}

function plural(n) {
         var ps = "";
	if (n > 1) {
           ps = "s";
	}
	return ps
}

function isDate(p_Expression){
	return !isNaN(new Date(p_Expression));	// <<--- this needs checking
}

function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
	if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
	if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
	var dt1 = new Date(p_Date1);
	var dt2 = new Date(p_Date2);

	// get ms between dates (UTC) and make into "difference" date
	var iDiffMS = dt2.valueOf() - dt1.valueOf();
	var dtDiff = new Date(iDiffMS);

	// calc various diffs
	var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
	var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
	var nQuarters = parseInt(nMonths/3);	//<<-- different than VBScript, which watches rollover not completion
	
	var nMilliseconds = iDiffMS;
	var nSeconds = parseInt(iDiffMS/1000);
	var nMinutes = parseInt(nSeconds/60);
	var nHours = parseInt(nMinutes/60);
	var nDays  = parseInt(nHours/24);
	var nWeeks = parseInt(nDays/7);


	// return requested difference
	var iDiff = 0;		
	switch(p_Interval.toLowerCase()){
		case "yyyy": return nYears;
		case "q": return nQuarters;
		case "m": return nMonths;
		case "y": 		// day of year
		case "d": return nDays;
		case "w": return nDays;
		case "ww":return nWeeks;		// week of year	// <-- inaccurate, WW should count calendar weeks (# of sundays) between
		case "h": return nHours;
		case "n": return nMinutes;
		case "s": return nSeconds;
		case "ms":return nMilliseconds;	// millisecond	// <-- extension for JS, NOT available in VBScript
		default: return "invalid interval: '" + p_Interval + "'";
	}
}




function isonline(n) {

	var stronline="1~2~3~4~16~15";

	if (stronline.indexOf('~' + n + '~') > 0) {
		return 'online';
	} else {
		return 'offline';
	}
}
function rec(id) {
	document.imgrec.src = '/rec.p?t=c&id=' + id + '&kill=' + (new Date()).getTime();
}
function helpup(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=350,left = 100,top = 100');");
}
function readCookie(name,chip) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	var varc = "";
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			varc = c.substring(nameEQ.length,c.length);
		}
	}

	var lenc = varc.length;

	if (lenc>0) {
		var chipEQ = chip + "=";
		ca = varc.split('&');
		for(var i=0;i<ca.length;i++)
		{
				c = ca[i];
				while (c.charAt(0)==' ') {
					c = c.substring(1,c.length);
				}
				if (c.indexOf(chipEQ) == 0) {
					return c.substring(chipEQ.length,c.length);
				}
		}
	}

	return "";
}

function dh(n) {
//	document.write('<div class="error">Please note that we are experimenting with the layout tonight, and making news posts anonymous. More info and discussion <a style="text-decoration:underline" href="/f/382/" class="white">here</a>.</div><BR>');

	var kw = prunekeyword(n);
	document.write('<div class="regular" id="hl" name="hl">');
	if (kw.length>0) {
		document.write('<b>' + hllan() + '</b><BR>');
		var kwstring = kw.split(' ');
		var vkw = escape(kw);
		var thiscolor = '';
		for(var k=0;k<kwstring.length;k++)
		{
			kwparse = kwstring[k];
			thiscolor = KeyWordGetColor();
			document.write('<b style="color:#000000\;background-color:' + thiscolor + '"><a class="regular" href="#" onClick="hl(\'' + kwparse + '\',\'' + thiscolor + '\')\;"><font color="#000000">' + kwparse + '</font></a></b> ');
		}
		document.write(hlclear());
		document.write(hlend() + '<BR>');
	}
	document.write('</div>');
}

function hl(n,o) {
	var hstart = "<b style='color:black; background-color:" + o + ";'>";
	var hend = "</b>";
	var divs = document.getElementsByTagName('div');
	divs['clear'].style.visibility = 'visible';
	divs['clear'].style.display = 'inline';
	return highlightSearchTerms(n,false,true,hstart,hend);
}

function prunekeyword(n) {
	var ca = n;
	var nameEQ = "?";
	var varca = "";
	if (ca.indexOf(nameEQ) > 0) {
		ca = ca.substring((ca.indexOf(nameEQ)+1),ca.length);
	}

	var sraw = "k=,q=,p=,qt=,kw=,st=,kt=,sp=,ask=,plm=,term=,phrase=,query=,search=,lookup=,keyword=";
	var arrstring = sraw.split(',');
	var arrca = ca.split('&');
	for(var i=0;i<arrca.length;i++)
	{
		var c = arrca[i];

		for(var j=0;j<arrstring.length;j++)
		{
			sstring = arrstring[j];
			if (c.indexOf(sstring) == 0) {
				varca = c.substring(sstring.length,c.length);
			}
		}
	}

	varca = varca.replace(/%20/gi, " ");
	varca = varca.replace(/\+/gi, " ");
	//varca = varca.replace(/%22/gi, "");
	//varca = varca.replace(/\"/gi, "");

	return unescape(varca);
}


function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{

  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<b style='color:#000000; background-color:" + KeyWordGetColor() + ";'>";
    highlightEndTag = "</b>";
  }
  
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
	if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
		if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
			if (lcBodyText.lastIndexOf("/textarea>", i) >= lcBodyText.lastIndexOf("<textarea", i)) {
				if (lcBodyText.lastIndexOf("/object>", i) >= lcBodyText.lastIndexOf("<object", i)) {
					newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
					bodyText = bodyText.substr(i + searchTerm.length);
					lcBodyText = bodyText.toLowerCase();
					i = -1;
				}
			}
		}
	}
    }
  }
  
  return newText;
}

function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{

  if (searchText.length<3) {
	alert(hlerror());
	return false;
  }

  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;

  //IFRAMES
  var frameText;
  var elements = document.getElementsByTagName("iframe");

  for (var j = 0; j < elements.length; j++) {
    if(elements[j].src.indexOf('googlesyndication.com') > -1)
    {
	  for (var i = 0; i < searchArray.length; i++) {
	    frametext = elements[j].innerHTML;
            //elements[j].innerHTML = doHighlight(frameText, searchArray[i], highlightStartTag, highlightEndTag);
	    //alert(frametext);
	  }
    }
  }
  //
  
  return true;
}

function searchPrompt(defaultText, treatAsPhrase, textColor, bgColor)
{
  // This function prompts the user for any words that should
  // be highlighted on this web page
  if (!defaultText) {
    defaultText = "";
  }

  // we can optionally use our own highlight tag values
  if ((!textColor) || (!bgColor)) {
    highlightStartTag = "";
    highlightEndTag = "";
  } else {
    highlightStartTag = "<b style='color:" + textColor + "; background-color:" + bgColor + ";'>";
    highlightEndTag = "</b>";
  }
  
  var searchText = document.search.q.value;

  if (searchText.length<3 || !searchText) {
	alert(hlerror());
	return false;
  }

  var divs = document.getElementsByTagName('div');
  var dc = divs['hl'].innerHTML;
  if (dc.length>0) {
  	divs['clear'].innerHTML = '<b style="color:' + textColor + '\;background-color:' + bgColor + '"><a class="regular" href="#" onClick="hl(\'' + searchText + '\',\'' + bgColor + '\')\;"><font color="' + textColor + '">' + searchText + '</font></a></b>&nbsp\;' + divs['clear'].innerHTML;
	divs['clear'].style.visibility = 'visible';
	divs['clear'].style.display = 'inline';
  } else {
  	divs['hl'].innerHTML = '<b class="regular">' + hllan() + '</b><BR>' + hlclear() + hlend() + '<BR>';
	divs['clear'].innerHTML = '<b style="color:' + textColor + '\;background-color:' + bgColor + '"><a class="regular" href="#" onClick="hl(\'' + searchText + '\',\'' + bgColor + '\')\;"><font color="' + textColor + '">' + searchText + '</font></a></b>&nbsp\;' + divs['clear'].innerHTML; 
	divs['clear'].style.visibility = 'visible';
	divs['clear'].style.display = 'inline';
  }


  return highlightSearchTerms(searchText, treatAsPhrase, true, highlightStartTag, highlightEndTag);
}

function KeyWordGetColor()
{
    var color = 'yellow';

    switch (counter)
    {
	case 0: color='yellow';  break;
	case 1: color='#99FF99'; break;
	case 2: color='#FFCCFF';  break;
	case 3: color='#CC99FF';  break;
	case 4: color='#99CCFF';  break;
	case 5: color='#FFCC99';  break;
	case 6: color='#CCCCFF';  break;
	case 7: color='#66CCFF';  break;
	case 8: color='#66CC99';  break;
	case 9: color='#66CC66';  break;
	case 9: color='#99CCCC';  break;
	default: break;
    }
    counter++;
    return color;
}
function paginate(n,o,p,q) {


	var varpages = n;
	var varpage = o;

	var varbegin = (varpage - 3);
	var varend = (varpage + 4);

	if (varbegin <= 0) {
	   varbegin = 1;
	}

	if (varend > varpages) {
	   varend = varpages;
	}

	if (varend <= 0) {
	   varend = 1;
	}

        var varprevious = '';
        var varnext = '';

	if (varpage > varbegin) {
		varprevious = " <a href='" + p + (varpage-1) + q + "' class='page td'>&lt;</a>";
	}

	if (varpage < varend) {
		varnext = " <a href='" + p + (varpage+1) + q + "' class='page td'>&gt;</a>";
	}


	var varextrab = '';
	var varextrae = '';




	if (varbegin > 1) {
		varextrab = " <a class='page td' href='" + p + "1" + q + "'>1</a> ...";
	}

	if (varend < varpages) {
		varextrae = " ... <a class='page td' href='" + p + varpages + q + "'>" + varpages + "</a>";
	}

	document.write(varprevious + varextrab);
	document.write("<span>");
	for (i = varbegin;i <= varend;i++) {
		if (i == varpage) {
			document.write(" <a class='page-selected td' href='" + p + i + q + "'>" + i + "</a>");
		} else {
			document.write(" <a class='page td' href='" + p + i + q + "'>" + i + "</a>");
		}
	}
   	document.write(varextrae + varnext) ;
	document.write("</span>");

} 

function ShowHide(id) {
	divs = document.getElementsByTagName('div');
	if (divs[id].style.visibility == 'hidden') {
		divs[id].style.visibility = 'visible';
		divs[id].style.display = 'block';
	} else 	{
		divs[id].style.visibility = 'hidden';
		divs[id].style.display = 'none';
	}
}

function quickcomment(n,o) {

  if (ul > 0) {
	divs = document.getElementsByTagName('div');
	        divs[o].innerHTML = 'loading...';
			makeHttpRequest(n, o);

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'block';
		divs[o].style.height = '400px';
		divs[o].style.width = '100%';
		setTimeout('location.href="#fast"',375);
  } else {
    do_login();
  }

}
//editing inline
var prepopulaterequest,editinlinerequest;
function editinline(pid,item,item_id,comment_id,type,type_id) {
  prepopulaterequest = createRequest();
	
	var url = "/common/prepopulateinlineediting.p?item=" + item + "&id=" + comment_id + "&" + type + "=" + type_id + "&random=" + Math.random() * 100;

	prepopulaterequest.open("GET", url, true);
	prepopulaterequest.onreadystatechange = function() {prepopulatecomment(pid,item,item_id,comment_id,type,type_id);}; //can't pass parameter onreadystatechange
	prepopulaterequest.send(null);	
}

function prepopulatecomment(pid,item,item_id,comment_id,type,type_id){

	var comment;

  if (prepopulaterequest.readyState == 4) {
		//if(editinlinerequest.status == 0) {//success for file system

	    if(prepopulaterequest.status == 200) {//success for http
		
			switch(item){
				case "ft":
				
					var xmlobject = parser(prepopulaterequest.responseText);
		      		  var x = xmlobject.getElementsByTagName('thread');

		                 	if (document.implementation.createDocument){ // Mozilla
			
							 currID = x[0].getElementsByTagName('thread_id')[0].textContent;
		        		     currTitle = x[0].getElementsByTagName('thread_title')[0].textContent;
		        		     comment = x[0].getElementsByTagName('thread_text')[0].textContent;
		                            

							} else if (window.ActiveXObject){ //IE

							 currID = x[0].getElementsByTagName('thread_id')[0].text;
		        		     currTitle = x[0].getElementsByTagName('thread_title')[0].text;
		        		     comment = x[0].getElementsByTagName('thread_text')[0].text;

							}
							if (item_id == 1) {
							
								currTitle = currTitle.replace(/\&amp;/g,"&");
								currTitle = currTitle.replace(/&quot;/g,"\"");
								//currTitle = currTitle.replace(/~~\.,\.~~/g,"'");
								
								currTitle = currTitle.replace(/\&lt;/g,"<");
								currTitle = currTitle.replace(/\&gt;/g,">");
							  //editheader = "<input type='hidden' id='title' name='title' value='" + forum_title + "' />";
							  
							   editheader = "<textarea id='header' name='header' cols='30' rows='1' >" + currTitle + "</textarea>"
							
							 
							  document.getElementById("forum_header").innerHTML = editheader;
							}

							break;
				default:
					var xmlobject = parser(prepopulaterequest.responseText);
				    var x = xmlobject.getElementsByTagName('comment');

					if (document.implementation.createDocument){ // Mozilla
	
						 currID = x[0].getElementsByTagName('comment_id')[0].textContent;
						 comment = x[0].getElementsByTagName('comment_text')[0].textContent;
							

					} else if (window.ActiveXObject){ //IE

						 currID = x[0].getElementsByTagName('comment_id')[0].text;
						 comment = x[0].getElementsByTagName('comment_text')[0].text;

					}
			
				}
					
				  comment = comment.replace(/\&amp;/g,"&");
				  comment = comment.replace(/&quot;/g,"\"");
				  //comment = comment.replace(/~~\.,\.~~/g,"'");
				  //comment = comment.replace(/\<\/div\>/g,"[quote]");
				 
				   comment = comment.replace(/\&lt;/g,"<");
				   comment = comment.replace(/\&gt;/g,">");
				/*   
				   //comment = comment.replace(/\&amp;lt;/g,"<");
				   //comment = comment.replace(/\&amp;gt;/g,">");
				 
				   comment = comment.replace(/\<br\>/g, "\n");
				   comment = comment.replace(/\<br\/\>/g, "\n");
				  
				   //comment = comment.replace(/(\<div class='qp pad d'\>\<a class='page-dull td' href=')((.|\s)*?)('\>\<b\>&laquo;\<\/b\>\<\/a\>)((.|\s)*)(<\/div\>)/g,"[quote id=$2]$5[/quote]");
				   //comment = comment.replace(/\<div class='qp pad d'\>\<i\>\<a class="page-dull td" href=")((\w|\/|#)*)("\>\<b\>&laquo;\<\/b\>\<\/a\>)((.|\s)*)(<\/div\>)/g,"[quote id=$2]$5[/quote]");
				   //comment = comment.replace(/(\<div class='qp pad d'\>\<a class="page-dull td" href=")((\w|\/|#)*)("\>\<b\>&laquo;\<\/b\>\<\/a\>&nbsp;\<i\>)(\<\/b\>((.|\s)*)\<\/b\/\>)((.|\s)*)(\<\/i\><\/div\>)/g,"[quote id=$2]$7[/quote]");
				   
				   comment = comment.replace(/(\<div class='qp pad d'\>\<a class="page-dull td" href=")((\w|\/|#)*?)("\>\<b\>&laquo;\<\/b\>\<\/a\>&nbsp;\<i\>)((.|\s)*?)(\<\/i\><\/div\>)/g,"[quote id=$2]$5[/quote]");
				   comment = comment.replace(/(\<div class='qp pad d'\>\<a class="page-dull td" href=")((\w|\/|#)*?)("\>\<b\>&laquo;\<\/b\>\<\/a\>)((.|\s)*?)(<\/div\>)/g,"[quote id=$2]$5[/quote]");
				   comment = comment.replace(/(\<div style='display:block;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|&)+)(\<\/a\>\<\/div\>)/g,"[url=$2]$5[/url]")
				   comment = comment.replace(/(\<a class="plime" href="\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(" target="_blank" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|&)+)(\<\/a\>)/g,"[url=$2]$5[/url]")  
				   comment = comment.replace(/(\<span class='spoiler'\>)((.|\s)*?)(\<\/span\>)/g,"[spoiler]$2[/spoiler]");
				   comment = comment.replace(/(\<strike\>)((.|\s)*?)(\<\/strike\>)/g,"[strike]$2[/strike]");
				   
				   comment = comment.replace(/(\<div class='imagecontainer'\>\<a href='\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(' rel='nofollow' target='_blank'\>\<img  src=')((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(\>\<\/a\>\<noscript\> \<span style='display:inline;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(\<\/a\>\<\/span\>\<\/noscript\>)(\<\/div\>\<script\>forumimage[(]')((\w|\s|:|;|-|\/|\?|\.|=|#|&)+)(',')((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)([)];\<\/script\>)/g,"[image]$2[/image]");
				   comment = comment.replace(/(\<ul style='list-style-type: disc; margin: 0px 10px; padding: 0px 10px;'\>)((.|\s)*?)(\<\/ul\>)/g,"[ul]$2[/ul]");	
				   comment = comment.replace(/\<li class='li'\>/g,"[*]");
				   
				   comment = comment.replace(/(\<p align='center'\>\<object width="486" height="412"\>\<embed src='http:\/\/admin.brightcove.com\/destination\/player\/player.swf' bgcolor='#FFFFFF' flashVars='allowFullScreen=true&initVideoId=)((\d)*)(&servicesURL=http:\/\/services.brightcove.com\/services&viewerSecureGatewayURL=https:\/\/services.brightcove.com\/services\/amfgateway&cdnURL=http:\/\/admin\.brightcove.com&autoStart=false' base='http:\/\/admin.brightcove.com' name='bcPlayer' width='486' height='412' allowFullScreen='true' allowScriptAccess='always' seamlesstabbing='false' type='application\/x-shockwave-flash' swLiveConnect='true' pluginspage='http:\/\/www.macromedia.com\/shockwave\/download\/index.cgi\?P1_Prod_Version=ShockwaveFlash'\>\<\/embed\>\<\/object\>\<noembed\>\<a href='http:\/\/www.plime.com\/redir.p\?)((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(' class='plime' target='_blank' rel='nofollow'\>\<b\>flash video\<\/b\>\<\/a\>\<\/noembed\>\<\/p\>)/g,"[video]$5[/video]")
				  // comment = comment.replace(/(\<div class='imagecontainer'\>\<a href='\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(' rel='nofollow' target='_blank'\>\<img  src='\/images\/null.gif' id=')((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(\>\<\/a\>\<noscript\> \<span style='display:inline;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|'|#|&)+)(\<\/a\>\<\/span\>\<\/noscript\>)/g,"[image]$2[/image]");
				   comment = comment.replace(/\<div class='qp pad d'\>/g,"[quote]");
				   comment = comment.replace(/\<\/div\>/g, "[/quote]");
				   comment = comment.replace(/\<b\>/g,"[b]");
				   comment = comment.replace(/\<\/b\>/gi, "[/b]");
				   comment = comment.replace(/\<i\>/gi, "[i]");
				   comment = comment.replace(/\<\/i\>/gi, "[/i]");
				   comment = comment.replace(/\<u\>/gi, "[u]");
				   comment = comment.replace(/\<\/u\>/gi, "[/u]");
*/
				  comment_text = "comment_text_" + comment_id;

				  editcomment = "<form action='/c.p?action=1&pid=" + pid + "&item=" + item + "&id=" + comment_id + "&" + type + "=" + type_id + "&inline=1' method='post'>"
				  editcomment += "<textarea id='comment_" + comment_id + "' name='comment" + comment_id + "' cols='45' rows='10'>" + comment + "</textarea><BR><BR>"
				  editcomment += "<input type='button' onclick=\"submitinlineediting(" + pid + "," + comment_id + "," + type_id + "," + item_id + ",'" + item + "','" + type + "')\" value='submit' /></form>"
				  document.getElementById(comment_text).innerHTML = editcomment;
				  
		} else {
			alert("Error...prepopulaterequest status is " + prepopulaterequest.status);
            }
	}

}

function submitinlineediting(pid,comment_id,type_id,item_id,item,type){
	editinlinerequest = createRequest();
	var comment_header;
	comment_header = '';
	var comment_name = "comment_" + comment_id;
	
	if (item_id == 1) {
		comment_header = document.getElementById("header").value;
	}
	
	var comment_text = escape(document.getElementById(comment_name).value);
	//comment_text = comment_text.replace(/%0A/g, VbCrLf)
	
	//for special chars
	comment_text = comment_text.replace(/\+/g, "~~pl.us~~")
	var url = "/c.p?action=1&pid=" + pid + "&item=" + item + "&id=" + comment_id + "&" + type + "=" + type_id + "&inline=1";
	var params = "title=" + escape(comment_header) + "&text=" + comment_text;
    editinlinerequest.open('POST', url, true);
    editinlinerequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	editinlinerequest.onreadystatechange = function() {rewriteComment(item);}; //can't pass parameter onreadystatechange
	editinlinerequest.send(params);
}


function createRequest() {
	var request = null;
	try {
		request = new XMLHttpRequest();
	} catch (e) {
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				request = null;
			}
		}
	}
	
	if (request == null) {
		alert("Error creating request object.");
	} else {
		return request;
	}
}
function rewriteComment(item){
	if (editinlinerequest.readyState == 4) {
		//if(editinlinerequest.status == 0) {//success for file system

	    if(editinlinerequest.status == 200) {//success for http
			//alert(editinlinerequest.responseText);
			switch(item){
				case "ft":

					var xmlobject = parser(editinlinerequest.responseText);
		      		  var x = xmlobject.getElementsByTagName('thread');

		                 	if (document.implementation.createDocument){ // Mozilla
			
							 currID = x[0].getElementsByTagName('thread_id')[0].textContent;
		        		     currTitle = x[0].getElementsByTagName('thread_title')[0].textContent;
		        		     currText = x[0].getElementsByTagName('thread_text')[0].textContent;
		                            

							} else if (window.ActiveXObject){ //IE

							 currID = x[0].getElementsByTagName('thread_id')[0].text;
		        		     currTitle = x[0].getElementsByTagName('thread_title')[0].text;
		        		     currText = x[0].getElementsByTagName('thread_text')[0].text;

							}
							
							currTitle = currTitle.replace(/VbCrLf/g, "<br/>");
							currTitle = currTitle.replace(/\&amp;/g,"&");
							currTitle = currTitle.replace(/&quot;/g,"\"");
							currTitle = currTitle.replace(/\&lt;/g,"<");
							currTitle = currTitle.replace(/\&gt;/g,">");
							
							
							currText = currText.replace(/VbCrLf/g, "<br/>");
							currText = currText.replace(/\&amp;/g,"&");
							currText = currText.replace(/&quot;/g,"\"");
							//currText = currText.replace(/\<br\/\>/g, "\n");
							currText = currText.replace(/\&lt;/g,"<");
							currText = currText.replace(/\&gt;/g,">");
							
							var imagearray = currText.split("<script>");
							
							var endscript, jscode;
							
							//if currText contains script tags, strip out what's in between, and then eval it (start at 1 to get rid of everything before the script tags)
							
							for(i = 1; i < imagearray.length; i++) {
								endscript = imagearray[i].indexOf("</script>");
								
								jscode = imagearray[i].substring(0,endscript);
								eval(jscode);
							}
							
							comment_id = "comment_text_" + currID;
							document.getElementById('forum_header').innerHTML = currTitle;
							document.getElementById(comment_id).innerHTML = currText;
							
							//alert("forum updated successfully.");
							break;
				default: //comments
					var xmlobject = parser(editinlinerequest.responseText);
		      		  var x = xmlobject.getElementsByTagName('comment');

		                 	if (document.implementation.createDocument){ // Mozilla
			
							 currID = x[0].getElementsByTagName('comment_id')[0].textContent;
		        		     currText = x[0].getElementsByTagName('comment_text')[0].textContent;
		                            

							} else if (window.ActiveXObject){ //IE

							 currID = x[0].getElementsByTagName('comment_id')[0].text;
		        		     currText = x[0].getElementsByTagName('comment_text')[0].text;

							}
							
							currText = currText.replace(/\&amp;/g,"&");
							currText = currText.replace(/&quot;/g,"\"");
							currText = currText.replace(/\&lt;/g,"<");
							currText = currText.replace(/\&gt;/g,">");
							
							var imagearray = currText.split("<script>");
							
							var endscript, jscode;
							
							//if currText contains script tags, strip out what's in between, and then eval it (start at 1 to get rid of everything before the script tags)
							
							for(i = 1; i < imagearray.length; i++) {
								endscript = imagearray[i].indexOf("</script>");
								
								jscode = imagearray[i].substring(0,endscript);
								eval(jscode);
							}
							
							comment_id = "comment_text_" + currID;
							document.getElementById(comment_id).innerHTML = currText;
							
							//alert("comment updated successfully.");
							
				}
                
            } else {
			alert("Error...editinlinerequest status is " + editinlinerequest.status);
            }
	}

}
function closecomment(o) {
	var divs = document.getElementsByTagName('div');
	divs[o].style.visibility = 'hidden';
	divs[o].style.display = 'none';

}

function ajx(n) {

	divs = document.getElementsByTagName('div');
	var o = 'x' + n;
//alert(n)
	if (divs[o].style.visibility == 'visible') {

		divs[o].style.visibility = 'hidden';
		divs[o].style.display = 'none';
		//plusminus(n,"-","+");

	} else 	{

		var dc2 = divs[o].innerHTML;
		if (dc2.length==0) {
			divs[o].innerHTML = ''
			makeHttpRequest('/sidebar.p?pid=' + n + '&pt=' + pagetype, o);
		}

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'inline';
	}

		plusminus("a" + n);
}

function ajx_08(n){
	divs = document.getElementsByTagName('div');
	var o = 'x' + n;
	if (divs[o].style.visibility == 'visible') {

		divs[o].style.visibility = 'hidden';
		divs[o].style.display = 'none';
		//plusminus(n,"-","+");

	} else 	{

		var dc2 = divs[o].innerHTML;
		if (dc2.length==0) {
			divs[o].innerHTML = ''
	//		alert('/sidebar_08.p?pid=' + n + '&pt=' + pagetype)
			makeHttpRequest('/sidebar.p?pid=' + n + '&pt=' + pagetype, o);
		}

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'inline';
	}

		plusminus("a" + n);


}

function cjx(n) {

	divs = document.getElementsByTagName('div');
	var o = 'x0';

	if (divs[o].style.visibility == 'visible') {

		divs[o].style.visibility = 'hidden';
		divs[o].style.display = 'none';

	} else 	{

		var dc2 = divs[o].innerHTML;
		if (dc2.length==0) {
			divs[o].innerHTML = ''
			makeHttpRequest('/common/templates/menu/c' + n + dps + '.htm', o);
		}

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'inline';
	}

	plusminus("c" + n);

}


function getfolder(n) {
	return ((n / 500) * 500) - (n % 500);
}

function makeHttpRequest(url, mid, return_xml) {

    var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
	    }
        }
    }

    if (!http_request) {
        //alert('Unfortunatelly you browser doesn\'t support this feature.');
        return false;
    }
    http_request.onreadystatechange = function() {

       if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                if (return_xml) {
                    eval('ajxd(http_request.responseXML,mid)');
                } else {
                    eval('ajxd(http_request.responseText,mid)');
                }
            } else {
              	//if (mid == "userF" + id || mid == "userI" + id) {
	        //   eval('ajxd("<ul id=\'menu\' class=\'plime2\'><li>none added</ul>",mid)');
                //}
               //alert('There was a problem with the request.(Code: ' + http_request.status + ')');
            }
        }
    }
    http_request.open('GET', url, true);
    http_request.send(null);
}


function ajxd(n,o) {
	var varn = n;
	if (o == "userF" + id) {
	   varn = varn.replace('s.gif?nokill=1','s.gif?kill=' + (new Date()).getTime());
        }
       	//if (o == "userF" + id || o == "userI" + id) {
        //   if (varn.length == 0) {
             //varn = "<ul id='menu' class='plime2'><li>none added</ul>";
        //   }
        //}

        document.getElementById(o).innerHTML = varn;

}

//STATIC HIDE
function hidenav(twocolumn) {
	divs = document.getElementsByTagName('div');
	divs['shownav'].style.visibility = 'visible';
	divs['shownav'].style.display = 'inline';
	divs['leftcontent-ltr'].style.visibility = 'hidden';
	divs['leftcontent-ltr'].style.display = 'none';
	divs['centershell'].style.marginLeft = '18px';
        divs['centershell'].style.width = '936px';
        divs['centershelltl'].style.width = '936px';
        divs['centershelltr'].style.width = '936px';
        divs['centershellbl'].style.width = '936px';
        divs['centershellbr'].style.width = '936px';
        setCookie('nav',1,30);

        //fix chat
        if ( typeof( window[ 'chatpage' ] ) != "undefined" ) {
	   divs['chat'].style.width = '580px';
        }

}

function shownav(twocolumn) {
	divs = document.getElementsByTagName('div');
	divs['shownav'].style.visibility = 'hidden';
	divs['shownav'].style.display = 'none';
	divs['leftcontent-ltr'].style.visibility = 'visible';
	divs['leftcontent-ltr'].style.display = 'inline';
	divs['centershell'].style.marginLeft = '189px';
        divs['centershell'].style.width = '765px';
        divs['centershelltl'].style.width = '765px';
        divs['centershelltr'].style.width = '765px';
        divs['centershellbl'].style.width = '765px';
        divs['centershellbr'].style.width = '765px';
	setCookie('nav',0,30);

        //fix chat
        if ( typeof( window[ 'chatpage' ] ) != "undefined" ) {
	   divs['chat'].style.width = '400px';
        }

}

function checknav(twocolumn) {

	var nav=getCookie('nav');

	if (nav==1) {
		hidenav(twocolumn);
	}
}

function hidenavrtl(twocolumn) {
	divs = document.getElementsByTagName('div');
	divs['shownavrtl'].style.visibility = 'visible';
	divs['shownavrtl'].style.display = 'inline';
	divs['rightcontent-rtl'].style.visibility = 'hidden';
	divs['rightcontent-rtl'].style.display = 'none';
	divs['centershell'].style.marginLeft = '18px';

        if (twocolumn != "1") {
       	   divs['leftcontent-rtl'].style.marginLeft = '738px';
           divs['centershell'].style.width = '725px';
        } else {
	   divs['centershell'].style.width = '914px';
        }

	setCookie('nav',1,30);
}

function shownavrtl(twocolumn) {
	divs = document.getElementsByTagName('div');
	divs['shownavrtl'].style.visibility = 'hidden';
	divs['shownavrtl'].style.display = 'none';
	divs['rightcontent-rtl'].style.visibility = 'visible';
	divs['rightcontent-rtl'].style.display = 'inline';
	divs['centershell'].style.marginLeft = '189px';

        if (twocolumn != "1") {
           divs['leftcontent-rtl'].style.marginLeft = '567px';
	   divs['centershell'].style.width = '554px';
        } else {
	   divs['centershell'].style.width = '743px';
        }

	setCookie('nav',0,30);
}

function checknavrtl(twocolumn) {

	var nav=getCookie('nav');

	if (nav==1) {
		hidenavrtl(twocolumn);
	}
}
//

function getCookie(NameOfCookie)
{


if (document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+"=");
if (begin != -1) // Note: != means "is not equal to"
{


begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); }
}
return null; 

}

function setCookie(NameOfCookie, value, expiredays)
{

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));


document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; path=/; domain=." + domainname + "; expires=" + ExpireDate.toGMTString());

}
function tn(data) {
   document.write(data);
}


/*
function lastview() {
   if (IsDate(getCookie('allpicks'))) {

   }
}
*/




function ujx(id) {

        var ujid = "user" + id;

 	divs = document.getElementsByTagName('div');

  	if (divs[ujid].innerHTML.length < 2) {

            var varInner =  "<ul class='plime2 menu'>";
            varInner +=  "<li><table class='tmen' cellpadding='0' cellspacing='0'><tr valign='top'><td><a id='i" + id + "' class='ax' href='#' onclick='ujxI(" + id + ");return false;'>+</a></td><td>&nbsp;<a class='plime2 td mn' href='/members/" + un + "/i/'>" + "my interests" + "</a></td></tr></table><div style='visibility:hidden;display:none' class='x' id='userI" + id + "'></div>";
            varInner +=  "<li><table class='tmen' cellpadding='0' cellspacing='0'><tr valign='top'><td><a id='f" + id + "' class='ax' href='#' onclick='ujxF(" + id + ");return false;'>+</a></td><td>&nbsp;<a class='plime2 td mn' href='/members/" + un + "/m/'>" + "my friends" + "</a></td></tr></table><div style='visibility:hidden;display:none' class='x' id='userF" + id + "'></div>";
            varInner +=  "<li>";
            varInner +=  "</ul>";

            divs[ujid].innerHTML +=  varInner;

        }


	if (divs[ujid].style.visibility == 'hidden') {
		divs[ujid].style.visibility = 'visible';
		divs[ujid].style.display = 'inline';

		setCookie('fav',1,30);

	} else 	{
		divs[ujid].style.visibility = 'hidden';
		divs[ujid].style.display = 'none';
		setCookie('fav',0,-1);
		setCookie('favI',0,-1);
		setCookie('favF',0,-1);
	}

	plusminus("u" + id);
}

function ujxI(n) {

	divs = document.getElementsByTagName('div');
	var o = 'userI' + n;

	if (divs[o].style.visibility == 'visible') {


		divs[o].style.visibility = 'hidden';
		divs[o].style.display = 'none';
		setCookie('favI',0,-1);

	} else 	{

		setCookie('favI',1,30);
		var dc2 = divs[o].innerHTML;
		if (dc2.length==0) {
			divs[o].innerHTML = ''

			var vargo = '/common/templates/menu-user/' + getfolder(n) + '/' + n + dps + '.htm';
			makeHttpRequest(vargo, o);
		}

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'inline';
	}

	plusminus("i" + n);

}

function ujxF(n) {

	divs = document.getElementsByTagName('div');
	var o = 'userF' + n;

	if (divs[o].style.visibility == 'visible') {


		divs[o].style.visibility = 'hidden';
		divs[o].style.display = 'none';
		setCookie('favF',0,-1);

	} else 	{
		setCookie('favF',1,30);
		var dc2 = divs[o].innerHTML;
		if (dc2.length==0) {
			divs[o].innerHTML = ''

			var vargo = '/sidebarfriend.p';
			makeHttpRequest(vargo, o);
		}

		divs[o].style.visibility = 'visible';
		divs[o].style.display = 'inline';
	}

	plusminus("f" + n);


}

function addplime(n,o) {

       if (ul >= 1) {
        	var vargo = '/addplime.p?pid=' + n + '&type=' + o;
        	var u = 'userI' + id;
        	makeHttpRequest(vargo, u);
        	divs = document.getElementsByTagName('div');

                if (divs['user' + id].innerHTML.length < 2) {
                   ujx(id);
                }

        	divs[u].style.visibility = 'visible';
        	divs[u].style.display = 'inline';
        	var u = 'user' + id;
        	divs[u].style.visibility = 'visible';
        	divs[u].style.display = 'inline';
       } else {
          do_login();
       }
	return false;
}

function delplime(n) {
	disablerefreshajx = 0;
	var vargo = '/addplime.p?del=1&pid=' + n;
	var u = 'userI' + id
	divs = document.getElementsByTagName('div');
	makeHttpRequest(vargo, u);

	disablerefreshajx = 1;
	return false;
}

function addfriend(n) {
  
       if (ul >= 1) {
        	var vargo = '/addfriend.p?fid=' + n
        	var u = 'userF' + id;
        	makeHttpRequest(vargo, u);
        	divs = document.getElementsByTagName('div');

                if (divs['user' + id].innerHTML.length < 2) {
                   ujx(id);
                }

        	divs[u].style.visibility = 'visible';
        	divs[u].style.display = 'inline';
        	var u = 'user' + id;
        	divs[u].style.visibility = 'visible';
        	divs[u].style.display = 'inline';
       } else {
          do_login();
       }

	return false;
}

function delfriend(n) {

	disablerefreshajx = 0;
	var vargo = '/addfriend.p?del=1&fid=' + n;
	var u = 'userF' + id
	divs = document.getElementsByTagName('div');
	makeHttpRequest(vargo, u);
	divs[u].style.visibility = 'visible';
	divs[u].style.display = 'inline';
	disablerefreshajx = 1;
	return false;
}


    function rateOver(n,id){
	if ((document.getElementById('rate0_'+id).value==0)) {
		draw(n,id);
	}
    }
    function rateClear(id){
	if (document.getElementById('rate0_'+id).value==0) {
		draw(0,id);
	}
    }

    function rateact(n,id,pid,ntype,nurl){
      var divspot = '';
      var retspot = '';
      var html = '';

      if (parseInt(ul) >= 1) {

            if (ntype == 'u') {
              divspot = 'votebox';
            } else {
              divspot = 'vc' + id;
              retspot = 'vcn' + id;
              var ns = parseInt(document.getElementById(divspot).innerHTML);
              var nsul = parseInt(ul);
            }

             makeHttpRequest('/addrateaction.p?t=' + ntype + '&i='+ id + '&s=' + n + '&pid=' + pid + '&u=' + nurl, retspot);


                 var arrowup = '';
                 var arrowmiddle = '';
                 var arrowdown = '';

                 if (n == -1) {

                    if (document.getElementById('ad'+id).className == 'arrowdown-voted') {
                        document.getElementById('am'+id).className = 'regular';
                        document.getElementById('ad'+id).className = 'arrowdown';
                        document.getElementById(divspot).innerHTML = (ns + nsul);
                    } else {
                        document.getElementById('am'+id).className = 'plime2';
                        document.getElementById('ad'+id).className = 'arrowdown-voted';
                        if (document.getElementById('au'+id).className == 'arrowup-voted') {
                             document.getElementById(divspot).innerHTML = ns - (nsul * 2);
                        } else {
                             document.getElementById(divspot).innerHTML = ns - nsul;
                        }
                    }

                    document.getElementById('au'+id).className = 'arrowup';

                 } else {
                    if (document.getElementById('au'+id).className == 'arrowup-voted') {
                        document.getElementById('au'+id).className = 'arrowup';
                        document.getElementById('am'+id).className = 'regular';
                        document.getElementById(divspot).innerHTML = ns - nsul;
                    } else {
                        document.getElementById('au'+id).className = 'arrowup-voted';
                        document.getElementById('am'+id).className = 'plime';
                        if (document.getElementById('ad'+id).className == 'arrowdown-voted') {
                             document.getElementById(divspot).innerHTML = ns + (nsul * 2);
                        } else {
                             document.getElementById(divspot).innerHTML = ns + nsul;
                        }
                    }

                    document.getElementById('ad'+id).className = 'arrowdown';
                 }

	} else {
            do_login();
        }

    }





function do_login() {
   document.location.href = "/login.p?pid=" + plime;
}

function aftervoteuser(n) {
 alert(n);
}
function sr(id,rating,ntype,nsize) {
               var i = 0;
               if (rating > 5) {
                  rating = 5;
               }

              if (nsize == '-big') {
                width = 32;
              } else {
                width = 16;
              }

               var html = '<ul class="star-rating' + nsize + '"><li class="current-rating' + nsize + '" style="width:' + (rating * width) + 'px;"></li>';
               for(i=1; i<=5; i++){
                  html += '<li><a href="#" title="' + i + '/5" class="star' + nsize + i + '" onClick="ratethis('+ i +',' + id + ',\'' + ntype + '\',\'' + nsize + '\');return false;"></a></li>';
               }
               html += '</ul>';

     document.write('<span id="rate_' + id + '" class="ltr">' + html + '</span>');
}



function randOrd(a, b){
	return (Math.round(Math.random())-0.5);
}




function disableform(n) {
    for (var i = 0; i<document.forms[n].elements.length; i++) {
		document.forms[n].elements[i].disabled=true;
    }
}




var disappeardelay=250;
var enableanchorlink=1;
var hidemenu_onclick=1;

var ie5=document.all;
var ns6=document.getElementById&&!document.all;

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=0
dropmenuobj.y=110
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}


function repnav(newstr,newdps,newmenu) {

	/*
	//if (id == 2) {

       // var divs = document.getElementsByTagName('div');
       // var str = divs['divnav'].innerHTML;

	//if (menutype == newmenu) {
	//	dps = odps;
	//}

	var oldstr = '';
	if (dps=='n') {
		oldstr = '(/")';
	} else if (dps=='s') {
		oldstr = '(/s/)"';
	} else if (dps=='f') {
		oldstr = '(/f/)(\d{1,})(/0-0/0/")';
	} else  {
		oldstr = '(/' + dps + '/)(\d{1,})(/")';
	}

	alert(oldstr);
	alert(newstr);

	var pattern = new RegExp(oldstr,"g");
	divs['divnav'].innerHTML = str.replace(pattern,newstr);

	dps = newdps;

	}

	*/
}

function plusminus(thediv) {

         if (document.getElementById(thediv).innerHTML == "+") {
             document.getElementById(thediv).innerHTML = "-"
         } else {
             document.getElementById(thediv).innerHTML = "+"
         }
}

function changeSelect(frm,flf,fld) {
	var x = document.forms[frm][fld].value;
 	if (x == "0") {
		rssshow()
 	} else {
		rsshide()
 	}
	return;
}


//HELP
isOpen = false
var pd
var x
function setupXMLHTTP(){
    if(window.XMLHttpRequest) {
    	try {
    	   req = new XMLHttpRequest();
        } catch(e) {
    	   req = false;
        }
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
    	}
    }
    return req
}

function flagPopup(lid,xdir) {
  if (ul >= 1) {

	if (isOpen) {
		helpClose()
	}
	field = document.getElementById('flag' + lid);
	mx = 0;
	my = 0;
	tempImg = field;
	while (tempImg!=null) {
		mx += tempImg.offsetLeft;
		my += tempImg.offsetTop -1;
		tempImg = tempImg.offsetParent;
	}
	if (!pd) {
		pd = document.createElement("div");
		pd.style.position = "absolute";
		pd.style.backgroundColor = "#" + color_3;
		pd.style.borderColor = "#" + color_14;
		pd.style.borderStyle = "solid";
		pd.style.borderWidth = "3px";
		pd.style.zIndex = 4999;
		document.body.appendChild(pd);
	} else {
		pd.style.display = "block";
	}
	my++
	var pdwidth = 190;
	//var pdheight = 100;
	mx+= 4;
	my+= 2;
	pd.style.left = mx + "px";
	pd.style.top = my + "px";
	pd.style.padding = "0px";
	pd.style.width = pdwidth + "px";
//	pd.style.height = pdheight + "px";
	pd.innerHTML = '<div id="flg' + lid + '" class="regular" style="background-color:' + color_3 + '"><span onClick="helpClose()" style="width:17px;height:20px;display:inline;float:' + xdir + ';margin-top:-4px">&nbsp;<a href="#" class="plime2 td" onClick="helpClose();return false" style="border-right:0pmargin-bottom:1px;width:10px;height:10px;border:1px solid #' + color_14 + ';padding:1px;display:inline;font-size:8px"">&nbsp;X&nbsp;</a></span><div class="dropdown"><span style="padding:3px"><b>why prune this link?</b></span></div><ul><li><a href="#" onclick="doflag(' + lid + ',1);return false" class="plime">not safe for work</a></li><li><a href="#" onclick="doflag(' + lid + ',2);return false" class="plime">spam</a></li><li><a href="#" onclick="doflag(' + lid + ',3);return false" class="plime">stupid link</a></li><li><a href="#" onclick="doflag(' + lid + ',4);return false" class="plime">duplicate story</a></li><li><a href="#" onclick="doflag(' + lid + ',5);return false" class="plime">headline is not accurate</a></li><li><a href="#" onclick="doflag(' + lid + ',6);return false" class="plime">wrong category</a></li><li><a href="#" onclick="doflag(' + lid + ',7);return false" class="plime">annoying popups</a></li><li><a href="#" onclick="doflag(' + lid + ',8);return false" class="plime">link is dead</a></li></ul><BR></div>';
	isOpen = true;

  } else {
    do_login();
  }

}

function doflag(lid,st) {

  makeHttpRequest('/flag.p?pid=' + plime + '&f=l&r=' + st + '&id='+ lid,'flg'+lid);
  setTimeout('pd.style.display = "none"',650);
  isOpen = false
}

function helpPopup(div_id,language_id,title,xdir) {
	if (isOpen) {
		helpClose()
	}
	field = document.getElementById(div_id);
	mx = 0;
	my = 0;
	tempImg = field;
	while (tempImg!=null) {
		mx += tempImg.offsetLeft;
		my += tempImg.offsetTop -1;
		tempImg = tempImg.offsetParent;
	}
	if (!pd) {
		pd = document.createElement("div");
		pd.style.position = "absolute";
		pd.style.backgroundColor = "#" + color_3;
		pd.style.borderColor = "#" + color_14;
		pd.style.borderStyle = "solid";
		pd.style.borderWidth = "3px";
		pd.style.zIndex = 4999;
		document.body.appendChild(pd);
	} else {
		pd.style.display = "block";
	}
	my++
	var pdwidth = 186;
	var pdheight = 200;
	my+= 6;
	if (xdir == "right") {
		mx-= 172;
	} else {
		if (ns6) {
			//nothing
		} else {
			mx-= 12;
		}
	}
	pd.style.left = mx + "px";
	pd.style.top = my + "px";
	pd.style.padding = "0px";
	pd.style.width = pdwidth + "px";
	//pd.style.height = pdheight + "px";
	pd.innerHTML = '<div class="regular" style="background-color:' + color_3 + '"><span onClick="helpClose()" style="width:17px;height:20px;display:inline;float:' + xdir + ';margin-top:-4px">&nbsp;<a href="#" class="plime td" onClick="helpClose();return false" style="border-right:0pmargin-bottom:1px;width:10px;height:10px;border:1px solid #' + color_14 + ';padding:1px;display:inline;font-size:8px"">&nbsp;X&nbsp;</a></span><B style="padding:4px">' + title + '</b><hr style="margin-bottom:0px"><div id="hlp'+div_id+'" style="padding:4px">' + 'loading...' + '</div></div>';
	isOpen = true;
	loadHelp(div_id,language_id)
}


function loadHelp(div_id,language_id){

    x = div_id
    x = x.replace(/ /g, '+')
    makeHttpRequest('/adminhelp.p?lan=' + language_id + '&id='+x,'hlp'+x);

}

function helpClose(){
    pd.style.display = "none";
	pd.innerHTML = "";
	isOpen = false
}
function submitHelpForm(n){
    str = 'id='+document.getElementById('page_string'+n).value.replace(/ /g, '+')
    str += '&help_body='+document.getElementById('hlp_body'+n).value.replace(/ /g, '+')
    str += '&language='+document.getElementById('hlp_language'+n).value.replace(/ /g, '+')
    str += '&help_id='+document.getElementById('hlp_id'+n).value.replace(/ /g, '+')

    hlpSave = setupXMLHTTP()
    hlpSave.onreadystatechange = helpClose
    hlpSave.open('POST', '/adminhelp.p?lan='+document.getElementById('hlp_language'+n).value.replace(/ /g, '+'), true);
    hlpSave.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hlpSave.send(str);
}



function submitLogin(){
    str = 'username='+document.getElementById('username').value.replace(/ /g, '+')
    str += '&password='+document.getElementById('password').value.replace(/ /g, '+')
    str += '&login=1'
    
    logXML = setupXMLHTTP()
    logXML.onreadystatechange = loginXMLprocess
    logXML.open('POST', '/login.p?pid=' + plime + '&up=1&level=1', true);
    logXML.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    logXML.send(str);

}

// Function that processes the Login XML
function loginXMLprocess(){

    if (logXML.readyState == 4) {

        if (logXML.status == 200) {

             if (logXML.responseText.length > 0) {

                alert(logXML.responseText);
                
             }

	}
    }
}





//========================
//PMS START HERE
//========================

checkIn = 4000
if (id > 0) {
//	setTimeout('checkPMs()', 5000)
}

// Setup
function invitesXMLHTTP(){
    if(window.XMLHttpRequest) {
    	try {
    	   req = new XMLHttpRequest();
        } catch(e) {
    	   req = false;
        }
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
    	}
    }
    return req
}

// Function that checks for new PM's and slows down over time to reduce server load.
function checkPMs(){
    if(checkIn < 10000){
        //checkIn += 500
    }
    // Check for PM's
    pmXML = invitesXMLHTTP()
    pmXML.onreadystatechange = pmXMLprocess
    x = "/chat/cache/invites/" + getfolder(id) + "/" + id + "_{" + uh + "}.xml"
    //document.location.href = x;
    pmXML.open("GET", x, true);
    pmXML.send("");
    setTimeout('checkPMs()', checkIn)
}


// Function that processes the PM XML
function pmXMLprocess(){

    if (pmXML.readyState == 4) {

        if (pmXML.status == 200) {

             if (pmXML.responseText.length > 0) {

		xmlobject = parser(pmXML.responseText);
		x = xmlobject.getElementsByTagName('invite')[0];

	            //x = pmXML.responseXML.documentElement
	            pmXML = setupXMLHTTP()
        	    pmXML.open("POST", "/chat/invite_clear.p", true);
	            pmXML.send("");
        	    youHaveMail(x.getAttribute("inviteFrom"), x.getAttribute("roomID"), x.getAttribute("roomCustomID"), x.getAttribute("roomName"), x.getAttribute("roomHash"))

            	}
	}
    }
}

// Popup with options
function youHaveMail(iFrom, rID, rCID, rName, rHash) {
    checkIn = 100000

    var divs = document.getElementsByTagName('div');

   // alert('test1');
  //  divs['chatinvite'].style.display = '';
 //   alert('test2');
 //   divs['chatinvite'].innerHTML = iFrom+" has invited you to the chat room '"+rName+"'.\nPress OK to join them now or Cancel to decline";

    if (confirm(iFrom+" has invited you to the chat room '"+rName+"'.\nPress OK to join them now or Cancel to decline")) {

	if ( typeof( window[ 'chatpage' ] ) != "undefined" ) {
	        roomsChange(rID,rHash,nName);
	} else {
	      //  document.location.href='http://www.plime.com/chat.p?roomID='+rID+'&roomHash='+rHash


		var formstr = '<form name="chatform" method="post" action="/members/c/' + id + '/">';
		formstr += '<input name="roomID" value="'+rID+'" type="hidden">';
		formstr += '<input name="roomHash" value="'+rHash+'" type="hidden">';
		formstr += '<input name="roomName" value="'+rName+'" type="hidden">';
		formstr += '</form>';

		divs['chatalert'].style.visibility = 'visible';
		divs['chatalert'].style.display = 'block';
		divs['chatalert'].innerHTML = formstr;

		if (rID.substr(0,2) == "p~") {
			document.chatform.action = '/plime/c/' + rID.substr(2,(rID.length-2)) + '/';
		}

		document.chatform.submit();

	}
    }else {
        // no thanks
    }
}

function parser(xmlstrparse) {

	if (document.implementation.createDocument){
		// Mozilla
		var parser = new DOMParser();
		myDocument = parser.parseFromString(xmlstrparse, "text/xml");
	} else if (window.ActiveXObject){
		// Internet Explorer
		myDocument = new ActiveXObject("Microsoft.XMLDOM")
		myDocument.async="false";
		myDocument.loadXML(xmlstrparse);
	}

    return myDocument

}

//========================
//PMS END HERE
//========================


function updateColours(c1,c2){
	var brightnessThreshold = 125;
	var colorThreshold = 500;

	var bY=((br.getValue() * 299) + (bg.getValue() * 587) + (bb.getValue() * 114)) / 1000;
	var fY=((fr.getValue() * 299) + (fg.getValue() * 587) + (fb.getValue() * 114)) / 1000;
	var brightnessDifference = Math.abs(bY-fY);

    var colorDifference = (Math.max (fr.getValue(), br.getValue()) - Math.min (fr.getValue(), br.getValue())) +
                          (Math.max (fg.getValue(), bg.getValue()) - Math.min (fg.getValue(), bg.getValue())) +
                          (Math.max (fb.getValue(), bb.getValue()) - Math.min (fb.getValue(), bb.getValue()));

	document.getElementById("bDiff").value = brightnessDifference;
	document.getElementById("cDiff").value = colorDifference;

	if ((brightnessDifference >= brightnessThreshold) && (colorDifference >= colorThreshold))	{
	    document.getElementById("cResult").value = "YES!"; // compliant
	}else if ((brightnessDifference >= brightnessThreshold) || (colorDifference >= colorThreshold)){
		document.getElementById("cResult").value = "sort of..."; // sort of compliant
	}else{
		document.getElementById("cResult").value = "NO!"; // not compliant "Poor visibility between text and background colors."
	}
}


//============================
//C.P
//============================

var image_fileid = 0;
var image_id = 0;

function getthumbnail(image_fileurl,image_fileversionid,image_thumbnailhash) {
	pos = image_fileurl.lastIndexOf("/");
	image_fileurl = left(image_fileurl, pos+1 ) + image_fileversionid + "_" + image_thumbnailhash + "_" + "90x90.jpg" 
	return image_fileurl;
}

function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function previ() {

   var image_dom = window.parent.parent.document.getElementById("image_dom").value;
   var image_id = window.parent.parent.document.getElementById("image_id").value;
   var image_seed = window.parent.parent.document.getElementById("image_seed").value;
   var image_ext = window.parent.parent.document.getElementById("image_ext").value;
   var image_fileid = window.parent.parent.document.getElementById("image_fileid").value;
   var image_fileurl = window.parent.parent.document.getElementById("image_fileurl").value;
   var image_fileversionid = window.parent.parent.document.getElementById("image_fileversionid").value;
   var image_fileguid = window.parent.parent.document.getElementById("image_fileguid").value;
   var image_thumbnailhash = window.parent.parent.document.getElementById("image_thumbnailhash").value;
   
   image_fileurl = getthumbnail(image_fileurl,image_fileversionid,image_thumbnailhash);

   var ptml = '';
   
   if (image_fileid > 0) {
   
      ptml = "<img src='" + image_fileurl + "' style='border:1px solid #" + window.parent.color_14 + ";background-color:#" + window.parent.color_14 + "'>";
	
   } else if (image_id > 0){

	  var imageurl = "http://" + image_dom + "/images/library/" + getfolder(image_id) + "/" + image_id + "_" + image_seed + "_90" + image_ext
  	  ptml = "<img src='" + imageurl + "' style='border:1px solid #" + window.parent.color_14 + ";background-color:#" + window.parent.color_14 + "'>";			
  
  } else {
      ptml = '';
   }

   window.parent.parent.document.getElementById("previ").innerHTML = ptml;
//alert(window.parent.parent.document.getElementById("previ").innerHTML);

}

function prevc() {
 setTimeout('prevd()',100);
}

function prevd() {

var bol_news = 1;

   var category = document.getElementById("plime_id").options[document.getElementById("plime_id").selectedIndex].text;
   category = category.replace(/\.\.\./g,"");
   var url = document.getElementById("original_url").value;
   var title = document.getElementById("link_name").value;
   var description = document.getElementById("link_description").value;
   var file_url = document.getElementById("image_fileurl").value.replace("sqr","600x1000");
	
	var alt_title = '';
	
 /*  for (var i=0; i < document.c.link_type.length;i++) {
		if (document.c.link_type[i].value == 'photo' && document.c.link_type[i].checked) {
		   file_url = document.getElementById("photo_fileurl").value.replace("sqr","600x1000");
		   url = document.getElementById("poriginal_url").value;
		   alt_title = document.getElementById("plink_name").value;
		   description = document.getElementById("plink_description").value;

			title = "<img src='" + file_url + "' style='max-width:300px;' alt='" + alt_title + "'/>";		
			bol_news = 0;
			document.getElementById("previ").innerHTML = '';
		}
   }
*/
   description = description.replace(/\</g, "&lt;");
   description = description.replace(/\>/g, "&gt;");
   description = description.replace(/\n/g, "<br>");
   
   description = regexreplace(description,"(\\[b\\])((.|\\s)*?)(\\[\/b\\])","<b>$2</b>");//alert(description);
   description = regexreplace(description,"(\\[quote\\])((.|\\s)*?)(\\[\/quote\\])","<div class='qp pad d'><i>$2</i></div>");
   
   description = description.replace(/\[b\]/gi, "<b>");
   description = description.replace(/\[\/b\]/gi, "</b>");
   description = description.replace(/\[i\]/gi, "<i>");
   description = description.replace(/\[\/i\]/gi, "</i>");
   description = description.replace(/\[u\]/gi, "<u>");
   description = description.replace(/\[\/u\]/gi, "</u>");
  // description = description.replace(/(\<div style='display:block;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|&)+)(\<\/a\>\<\/div\>)/g,"[url=$2]$5[/url]")
  description = description.replace(/(\[url=")((\w|\s|:|;|-|\/|\?|\.|=|&|\+)+)(\"\])((.|\s)*?)(\[\/url\])/g,"<a class=\"plime\" href=\"/redir.p?$2\" target=\"_blank\" rel=\"nofollow\">$5</a>")  
   


   var source = "<i class='regular t'>" + document.getElementById("source_alt").value + "</i>";

   var ptml = "<table width='405' cellspacing='10'><tr valign='top'><td><B>";
              ptml += "<a class='plime b' href='" + url + "'  title='" + alt_title + "' target='_blank'>" + title + "</a></b>";

              ptml += "<div class='sub'>" + description + " <i class='t'>" + source + " 1 second ago</i></div>";
              ptml += "<table cellpadding='2' cellspacing='0'><tr><td><span class='regular'><a href='#' onclick='return false' class='page tz td'>comments</a>&nbsp;<a href='#' onclick='return false' class='page tz td'>related</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>edit</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>email</a>&nbsp;<a class='page tz td plime' href='#' onClick='return false'>" + category + "</a></span>";
              ptml += "</td></tr></table>";

              ptml += "</td><td width='1' nowrap>";
              ptml += "<table cellpadding='0' cellspacing='0'><tr><td align='center' nowrap>";
              ptml += "<span class='arrowup-voted'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "<span class='plime' style='padding:3px'><b>" + ul + "</b></span>";
              ptml += "<span class='arrowdown'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "</td></tr></table>";

              ptml += "</td></tr></table>";
              
   if (document.getElementById("image_fileid").value != image_fileid || document.getElementById("image_id").value != image_id) {
		   previ();  
    }

   document.getElementById("prevn").innerHTML = ptml;


}

function prevs() {
 setTimeout('prevp()',100);
}

function prevp() {

var bol_news = 1;

   var category = document.getElementById("plime_id").options[document.getElementById("plime_id").selectedIndex].text;
   category = category.replace(/\.\.\./g,"");
   var url = document.getElementById("original_url").value;
   var alt_title = document.getElementById("link_name").value;
   var description = document.getElementById("link_description").value;
   var file_url = document.getElementById("image_fileurl").value.replace("sqr","600x1000");
	
	var title = "<img src='" + file_url + "' style='max-width:300px;' alt='" + alt_title + "'/>";
			document.getElementById("previ").innerHTML = '';
	
   description = description.replace(/\</g, "&lt;");
   description = description.replace(/\>/g, "&gt;");
   description = description.replace(/\n/g, "<br>");
   
   description = regexreplace(description,"(\\[b\\])((.|\\s)*?)(\\[\/b\\])","<b>$2</b>");//alert(description);
   description = regexreplace(description,"(\\[quote\\])((.|\\s)*?)(\\[\/quote\\])","<div class='qp pad d'><i>$2</i></div>");
   
   description = description.replace(/\[b\]/gi, "<b>");
   description = description.replace(/\[\/b\]/gi, "</b>");
   description = description.replace(/\[i\]/gi, "<i>");
   description = description.replace(/\[\/i\]/gi, "</i>");
   description = description.replace(/\[u\]/gi, "<u>");
   description = description.replace(/\[\/u\]/gi, "</u>");
  // description = description.replace(/(\<div style='display:block;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|&)+)(\<\/a\>\<\/div\>)/g,"[url=$2]$5[/url]")
  description = description.replace(/(\[url=")((\w|\s|:|;|-|\/|\?|\.|=|&|\+)+)(\"\])((.|\s)*?)(\[\/url\])/g,"<a class=\"plime\" href=\"/redir.p?$2\" target=\"_blank\" rel=\"nofollow\">$5</a>")  
   


   var source = "<i class='regular t'>" + document.getElementById("source_alt").value + "</i>";

   var ptml = "<table width='405' cellspacing='10'><tr valign='top'><td><B>";
              ptml += "<a class='plime b' href='" + url + "'  title='" + alt_title + "' target='_blank'>" + title + "</a></b>";

              ptml += "<div class='sub'>" + description + " <i class='t'>" + source + " 1 second ago</i></div>";
              ptml += "<table cellpadding='2' cellspacing='0'><tr><td><span class='regular'><a href='#' onclick='return false' class='page tz td'>comments</a>&nbsp;<a href='#' onclick='return false' class='page tz td'>related</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>edit</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>email</a>&nbsp;<a class='page tz td plime' href='#' onClick='return false'>" + category + "</a></span>";
              ptml += "</td></tr></table>";

              ptml += "</td><td width='1' nowrap>";
              ptml += "<table cellpadding='0' cellspacing='0'><tr><td align='center' nowrap>";
              ptml += "<span class='arrowup-voted'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "<span class='plime' style='padding:3px'><b>" + ul + "</b></span>";
              ptml += "<span class='arrowdown'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "</td></tr></table>";

              ptml += "</td></tr></table>";
              
			document.getElementById("previ").innerHTML = '';

   document.getElementById("prevn").innerHTML = ptml;


}

function prevw() {
 setTimeout('prevv()',100);
}

var vidrefresh = true;
function prevv() {

var bol_video = 1;

   var category = document.getElementById("plime_id").options[document.getElementById("plime_id").selectedIndex].text;
   category = category.replace(/\.\.\./g,"");
   var url = document.getElementById("original_url").value;
   var alt_title = document.getElementById("link_name").value;
   var description = document.getElementById("link_description").value;
	var title;
	

	if ($("#old_url").val() != $("#original_url").val() || vidrefresh == true) {

		$.ajax({
		   type: "POST",
		   url: "/formatVideo.asp",
		   async: false,
		   data: "url=" + url + "&dh=" + new Date().getTime(),
		   success:function(embedCode){
			
				title = embedCode;
				if (!vidrefresh) {
					document.getElementById("title").innerHTML = title;
				}
			
			}

		});
	}
	$("#old_url").val($("#original_url").val()) ;
	
	
//	title = videohack(url);
   description = description.replace(/\</g, "&lt;");
   description = description.replace(/\>/g, "&gt;");
   description = description.replace(/\n/g, "<br>");
   
   description = regexreplace(description,"(\\[b\\])((.|\\s)*?)(\\[\/b\\])","<b>$2</b>");//alert(description);
   description = regexreplace(description,"(\\[quote\\])((.|\\s)*?)(\\[\/quote\\])","<div class='qp pad d'><i>$2</i></div>");
   
   description = description.replace(/\[b\]/gi, "<b>");
   description = description.replace(/\[\/b\]/gi, "</b>");
   description = description.replace(/\[i\]/gi, "<i>");
   description = description.replace(/\[\/i\]/gi, "</i>");
   description = description.replace(/\[u\]/gi, "<u>");
   description = description.replace(/\[\/u\]/gi, "</u>");
  // description = description.replace(/(\<div style='display:block;width:300px;overflow:hidden;'\>\<a class="plime" href="\/redir.p\?)((\w|:|;|-|\/|\?|\.|=|&)+)(" rel="nofollow"\>)((\w|\s|:|;|-|\/|\?|\.|=|&)+)(\<\/a\>\<\/div\>)/g,"[url=$2]$5[/url]")
  description = description.replace(/(\[url=")((\w|\s|:|;|-|\/|\?|\.|=|&|\+)+)(\"\])((.|\s)*?)(\[\/url\])/g,"<a class=\"plime\" href=\"/redir.p?$2\" target=\"_blank\" rel=\"nofollow\">$5</a>")  
   


   var source = "<i class='regular t'>" + document.getElementById("source_alt").value + "</i>";
   
   if(vidrefresh) {
     var ptml = "<table width='405' cellspacing='10'><tr valign='top'><td><B>";
              ptml += "<a class='plime b' id='title' href='" + url + "'  title='" + alt_title + "' target='_blank'>" + title + "</a></b>";

              ptml += "<div id='details'>";
              ptml += "<div class='sub'>" + description + " <i class='t'>" + source + " 1 second ago</i></div>";
              ptml += "<table cellpadding='2' cellspacing='0'><tr><td><span class='regular'><a href='#' onclick='return false' class='page tz td'>comments</a>&nbsp;<a href='#' onclick='return false' class='page tz td'>related</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>edit</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>email</a>&nbsp;<a class='page tz td plime' href='#' onClick='return false'>" + category + "</a></span>";
              ptml += "</td></tr></table>";
              ptml += "</div>";

              ptml += "</td><td width='1' nowrap>";
              ptml += "<table cellpadding='0' cellspacing='0'><tr><td align='center' nowrap>";
              ptml += "<span class='arrowup-voted'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "<span class='plime' style='padding:3px'><b>" + ul + "</b></span>";
              ptml += "<span class='arrowdown'><a href='#' onclick='return false'><!--n--></a></span>";
              ptml += "</td></tr></table>";

              ptml += "</td></tr></table>";
              

			document.getElementById("prevn").innerHTML = ptml;

 
	vidrefresh = false;
   } else {
   
	   var ptml = "<div class='sub'>" + description + " <i class='t'>" + source + " 1 second ago</i></div>";
	              ptml += "<table cellpadding='2' cellspacing='0'><tr><td><span class='regular'><a href='#' onclick='return false' class='page tz td'>comments</a>&nbsp;<a href='#' onclick='return false' class='page tz td'>related</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>edit</a>&nbsp;<a class='page tz td' href='#' onClick='return false'>email</a>&nbsp;<a class='page tz td plime' href='#' onClick='return false'>" + category + "</a></span>";
	              ptml += "</td></tr></table>";
	              

	   document.getElementById("details").innerHTML = ptml;
   
   }



}
/*
function videohack(lurl) {


                                var strVideo,intDot;


                                
                    //            'BRIGHTCOVE HACK
                      //          '============
                                intDot = lurl.toLowerCase().indexOf("brightcove.com/title.jsp?title=");

                                if (intdot > 0) {

                                      strVideo =lurl.substring(intDot + 31);
                                      
                                      intDot = strVideo.indexOf("&")
                                      if(intDot > 0) {
                                            strVideo = strVideo.substring(0,intDot-1);
                                      }

                                      varStr = "<p align='center'>"  +
                                               "<object width=""486"" height=""412"">" +
                                               "<embed src='http://admin.brightcove.com/destination/player/player.swf' bgcolor='#FFFFFF'" +
                                               " flashVars='allowFullScreen=true&initVideoId=" + strVideo + "&servicesURL=http://services.brightcove.com/services&viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&cdnURL=http://admin.brightcove.com&autoStart=false'" +
                                               " base='http://admin.brightcove.com' name='bcPlayer' width='486' height='412' allowFullScreen='true' allowScriptAccess='always' seamlesstabbing='false'" +
                                               " type='application/x-shockwave-flash' swLiveConnect='true' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></embed>" +
                                               "</object><noembed><a href='http://www.plime.com/redir.p?" + lurl + "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                }

                                'COLLEGEHUMOR HACK
                                '=================
                                intDot = lurl.toLowerCase().indexOf("collegehumor.com/video:");


                                if (intdot > 0) {

                                      strVideo =lurl.substring(intDot + 23);


                                      if (strVideo.substring(strVideo.length) == "/") {
                                            strVideo = strVideo.substring(0,strVideo.length-1);
                                      }

                                      intDot = strVideo.indexOf("/ls");

                                      if (intDot > 0) {
                                            strVideo = strVideo.substring(0,intDot-1)
                                      }

                                      varStr = "<p align='center'>"  +
                                               "<object width=""400"" height=""300"">" +
                                               "<embed src=""http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=""" + strVideo + """" +
                                               " quality=""best"" width=""400"" height=""300"" type=""application/x-shockwave-flash"" wmode=""transparent""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" + lurl + "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                }
                                /*
                                'GAMETRAILERS HACK
                                '=================
                                intDot = instr(Lcase(lurl),"gametrailers.com/umwatcher.php?id=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 34)

                                      varStr = "<p align='center'>"  +
                                               "<object classid=""clsid:d27cdb6e-ae6d-11cf-96b8-444553540000""  codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"" id=""gtembed""" +
                                               " width=""480"" height=""409"">	<param name=""allowScriptAccess"" value=""sameDomain"" /> <param name=""movie"" value=""http://www.gametrailers.com/remote_wrap.php?umid=" & strVideo & """/>" +
                                               " <param name=""quality"" value=""high"" /> <embed src=""http://www.gametrailers.com/remote_wrap.php?umid=" & strVideo & """" +
                                               " swLiveConnect=""true"" name=""gtembed"" align=""middle"" allowScriptAccess=""sameDomain"" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer""" +
                                               " type=""application/x-shockwave-flash"" width=""480"" height=""409""></embed> </object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

                                'GLUMBERT HACK
                                '=================
                                intDot = instr(Lcase(lurl),"glumbert.com/media/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 19)

                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""496"" height=""372"">" +
                                               "<param name=""movie"" value=""http://www.glumbert.com/embed/" & strVideo & """></param>" +
                                               "<param name=""wmode"" value=""transparent""></param>" +
                                               "<embed width=""496"" height=""372"" src=""http://www.glumbert.com/embed/" & strVideo & """ type=""application/x-shockwave-flash"" wmode=""transparent""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

                                'GOOGLE VIDEO HACK
                                '=================
                                intDot = instr(Lcase(lurl),"google.com/videoplay?docid=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 27)

                                      varStr = "<p align='center'>"  +
                                               "<object width=""375"" height=""300"">" +
                                               "<embed width=""375"" height=""300"" id=""VideoPlayback""" +
                                               " type=""application/x-shockwave-flash"" src=""http://video.google.com/googleplayer.swf?docId=" & strVideo & "&hl=en""> </embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if
                                
                                'GOEAR HACK
                                '============
                                intDot = instr(Lcase(lurl),"goear.com/listen.php?v=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 23)

                                      varStr = "<p align='center'>"  +
                                               "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"" width=""366"" height=""75"">" +
                                               "<param name=""movie"" value=""http://www.goear.com/files/localplayer.swf"" /><param name=""FlashVars"" value=""file=" & strVideo & """ /><param name=""quality"" value=""high"" />" +
                                               "<embed src=""http://www.goear.com/files/localplayer.swf"" flashvars=""file=" & strVideo & """ quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" " +
                                               "type=""application/x-shockwave-flash"" width=""366"" height=""75""></embed></object><noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if


                                'IFILM HACK
                                '=================
                                intDot = instr(Lcase(lurl),"ifilm.com/video/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 16)

                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""448"" height=""365"">" +
                                               "<embed width=""448"" height=""365"" src=""http://www.ifilm.com/efp"" quality=""high""" +
                                               " bgcolor="" & color_3 & "" name=""efp"" align=""middle"" type=""application/x-shockwave-flash"" wmode=""transparent"" " +
                                               "pluginspage=""http://www.macromedia.com/go/getflashplayer"" flashvars=""flvbaseclip=" & strVideo & "&""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"

                                End if


                                'LIVELEAK HACK
                                '=================
                                intDot = instr(Lcase(lurl),"liveleak.com/view?i=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 20)



                                      If right(strVideo,1) = "/" then
                                           strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""450"" height=""370"" wmode=""transparent"" data=""http://www.liveleak.com/player.swf?autostart=false&token=" & strVideo & """>" +
                                               "<param name=""movie"" value=""http://www.liveleak.com/player.swf?autostart=false&token=" & strVideo & """>" +
                                               "<param name=""wmode"" value=""transparent""><param name=""quality"" value=""high""></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

                                
                                'METACAFE HACK
                                '=================
                                intDot = instr(Lcase(lurl),"metacafe.com/watch/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 19)



                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""375"" height=""300"">" +
                                               "<embed width=""375"" height=""300"" id=""VideoPlayback"" type=""application/x-shockwave-flash"" src=""http://www.metacafe.com/fplayer/" & strVideo & ".swf""" +
                                               " flashVars=""playerVars=videoTitle=Metacafe|showStats=yes|autoPlay=no|blogName=plime.com|blogURL=http://www.plime.com&playerType=Embed&displayMode=normal""" +
                                               "> </embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if


                                'MYSPACE HACK
                                '=================
                                intDot = instr(Lcase(lurl),"vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 62)


                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""430"" height=""346""><embed width=""430"" height=""346""" +
                                               " src=""http://lads.myspace.com/videos/vplayer.swf"" flashvars=""m=" & strVideo & "&type=video"" type=""application/x-shockwave-flash"" wmode=""transparent""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if


                                'REVVER HACK
                                '=================
                                intDot = instr(Lcase(lurl),"revver.com/watch/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 17)



                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""392"" height=""480"">" +
                                               "<embed type=""application/x-shockwave-flash"" src=""http://flash.revver.com/player/1.0/player.swf"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" scale=""noScale"" " +
                                               "salign=""TL"" bgcolor=""" & color_3 & """ flashvars=""mediaId=" & strVideo & "&affiliateId=68916"" wmode=""transparent"" " +
                                               "height=""392"" width=""480""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if
                                
                                'SUPERDELUXE HACK
                                '=================
                                intDot = instr(Lcase(lurl),"superdeluxe.com/sd/contentdetail.do?id=")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 39)

                                      varStr = "<p align='center'>"  +
                                               "<object width=""400"" height=""350""><param name=""allowFullScreen"" value=""true"" /><param name=""movie"" value=""http://www.superdeluxe.com/static/swf/share_vidplayer.swf"" />" +
                                               "<param name=""FlashVars"" value=""id=" & strVideo & """ /><embed src=""http://www.superdeluxe.com/static/swf/share_vidplayer.swf"" FlashVars=""id=" & strVideo +
                                                """ type=""application/x-shockwave-flash"" width=""400"" height=""350"" allowFullScreen=""true"" ></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

                                'VEOH HACK
                                '=================
                                intDot = instr(Lcase(lurl),"veoh.com/videos/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 16)

                                      intDot = instr(strVideo,";")
                                      If intDot > 0 then
                                            strVideo = left(strVideo,intDot-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""540"" height=""438"">" +
                                               "<embed src=""http://www.veoh.com/videodetails.swf?permalinkId=" & strVideo & "&id=1&player=videodetails&videoAutoPlay=0""" +
                                               " width=""540"" height=""438"" bgcolor=""" & color_3 & """ type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if
                                
                                
                                'VIDMAX HACK
                                '=================
                                intDot = instr(Lcase(lurl),"vidmax.com/index.php/videos/view/")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 33)

                                      intDot = instr(strVideo,"/")
                                      If intDot > 0 then
                                            strVideo = left(strVideo,intDot-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""400"" height=""294"">" +
                                               "<embed src=""http://vidmax.com/img/vidmax_player.swf"" width=""450"" height=""447"" bgcolor=""" & color_3 & """ type=""application/x-shockwave-flash""" +
                                               "  pluginspage=""http://www.macromedia.com/go/getflashplayer"" flashvars=""xml=http://vidmax.com/index.php/videos/playlist/&id=" & strVideo & "&autoPlay=true&bg=http://vidmax.com/img/back.jpg""" +
                                               " scale=""showall"" name=""index"" /></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

                                'VIMEO HACK
                                '=================
                                intDot = instr(Lcase(lurl),"vimeo.com/clip:")

                                If intdot > 0 then

                                      strVideo = mid(lurl,intDot + 15)



                                      If right(strVideo,1) = "/" then
                                            strVideo = left(strVideo,len(strVideo)-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""400"" height=""294"">" +
                                               "<embed width=""400"" height=""294""" +
                                               " src=""http://www.vimeo.com/moogaloop.swf?clip_id=" & strVideo & """ quality=""best"" scale=""exactfit"" type=""application/x-shockwave-flash"" wmode=""transparent""></embed></object>" +
                                               "<noembed><a href='http://www.plime.com/redir.p?" & lurl & "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if


                                'YOUTUBE HACK
                                '============
                                intDot = lurl.toLowerCase().indexOf("youtube.com/watch?v=");

                                if(intdot > 0)

                                      strVideo = mid(lurl,intDot + 20)
                                      
                                      intDot = instr(strVideo,"&")
                                      If intDot > 0 then
                                            strVideo = left(strVideo,intDot-1)
                                      End if

                                      varStr = "<p align='center'>"  +
                                               "<object width=""375"" height=""300"">" +
                                               "<param name=""movie"" value=""http://www.youtube.com/v/" + strVideo + """></param>" +
                                               "<param name=""wmode"" value=""transparent""></param>" +
                                               "<param name=""allownetworking"" value=""internal""></param>" +
                                               "<embed allownetworking=""internal"" src=""http://www.youtube.com/v/" + strVideo + """" +
                                               " type=""application/x-shockwave-flash"" wmode=""transparent"" width=""375"" height=""300""></embed>" +
                                               "</object><noembed><a href='http://www.plime.com/redir.p?" + lurl + "' class='plime' target='_blank' rel='nofollow'><b>flash video</b></a></noembed></p>"
                                End if

			If len(strVideo) > 0 and varPermission < 1 then
				varStr = "<div>" & varStr & "</div>" 
			End if

            return varStr;

}
*/
function regexreplace(str,regx,regp) {
  var re = new RegExp(regx, "g");
  return str.replace(re,regp);
}

//-->