/**
 * @author ttyack
 */
documentReady("mediaReleaseVideo");
function mediaReleaseVideo()
{	
	if(jQuery("[id*='helpMeChooseButton']").length > 0)
	{
		addVideoOverlay();
	    jQuery("[id*='helpMeChooseButton']").click(
			function()
		    {
				openVideoPreview($(this).attr("href"));
				return false; // don't let the form submit
			}
		);
	}
}

var videoApi;
function addVideoOverlay()
{
	jQuery(function() { 
		videoApi = jQuery("#videoOverlay").overlay({oneInstance: false, api:true, clickable: true, expose: '#000'}); 
     
		videoApi.onClose( // When the video window is closed this callback function is fired
		function(){ jQuery(".videoWrap").html("");  }
		);
		
        // define function that opens the overlay 
        window.openVideoPreview = function(previewPageURL) { 
			var wrap = videoApi.getOverlay().find("div.videoWrap");
            var previewData = {};
			
            startVideoTemplate();
            
			
			// Hide those items only needed by the gallery
            videoApi.load(); 
        }
    });  
}


/**
 * @author ttyack
 */
function startVideoTemplate()
{
	addTopMovieCarousel("helpMeChooseLocation", 780,  512, "HelpMeChooseAlternative");
}

function addTopMovieCarousel(id, width, height, alt)
{
	var flashvars = {};
	if (location.host.search("myob.com.au") >= 0) {
		var params = { SALIGN: "tl", bgcolor: "#000000", base: "/resources/product_selector/" };
		urchinTracker('/MYOB2/MYOBAU-HOME/Business/Help-Me-Choose/productlist');		
	} else if (location.host.search("myob.co.nz") >= 0) {
		var params = { SALIGN: "tl", bgcolor: "#000000", base: "/resources/product_selector_nz/" };
		urchinTracker('/MYOBNZ2/MYOBNZ-HOME/Business/Help-Me-Choose/productlist');
	}
	//var params = { SALIGN: "tl", bgcolor: "#000000", base: "/resources/product_selector/" };
	var attributes = {};
	
	params.wmode = "opaque";
	
	var myMovie = escape(jQuery("#helpMeChooseLocation").attr("class"));
	//alert(myMovie);
	var expressInstall = "swfobject/expressInstall.swf";
	
	swfobject.embedSWF(myMovie, alt, width, height, "9.0.0", expressInstall, flashvars, params, attributes);
}

