
// common scripts

function del_req(del_url)
{
var myurl=del_url;
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=450,height=240,left=50,top=50';
window.open(myurl, "Check_Feeds", props);
}


var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}


// optional fields

options_hidden = true;

function Show_Options()
{
	if (options_hidden)
	{
		document.getElementById('optional_website').style.display='block';
		document.getElementById('optional_description').style.display='block';
		document.getElementById('optional_website_field').style.display='block';
		document.getElementById('optional_description_field').style.display='block';
		document.getElementById('options_link').innerHTML = '';
		options_hidden = false;
	}
	else
	{
		document.getElementById('optional_website').style.display='none';
		document.getElementById('optional_description').style.display='none';
		document.getElementById('optional_website_field').style.display='none';
		document.getElementById('optional_description_field').style.display='none';
		document.getElementById('options_link').innerHTML = '(+) show optional fields';
		options_hidden = true;
	}

	return false;
}


function Clear_Optional (e) {
	if (e && e.value == 'optional')
		e.value = '';
}

function Copy(txt)
{
	window.clipboardData.setData('text', txt.replace(/&amp;/g,'&'));
	window.status="Code copied to clipboard.";
	setTimeout("window.status=''",3000)
}

function CopyElement(src)
{
	txt = document.getElementById(src).innerHTML;
	Copy(txt);
}


function CopyHTMLLinkBack(txt1, txt2)
{
var a="<a href='" + txt1 + "'>" + txt2 + "</a>";
window.clipboardData.setData('text', a);
window.status="Code copied to clipboard.";
setTimeout("window.status=''" ,3000)
}



function my_popup(myurl)
{
var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=420,height=220,left=50,top=50';
window.open(myurl, "Report Abusive File", props);
}


// replays the video by rewriting the contents of the outer div
// causes a flash but can't be helped
function _video_replay(div) {
	odiv = document.getElementById(div)
	var text = odiv.innerHTML + ' ';
	odiv.innerHTML = '';
	odiv.innerHTML = text;
}


function video_replay(div) {
	odiv = document.getElementById(div)

	if (!odiv.outerHTML) // netscape etc
		return _video_replay(div);

  // Walk through all `<object>`s in the HTML...
  var _objectElms = odiv.getElementsByTagName("object");
  for (var i = 0, _objectElm; (_objectElm = _objectElms[i]); i++)
  {
    // First collect a snapshot of the html for the <object> `childNodes`
    // ...because IE is weird about outerHTML/innerHTML for `<object>`s.
    var _paramHTML = "";
    for (var j = 0, _childNode; (_childNode = _objectElm.childNodes[j]); j++)
    {
      _paramHTML += _childNode.outerHTML;
    }
    // Then clone and replace the `_objectElm` in the DOM and insert `_paramHTML`.
    _objectElm.outerHTML = _objectElm.outerHTML.replace(/(<\/object>$)/i, _paramHTML+"$1");
  }
}

function LTWH() {
// IE6 work around thanks to quirksmode http://www.quirksmode.org/index.html?/js/doctypes.html
	ie6doc = document.documentElement.scrollTop;
	x = ie6doc ? document.documentElement.scrollLeft:document.body.scrollLeft;//
	y = ie6doc ? document.documentElement.scrollTop:document.body.scrollTop;//
	w = ie6doc ? document.documentElement.clientWidth:document.body.clientWidth;//
	h = ie6doc ? document.documentElement.clientHeight:document.body.clientHeight;//

	return [x,y,w,h];
}


var screenmode = 'normal';
var normalx = '';
var normaly = '';
var normalw = '';
var normalh = '';

function fullscreen() {
	md = document.getElementById('fsDiv')
	ie6doc = document.documentElement.scrollTop;
	if (screenmode == 'normal') {
		normalx = md.style.left;
		normaly = md.style.top;
		normalw = md.style.width;
		normalh = md.style.height;
		if (ie6doc != null) {
			md.style.position = 'absolute';
		}
		tl = LTWH();
		md.style.left = tl[0]+'px';
		md.style.top = tl[1]+'px';
		md.style.width = tl[2]+'px';
		md.style.height = tl[3]+'px';
		screenmode = 'fullscreen';
	}
	else {
		if (ie6doc != null) {
			md.style.position = 'relative';
		}
		md.style.left = normalx;
		md.style.top = normaly;
		md.style.width = normalw;
		md.style.height = normalh;
		screenmode = 'normal';
	}
}

function videoComplete() {
}

