function emailFriend() {
	var emf = $('emailFriend');
	if (emf.byline.value == "none") {
		emf.byline.value = "FOX News";
	}
	if (window.location == "http://www.foxnews.com/story/0,2933,18502,00.html" || window.location == "http://www.foxnews.com/story/0,2933,20055,00.html") {
		emf.date.value = "";
	}
	var w = 750;
	var h = 400;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	emf.url.value = window.location;
	var winprops = "height="+h+",width="+w+",resizable='no',top="+wint+",left="+winl;
	var thiswin = window.open("","emailFriendWindow",winprops);
	thiswin.focus();
	emf.target = "emailFriendWindow";
	emf.action += '?' + ranNum;
	emf.submit();
}

function largePhoto(photo,caption,credit,pW,pH) {
	this.photo = photo;
	this.caption = caption;
	this.credit = credit;
	this.width = pW;
	this.height = pH;
}

function mainPhoto(photo,credit) {
	this.photo = photo;
	this.credit = credit;
}

function newPhPop(p) {
	var winW = photoRefs[p].width + 20;
	var winH = photoRefs[p].height + 130;
	var winl = (screen.width - winW) / 2;
	var wint = (screen.height - winH) / 2;
	var dimensions = 'height='+winH+',width='+winW+',top='+wint+',left='+winl+',resizable=no';
	var phUrl = "/js/photoPop.html?"+p;
	window.open(phUrl,'foxPhoto',dimensions);
}

function themeLink(s){
	if(s.selectedIndex > 0){
		var v = s.options[s.selectedIndex].value;
		v.indexOf("http://") == 0 ? window.open(v) : v.indexOf("javascript:") == 0 ? eval(v) : window.location = v;
	}
}

var rst = {
	next : function(t){
			var id = t.id;
			moveNext(id.substring(5),'gallery',5);
			return false;
	},
	prev : function(t){
			var id = t.id;
			movePrev(id.substring(5),'gallery',5);
			return false;
	},
	  gallery_content_a : function(t){
			var id = t.id;
			$('gallery_main').src='/images/'+photoImgs[id.substring(6)].photo;
			$$('a.gmain')[0].id='gmain_'+id.substring(6);
			$('gallery_credit').innerHTML=unescape(photoImgs[id.substring(6)].credit);
			$('gallery_strut').innerHTML=unescape(photoRefs[id.substring(6)].caption);
			$('gallery_caption').innerHTML=unescape(photoRefs[id.substring(6)].caption);
			return false;
	},
	 gmain : function(t){
			var id = t.id;
			newPhPop(id.substring(6));
			return false;
	},
	email_friend : function(t) {
			emailFriend();
			return false;
	}
};

var onload_story = function() {

	var els,kdz,kdw,kdm,kdf,lnx;

	 els = $A(document.getElementsByClassName('gallery_content','*'));
	els.each (function(el) {
		kdz = el.getElementsByTagName("LI");
		if (isie) {
			kdw = parseFloat(getElementStyle(kdz[0],'width'));
			kdm = parseFloat(getElementStyle(kdz[0],'margin-right'));
			kdf = kdw+kdm;
			kdz = kdz.length;
			el.style.width = (((kdz-1)*kdf)+kdw)+'em';
		} else {
			kdw = parseInt(getElementStyle(kdz[0],'width'));
			kdm = parseInt(getElementStyle(kdz[0],'margin-right'));
			kdf = kdw+kdm;
			kdz = kdz.length;
			el.style.width = ((1/12)*(((kdz-1)*kdf)+kdw))+'em';
		}
		 });
};

function getTools(t){
  var st;
  for(var i=0;i<t.childNodes.length;i++){
    var c=t.childNodes[i];
    if(c.nodeName == 'UL') return c;
  }
}
function toggleTools(t,d){
  getTools(t).style.display = d;
}
Digg = {
  remoteSubmit:function(a,b,c,d){
    var s='99d1febfbc0f579a6c3bb3559bbe7ace';if(!a)return;b=b||'';c=c||'';d=d||'';
    window.open('http://digg.com/remote-submit?phase=2&url='+a+'&title='+b+'&bodytext='+c+'&topic='+d+'&s='+s, new Date().getTime(),'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=600');
  }
}

Delicious = {
  remoteSubmit: function(url, title) {
    if(!url) return; title = title || '';
    window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title, new Date().getTime(),'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=400');
  }
}

function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

function farkItButton(h, u, s, b) {  if (!IsDef(h)) {
    if (IsDef(window.fark_headline)) {
      h = window.fark_headline;
    } else {
      h = '';
    }
  }
  u = unescape(location.href);
  var img = 'FarkItButton2_16x16.gif'; imgw = 16; imgh = 16;
  if(b){
    document.write('<a style="background-image:url(\'http://img.fark.net/pub/' + img + '\');" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=' + h + '&u=' + u + '" title="Fark It!" target="_blank">Fark It!</a>');
  } else {
    document.write('<a href="http://cgi.fark.com/cgi/fark/farkit.pl?h=' + h + '&u=' + u + '" title="Fark It!" target="_blank"><img id="farkitButton" src="http://img.fark.net/pub/' + img + '" width="' + imgw + '" height="' + imgh + '" border="0"></a>');
  }
}

function IsDef(variable) {
  return (!(!( variable||false )))
}

function GetThis(T, C, U, L) {
  var targetUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
  window.open(targetUrl);
}

Event.observe(window,'load',onload_story,false);
