/*   INSERT COPYRIGHT INFORMATION HERE
     *********************************
     INSERT INSTRUCTIONS FOR UPDATING HERE
     *************************************
*/

//***********************************************
//                POSITIONING
//***********************************************

//Position type ( 0 - Static, 1 - Relative, 2 - Dynamic )
var position_type = 1;
//x offset, used for 0-Static or 1-Relative
offsetx = -180;
//y offset, used for 0-Static or 1-Relative
offsety = 0;
//Preset position if above is 2-Dyanmic.  Options are
//0 - Top Left, 1 - Top Middle, 2 - Top Right
//3 - Middle Left, 4 - Middle, 5 - Middle Right
//6 - Bottom Left, 7 - Bottom Middle, 8 - Bottom Right
var preset_position = 8;

//***********************************************
//                TIMING OPTIONS
//***********************************************

//Time to delay showing video on page (0..n seconds)
var delay_time = 0;
//Time for video to remain on page (0..n seconds)
var remain_time = 0;
//Frequency that video shows ( 0 - every time, 1 - once per session, 2 - every x number of days )
var frequency = 0;
//Show video every (0..n) days
var frequency_days = 0;
//Seconds to fade video in for (0..n seconds)
var fadein_seconds = 0;
//Seconds to fade video out for (0..n seconds)
var fadeout_seconds = 0;

//***********************************************
//                FLASH MOVIE OPTIONS
//***********************************************

//URL for flash movie
video_url = '';
//Height of video (in pixels)
video_height = 440;
//Width of video (in pixels)
video_width = 660;
//Percent to buffer video for before playing (0-100)
var video_buffer = 85;
//User must press play button for video to play ( 0 - don't show before video, 1 - show before video )
var play_button_timing_before = 0;
//After movie stops, play button appears to replay ( 0 - don't show after video, 1 - show after video )
var play_button_timing_after = 0;
//Frame to show for Fade In/Fade Out/Mouseovers (0..n where n is last frame of video)
var frame_show_number = 0;
//URL to click to if user clicks video ( blank to not have a clickable video, otherwise a valid url to click to)
var clickable_url = '';
//Window option for clicking to URL above ( 0 - open in new browser window, 1 - open in same browser window )
var clickable_window_option = 0;

delay_time = delay_time * 1000;
remain_time = remain_time * 1000;



function buildURLString() {
	var sURL = "?a=" + video_url;

	if(delay_time > 0)
	      	sURL+= "&b=" + delay_time;
	if(remain_time > 0)
		sURL+= "&c=" + remain_time;
	sURL+= "&d=" + frequency;
	if(frequency_days > 0)
		sURL+= "&e=" + frequency_days;
	if(fadein_seconds > 0)
		sURL+= "&f=" + fadein_seconds;
	if(fadeout_seconds > 0)
		sURL+= "&g=" + fadeout_seconds;
	if(video_buffer > 0)
		sURL+= "&h=" + video_buffer;
	if(play_button_timing_before)
		sURL+= "&j=" + play_button_timing_before;
	if(play_button_timing_after)
		sURL+= "&k=" + play_button_timing_after;
	if(frame_show_number)
		sURL+= "&l=" + frame_show_number;
	if(clickable_url.length > 0) {
		sURL+= "&m=" + clickable_url; 
		sURL+= "&n=" + clickable_window_option;
	}
	
	//add in player controls for showcase
	sURL+= "&q=1";
	return sURL;
}

function buildStyleString() {
	var style_string = '';
	if(position_type == 1)
		style_string = "style='z-index: 1000; margin-left: " + offsetx + "px; margin-top: " + offsety + "px; display: block'";
	return style_string;
}


function launchPlayer(video_location, div_id) {
//	alert(video_location);
	video_url = "http://www.yourwebsitespokesperson.com/" + video_location;
	var url_string = buildURLString();
	var style_string = buildStyleString();

	var flashobj = '<object ' + style_string + ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + video_width + '" height="' + video_height + '" id="player" align="middle">';
	flashobj += '<param name="allowScriptAccess" value="sameDomain" />';
	flashobj += '<param name="allowFullScreen" value="false" />';
	flashobj += '<param name="movie" value="http://www.yourwebsitespokesperson.com/players/swf/player.swf' + url_string + '" />';
	flashobj += '<param name="wmode" value="transparent" />';
	flashobj += '<param name="quality" value="high" />';
	flashobj += '<param name="bgcolor" value="#ffffff" />';
	flashobj += '<embed src="http://www.yourwebsitespokesperson.com/players/swf/player.swf' + url_string + '" wmode="transparent" scale="exactFit" quality="high" bgcolor="#ffffff" width="' + video_width + '" height="' + video_height + '" name="player" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed>';
	flashobj += '</object>';

	oDiv = document.getElementById(div_id);
	oDiv.innerHTML = flashobj;
}

function debug(domain) {
	alert(domain);
}
