function writeTrailer(link, autoplay) {

	if(autoplay == 1) {

		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="650" height="370"> <param name="movie" value="/flash/trailer.swf?movieURL=' + link + '&Skin=flash/ClearOverAll.swf"> <param name="allowFullScreen" value="true" /> <param name="quality" value="high"> <embed src="/flash/trailer.swf?movieURL=' + link + '&Skin=flash/ClearOverAll.swf&autoplay=1" quality="high" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="370"></embed></OBJECT>');
		
	} else {
		
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="650" height="370"> <param name="movie" value="/flash/trailer.swf?movieURL=' + link + '&Skin=flash/ClearOverAll.swf"> <param name="allowFullScreen" value="true" /> <param name="quality" value="high"> <embed src="/flash/trailer.swf?movieURL=' + link + '&Skin=../../flash/ClearOverAll.swf" quality="high" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="650" height="370"></embed></OBJECT>');
		
	}

}

function cropImage() {

	/*
	
		Capture all variables associated
		
	*/
	
	var image = document.getElementById('yui_img').src;
	
	var croptop = document.getElementById('croptop').value;
	
	var cropleft = document.getElementById('cropleft').value;
	
	var cropheight = document.getElementById('cropheight').value;
	
	var cropwidth = document.getElementById('cropwidth').value;
	
	/*
		
		PHP FUNCTION:
		cropImage($img, $w, $h, $sx, $sy, $filename) {
	
		croptop = region.top;
		cropleft = region.left;	
		cropwidth = region.height;
		cropheight = region.width;	
	*/

	var ajx = ajax();
	ajx.open('open', 'includes/ajax.php?action=crop&file=' + image + '&width=' + cropwidth + '&height=' + cropheight + '&top=' + croptop + '&left=' + cropleft + '&random=' + Math.random(9999999999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
			
			document.location.href = 'my_account.php';

		
		}
		
	}
	ajx.send(null);
	
}

function qikajax(func,val) {
	
	alert("This item has been flagged for admin review");
	
	var ajx = new ajax();
	ajx.open('get','/filmfinder/includes/ajax.php?action=' + func + '&val=' + val + '&rand=' + Math.random(999999999));
	ajx.onreadystatechange = function () {
		if(ajx.readyState == 4) {
			
			
			
		}
	}
	ajx.send(null);
	
}

var adminSpotlight_type = "edit";
var adminTopSpotlight_type = "edit";


function showAdminForm_spotlight(type) {
	if(type == "add") {
		document.getElementById('admin_spotlight_title').value = "";
		document.getElementById('admin_spotlight_text').value = "";
	}
	document.getElementById('admin_form_spotlight').style.display = "block";
}
function hideAdminForm_spotlight() {
	document.getElementById('admin_form_spotlight').style.display = "none";
}



// Top Form

function showAdminForm_topspotlight(type) {
	document.getElementById('mast_spot_edit').style.display = "block";
	document.getElementById('mast_spot_content').style.display = "none";
}
function hideAdminForm_topspotlight() {
	document.getElementById('mast_spot_edit').style.display = "none";
	document.getElementById('mast_spot_content').style.display = "block";
}

function saveTopSpotlight() {
	var title = document.getElementById('admin_top_spotlight_title').value;
	var text = document.getElementById('admin_top_spotlight_text').value;
	var url = document.getElementById('admin_top_link').value;
	
	document.getElementById('admin_top_spotlight_loading').innerHTML = '<br><br><br><center><img src="images/loading.gif" height="24" width="24" alt="loading" /></center><br><br><br>';
	
	//run the ajax
	var ajx = new ajax;
	ajx.open('get', 'includes/ajax_admin.php?action=saveTopSpotlight&url='+escape(url)+'&title='+escape(title)+'&text='+escape(text)+'&random='+Math.random(99999));
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			if(ajx.responseText == 'successful') {
				document.getElementById('admin_top_spotlight_loading').innerHTML = '';
				document.getElementById('spotlight_title').innerHTML = title;
				document.getElementById('spotlight_text').innerHTML = text;
				alert("The top spotlight was saved. Reloading page.");
				document.location.href = document.location;
			} else {
				document.getElementById('admin_top_spotlight_loading').innerHTML = '';
				alert("There was an error saving the spotlight.");
			}
		}

	}
	ajx.send(null);

}

function closeoverlay() {

	document.getElementById('TB_overlay').innerHTML = '';
	document.getElementById('TB_overlay').id = "";

}