function domoviesearch (sWidNum) {
	eval('var sformObj = document.movieSearchForm' + (sWidNum?sWidNum:''));
	for (i=0; i < sformObj.searchby.length; i++) {
		if (sformObj.searchby[i].checked) {
 			var selectedField = sformObj.searchby[i].value;
		}
	}
	var searchQuery = sformObj.qfth.value
	switch (selectedField) {
		case 'movies' :
			str = 'http://www.moviefone.com/search/';
			break;
		default:
			str = 'http://search.aol.com/aol/search?invocationType=searchbox.webhome&query=';
			break;
	}
	realString = str + escape(searchQuery).replace(/\+/g,'%2b');
	parent.location.href = realString;
}

function sf_gg_fetch(n, id) {
	$.getJSON("/_p/p.php?url=" + escape("http://www.globalgiving.com/dy/data/project/gg.json?id=" + id),
		function(data){
			$("#globalgiving_title").html(data.title);
			$("#globalgiving_summary").html(data.summary);
			$("#globalgiving_img").attr("src",data.image);
			$("#globalgiving_title").html(data.title);
			$("#globalgiving_link").attr("href",data.url + "?RF=snagfilms");
			$("#globalgiving_funding").html(data.funding);
			$("#globalgiving_goal").html(data.goal);
			$("#globalgiving_donations").html(data.numberOfDonations);
			$("#globalgiving_content").fadeIn("slow");
		});
}

function sf_selectTab(tab,content) {
	$(".tab").removeClass("current");
	$("#" + tab).addClass("current");
	$(".tab_content").hide();
	$("#" + content).fadeIn("fast");
}

/******** video player ********/

function sf_initVideo(n, pmms, img, play) {
	var w = 600;
	var h = 410;
	var playerId = n + '_' + 824;
	var flashvars = 'assetId=video:asset:pmms:' + pmms + '&playerId=' + playerId + '&autoplay=';
	flashvars += (play) ? ('true') : ('false');
	flashvars += (img != "") ? ('&editorialimg=' + img) : ('');
	flashvars += '&serverBase=http://videoapi.aol.com&rvChannelFilter=AOLNull&commId=42462758471332080000';
	flashvars += '&displaySearch=false&displayUtil=false&displayTopCap=false&sk_color2=0xc9c9c9&sk_color3=0xc9c9c9';
	txt = '<OBJECT id="' + playerId + '" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'; 
	txt += '	width="' + w + '"'; 
	txt += '	height="' + h + '"'; 
	txt += '	padding="0"'; 
	txt += '	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" VIEWASTEXT>';
	txt += '		<PARAM NAME="FlashVars" VALUE="' + flashvars + '">';
	txt += '		<PARAM NAME="allowFullScreen" VALUE="true">';
	txt += '		<PARAM NAME="Movie" VALUE="http://o.aolcdn.com/mediaplayer/players/fpm/fpm.swf">';
	txt += '		<PARAM NAME="src" VALUE="http://o.aolcdn.com/mediaplayer/players/fpm/fpm.swf">';
	txt += '		<PARAM NAME="AllowScriptAccess" VALUE="always">';
	txt += '		<PARAM NAME="AllowNetworking" VALUE="all">';
	txt += '		<PARAM NAME="wmode" VALUE="transparent">';
	txt += '		<embed src="http://o.aolcdn.com/mediaplayer/players/fpm/fpm.swf"'; 
	txt += '			FlashVars="' + flashvars + '"'; 
	txt += '			quality="high"'; 
	txt += '			width="' + w + '"'; 
	txt += '			height="' + h + '"'; 
	txt += '			name="' + playerId + '"';
	txt += '			allowScriptAccess="always"'; 
	txt += '			allowFullScreen="true" ';
	txt += '			type="application/x-shockwave-flash" ';
	txt += '			wmode="transparent"';
	txt += '			pluginspage="http://www.macromedia.com/go/getflashplayer">';
	txt += '		</embed>';
	txt += '</OBJECT>';

	var node = document.getElementById(n);
	if (node != null) {
		node.innerHTML = txt;
		$(".video_frame_container").fadeIn("fast");
	}
}

function sf_selectVideo(n, id, img, btn) {
	sf_initVideo(n, id, img, false);
	$(".item a").removeClass("hl");
	if (btn) {	
		$("#" + btn).addClass("hl");
	}
}

function sf_playVideo(n, id, btn) {
	sf_initVideo(n, id, "", true);
	$(".item a").removeClass("hl");
	if (btn) {	
		$("#" + btn).addClass("hl");
	}
}

function sf_setVideoImageMetadata(n, img, title, url) {
	if (n) {
		if (null == img) {	
			$("#" + n).html("<!-- 0 -->");
		} else {
			if (url) {
				$("#" + n).html("<a href=\"" + url + "\"><img src=\"" + img + "\" alt=\"" + title + "\" /></a>");
			} else {
				$("#" + n).html("<img src=\"" + img + "\" alt=\"" + title + "\" />");
			}
		}
	}
}

function sf_setVideoMetadata(n, title) {
	if (n) {
		$("#" + n).html(title);
	}
}

function sf_hideExtras(n) {
	if (n) {
		$("#" + n).hide();
	}
}

function sf_showExtras(n) {
	if (n) {
		if ($("#" + n).css("display") == "none") {
			$("#" + n).fadeIn("fast");
		} else {
			$("#" + n).hide();
		}
	}
}

/******** widget ********/

function sf_initFilmWidgetIE(feed,id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" quality="high" id="W48445d75c7144604">';
	s += '<param value="' + feed + id + '" name="movie"/>';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s);
}

function sf_initFilmWidget(feed,id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" id="W48445d75c7144604" data="' + feed + id + '">';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s); 
}

function sf_initFilmWidget2(n,feed,id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" id="W48445d75c7144604" data="' + feed + id + '">';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	$(document).ready(function(){
		$("#"+n).html(s); // fix for safari
	});
}

function sf_initQuizWidgetIE(feed, id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" quality="high" id="W4900ad15f9492b32">';
	s += '<param value="' + feed + id + '" name="movie"/>';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s);
}

function sf_initQuizWidget(feed, id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" id="W4900ad15f9492b32" data="' + feed + id + '">';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s);
}

function sf_initCategoryWidgetIE(feed,id) {
	var s ='<object width="300" height="250" type="application/x-shockwave-flash" quality="high" id="W48445ebfd0c7d171">';
	s += '<param value="' + feed + id + '" name="movie"/>';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s);
}

function sf_initCategoryWidget(feed,id) {
	var s = '<object width="300" height="250" type="application/x-shockwave-flash" id="W48445ebfd0c7d171" data="' + feed + id + '">';
	s += '<param name="wmode" value="transparent"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/></object>';
	document.write(s);
}

function sf_seg(n, id) {
	var url = "/_p/p.php?url=" + escape("http://m.snagfilms.com/films/seg/" + id);
	$("#"+n).load(url);
}





