window.onload = function()
{
	var embedTypes = getRadioGroup('embed_type');
	var i = embedTypes.length;
	
	while(i--)
	{
		var radio = embedTypes[i];
		
		radio.onchange = function()
		{
			setEmbedCode( this.value );
		}
		
		if(radio.checked)
		{
			setEmbedCode( radio.value );
		}
	}
	
	var location = document.location.href.toString().toLowerCase();
	var type;
	
	switch(true)
	{
		case ( location.indexOf('flickronyourtv.com') > -1 ) :
		{
			type = 'flickr';
			break;
		}
		case ( location.indexOf('twitteronyourtv.com') > -1 ) :
		{
			type = 'twitter';
			break;
		}
		case ( location.indexOf('youtubeonyourtv.com') > -1 ) :
		{
			type = 'youtube';
			break;
		}
	}

	var params = {
		quality: "high",
		scale: "noscale",
		wmode: "window",
		allowscriptaccess: "always",
		bgcolor: "#FFFFFF",
		base: "widget/"
	};
	var flashvars = {
		startPage: type,
        siteXML: "xml/site.xml"
    };
	var attributes = {id:"flashcontent"};
	
	swfobject.embedSWF("widget/main.swf", "widgetcontainer", "100%", "100%", "9.0.28", "expressInstall.swf", flashvars, params, attributes);
	
	if(swfmacmousewheel) swfmacmousewheel.registerObject(attributes.id);
	
	swfobject.embedSWF("embed/inc/swf/button.swf", "flashbutton", "225", "64", "9.0.28", "expressInstall.swf", flashvars, params, attributes);
	
	$('embed_code').onfocus = function()
	{
		this.select();
	}
}

var setEmbedCode = function(type)
{	
	$('embed_code').value = '<script type="text/javascript" src="http://www.enjoyinternetonyourtv.com/embed/?type=' + type + '"></script>';
}

var getRadioGroup = function(name)
{
	var inputs = document.getElementsByTagName('input');
	var returnEl = new Array();
	var i = inputs.length
	while(i--)
		returnEl.push( inputs[i] );
	
	return returnEl;
}

var $ = function(elm)
{
	return document.getElementById(elm);
}