jQuery(document).ready(function() {
    
    jQuery('#spotCarousel').jcarousel({
        vertical: false,
        scroll: 1,
        buttonNextHTML:"<div id='nextBtn'><img alt='' src='/Files/Templates/AttentionFilm.VideoSpotModule/images/fwdBtn.jpg' /></div>",
        buttonPrevHTML:"<div id='prevBtn'><img alt='' src='/Files/Templates/AttentionFilm.VideoSpotModule/images/backBtn.jpg' /></div>",
        itemVisibleInCallback: itemVisible,
        buttonNextCallback: nextCallback,
        buttonPrevCallback: prevCallback
    });
    document.getElementById("prevButton").appendChild(document.getElementById("prevBtn"));
    document.getElementById("nextButton").appendChild(document.getElementById("nextBtn")); 
});

function itemVisible(carousel, item, idx, state) 
{
	document.getElementById("currentPageNo").innerHTML = idx;  
};

function nextCallback(carousel, button, enabled) 
{
    if(enabled)
        button.style.cursor = "pointer";
    else
        button.style.cursor = "default";

};

function prevCallback(carousel, button, enabled) 
{
    if(enabled)
        button.style.cursor = "pointer";
    else
        button.style.cursor = "default";    
};

function loadVideo(vidId)
{
	var temp = getVidById(vidId);	
	Base.Get("#title").innerHTML = temp.title;
	Base.Get("#created").innerHTML = temp.creationDate;
	Base.Get("#descriptionSpan").innerHTML = temp.description;
	Base.Get("#categoryNameLink").innerHTML = temp.categoryName;
	//if(request("test")=="true")
	//	alert(temp.urlEncodedPath);
	var swoof = new SWFObject("/CustomModules/Fonqi.VideoModule/Scripts/player/player.swf","ply","472","290","9","#FFFFFF");
	swoof.addParam("allowfullscreen","true");
	swoof.addParam("allowscriptaccess","always");
	swoof.addParam("flashvars","file="+temp.urlEncodedPath+"&image=preview.jpg&skin=/CustomModules/Fonqi.VideoModule/Scripts/player/skin.swf&fullscreen=true&autostart=true&repeat=list&linkfromdisplay=true&linktarget=_blank");
	swoof.write("container");
	currentVideoId = vidId;
	var embedScript = "<embed src='http://attentionfilm.net.dynamicweb.dk/CustomModules/Fonqi.VideoModule/Scripts/player/player.swf' width='500' height='319' bgcolor='#' allowscriptaccess='always' allowfullscreen='true' flashvars='file=http%3a%2f%2fattentionfilm.net.dynamicweb.dk%2fDefault.aspx%3fID%3d9%26playList%3dtrue%26videoID%3d"+currentVideoId+"&amp;image=preview.jpg&amp;skin=http://attentionfilm.net.dynamicweb.dk/CustomModules/Fonqi.VideoModule/Scripts/player/skin.swf&amp;fullscreen=true&amp;autostart=true&amp;repeat=list&amp;linkfromdisplay=true&amp;linktarget=_blank'/>";
	document.getElementById("embed_code").value = embedScript;
	Base.Get("#sendTofriendAnchor").href = "mailto:?subject="+temp.title+"&body="+getUrl();
	//parent.location.VideoID = vidId;
}


function loadVideo2(vidId)
{
	var temp = getVidById(vidId);	
	Base.Get("#title").innerHTML = temp.title;
	Base.Get("#created").innerHTML = temp.creationDate;
	Base.Get("#descriptionSpan").innerHTML = temp.description;
	Base.Get("#categoryNameLink").innerHTML = temp.categoryName;
	//if(request("test")=="true")
		//alert(temp.urlEncodedPath);
	var flashvars = {};
	var params = {
	  allowfullscreen: "true",
	  allowscriptaccess: "always",
	  flashvars:"file="+temp.urlEncodedPath+"&image=preview.jpg&skin=/CustomModules/Fonqi.VideoModule/Scripts/player/skin.swf&fullscreen=true&autostart=true&repeat=list&linkfromdisplay=true&linktarget=_blank"
	};
	
	swfobject.embedSWF("/CustomModules/Fonqi.VideoModule/Scripts/player/player.swf", "flashcontent", "472", "290", "9.0.0","expressInstall.swf", flashvars, params);
	currentVideoId = vidId;
	var embedScript = "<embed src='http://attentionfilm.net.dynamicweb.dk/CustomModules/Fonqi.VideoModule/Scripts/player/player.swf' width='500' height='319' bgcolor='#' allowscriptaccess='always' allowfullscreen='true' flashvars='file=http%3a%2f%2fattentionfilm.net.dynamicweb.dk%2fDefault.aspx%3fID%3d9%26playList%3dtrue%26videoID%3d"+currentVideoId+"&amp;image=preview.jpg&amp;skin=http://attentionfilm.net.dynamicweb.dk/CustomModules/Fonqi.VideoModule/Scripts/player/skin.swf&amp;fullscreen=true&amp;autostart=true&amp;repeat=list&amp;linkfromdisplay=true&amp;linktarget=_blank'/>";
	document.getElementById("embed_code").value = embedScript;
	Base.Get("#sendTofriendAnchor").href = "mailto:?body="+getReferer();
}

function loadVideoByPath2(xmlPath, autostart)
{	
	//if(request("test")=="true")
		//alert(xmlPath);
	var flashvars = {};
	var params = {
	  allowfullscreen: "true",
	  allowscriptaccess: "always",
	  flashvars:"file="+xmlPath+"&image=preview.jpg&skin=/CustomModules/Fonqi.VideoModule/Scripts/player/skin.swf&fullscreen=true&autostart="+autostart+"&repeat=list&linkfromdisplay=true&linktarget=_blank"
	};
	swfobject.embedSWF("/CustomModules/Fonqi.VideoModule/Scripts/player/player.swf", "flashcontent", "472", "290", "9.0.0","expressInstall.swf", flashvars, params);
	document.getElementById("sendTofriendAnchor").href = "mailto:?subject="+currentTitle+"&body="+getUrl();
}

function getVidById(id)
{	
	for(var i = 0; i<vids.length; i++)
	{
		if(vids[i].id == id)
			return vids[i];
	}
}

function getUrl()
{
	var url = "http://www.mva.org/composite-3350.htm?VideoID="+currentVideoId;
	return escape(url);
}
