var IE = document.all?true:false;

function write_em(link_desc, em_subj) {
	var u="video";
	var h="escapepodfilms";
	
	document.write("<a href='mailto:" + u + "@" + h + ".com")
	if (em_subj != '')
		document.write("?subject="+em_subj);
	document.write("'>")
	
	if (link_desc != '')
		document.write(link_desc);
	else
		document.write(u + "@" + h + '.com');
		
	document.write("</a>")
}

function blogStart() {
	var list=document.getElementById('epfArchiveList');
	var items=list.getElementsByTagName('li');
	var new_ul=document.createElement('ul');
	
	while (items.length>0)
		new_ul.appendChild(list.removeChild(items[items.length-1]));
	items=new_ul.getElementsByTagName('li');
	while (items.length>0)
		list.appendChild(new_ul.removeChild(items[0]));
}

function tweetImitate(doPreview) {
	var tweet;
	var tweeter=document.getElementById('twitteruser').value;
	if (tweeter=='')
		tweet="Duhhh";
	else
		tweet="RT @" + tweeter + ' Duhhh, I\'m ' + tweeter;
	
	tweet += "! DUH DUH DUH! #imitationofyou";
	
	if (doPreview)
		document.getElementById('tweetpreview').innerHTML=tweet;
	else 
		centerPopNav("http://twitter.com/home?status="+ URLEncode(tweet),'twitterrr',600,400)
}

function tweetAuto() {

	centerPopNav("http://twitter.com/home?status="
	+ URLEncode(document.getElementById('atweetpreview').innerHTML + ' #autotweet') 
	,'twitterrr',600,400)
}


function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function centerPopNav(url,name,size_w,size_h) {
	var win_w=size_w;
	var win_h=size_h;
	
	if (win_w>=screen.width)
		win_w=screen.width/2;
	
	if (win_h>=screen.height)
		win_h=screen.height/2;
	
	var features='scrollbars=yes,resizable=yes,width='+win_w+',height='+win_h
	+',left='+((screen.width/2)-(win_w/2))+',top='+((screen.height/2)-(win_h/2));
	var oldPopStyle = false;
	
	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)
		oldPopStyle=true;
	window.name='mainWin';
	if (oldPopStyle)
		popBox = window.open(url,name,features); 
	else {
		popBox = window.open(url,name,features);
		popBox.focus();
	}
}

function vid_credB(v_num) {
	var cred_box = document.getElementById('v_credits');
	if (cred_box.style.display=='')
		cred_box.style.display='none';
	else 
		cred_box.style.display='';
}