var thisForm;

function wrapIt(txtarea, lft, rgt) {
	if (document.all) {
		strSelection = document.selection.createRange().text;
		if (strSelection != "") {
			document.selection.createRange().text = lft + strSelection + rgt;
		}
	} else if (document.getElementById) {
		selLength = txtarea.textLength;
		selStart = txtarea.selectionStart;
		selEnd = txtarea.selectionEnd;
		if (selEnd == 1 || selEnd == 2) selEnd = selLength;
		s1 = (txtarea.value).substring(0,selStart);
		s2 = (txtarea.value).substring(selStart, selEnd);
		s3 = (txtarea.value).substring(selEnd, selLength);
		txtarea.value = s1 + lft + s2 + rgt + s3;
	}
}
function wrapSelection(txtarea, lft, rgt) {
	if (emptySelection(txtarea)) {
		my_text = prompt("Enter text for tag: " + lft, "");
		if (my_text == "") return;
		lft = lft + my_text;
	}
	wrapIt(txtarea, lft, rgt);
}
function wrapSelectionWithLink(txtarea) {
	my_link = prompt("Enter URL:","");
	if (my_link == "") return;
	if (my_link.substring(0, 7) != 'http://') my_link = 'http://' + my_link;
	lft="<a href=\"" + my_link + "\" target=\"_blank\">";
	rgt="<\/a>";
	if (emptySelection(txtarea)) {
		my_title = prompt("Enter link title:","");
		if (my_title == "") return;
		lft = lft + my_title;
	}
	wrapIt(txtarea, lft, rgt);
}
function emptySelection(txtarea) {
	if (document.all) {
		strSelection = document.selection.createRange().text;
	} else if (document.getElementById) {
		selStart = txtarea.selectionStart;
		selEnd = txtarea.selectionEnd;
		if (selEnd == 1 || selEnd == 2) selEnd = txtarea.textLength;
		strSelection = (txtarea.value).substring(selStart, selEnd);
	}
	return (strSelection == "") ? true : false;
}
var clicked = 0;

function doubleStop() {
	if (clicked == 0) {
		clicked++;
		return true;
	} else {
		return false;
	}
}
function jumpMenu(theObject) {
	if (theObject.options[theObject.selectedIndex].value != "none") {
		eval("parent.location='" + theObject.options[theObject.selectedIndex].value + "'");
	} else {
		theObject.selectedIndex = 0;
		return false;
	}
}
function textCounter(theField, charsLeft, maxChars) {
	if (theField.value.length > maxChars) {
		theField.value = theField.value.substring(0, maxChars);
	} else {
		charsLeft.value = maxChars - theField.value.length;
	}
}
function init() {
	clicked = 0;
	if (top.location != location) top.location.href = document.location.href;
}
function swap_done () {
	void(0);
}
function swap_in_quicktime(swap_target, video_url, w, h) {
	swap_target.innerHTML = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http:\/\/www.apple.com\/qtactivex\/qtplugin.cab" width="' + w + '" height="' + h + '"><param name="src" value="' + video_url + '" \/><param name="autoplay" value="true" \/><param name="controller" value="true" \/><embed width="' + w + '" height="' + h + '" src="' + video_url + '" pluginspage="http:\/\/www.apple.com\/quicktime\/download/" type="video/quicktime" controller="true" autoplay="true" \/><\/object>';
	swap_target.onclick = swap_done;
}
function swap_in_video(swap_target, video_url) {
	swap_target.innerHTML = '<object id="MediaPlayer" width="320" height="290" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" standby="Loading Windows Media Player components..." type="application\/x-oleobject"><param name="filename" value="' + video_url + '" \/><param name="autoStart" value="true" \/><param name="animationatStart" value="true"><param name="ShowStatusBar" value="true" \/><param name="Volume" value="1" \/><param name="ShowTracker" value="true" \/><param name="ShowAudioControls" value="true" \/><param name="ShowPositionControls" value="true" \/><embed type="application\/x-mplayer2" src="' + video_url + '" width="320" height="290" autoStart="true" ShowStatusBar="true" Volume="0" ShowTracker="false" ShowAudioControls="false" ShowPositionControls="false"><\/embed><\/object>';
	swap_target.onclick = swap_done;
}
function swap_in_memri(swap_target, video_url) {
	swap_target.innerHTML = '<object id="MediaPlayer" width="484" height="400" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" standby="Loading Windows Media Player components..." type="application\/x-oleobject"><param name="filename" value="' + video_url + '" \/><param name="autoStart" value="true" \/><param name="animationatStart" value="true"><param name="ShowStatusBar" value="true" \/><param name="Volume" value="1" \/><param name="ShowTracker" value="true" \/><param name="ShowAudioControls" value="true" \/><param name="ShowPositionControls" value="true" \/><embed type="application\/x-mplayer2" src="' + video_url + '" width="484" height="400" autoStart="true" ShowStatusBar="true" Volume="0" ShowTracker="false" ShowAudioControls="false" ShowPositionControls="false"><\/embed><\/object>';
	swap_target.onclick = swap_done;
}
function swap_in_mp3(swap_target, mp3_url) {
	swap_target.innerHTML = '<object id="MediaPlayer" width="320" height="290" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" standby="Loading Windows Media Player components..." type="application\/x-oleobject"><param name="filename" value="' + video_url + '" \/><param name="autoStart" value="true" \/><param name="animationatStart" value="true"><param name="ShowStatusBar" value="true" \/><param name="Volume" value="1" \/><param name="ShowTracker" value="true" \/><param name="ShowAudioControls" value="true" \/><param name="ShowPositionControls" value="true" \/><embed type="application\/x-mplayer2" src="' + video_url + '" width="320" height="290" autoStart="true" ShowStatusBar="true" Volume="0" ShowTracker="false" ShowAudioControls="false" ShowPositionControls="false"><\/embed><\/object>';
	swap_target.onclick = swap_done;
}


window.onload = function ()
{

    var aImages = document.getElementsByTagName('IMG');
    
    for (var i = 0; i < aImages.length; i++)
    {
        if ('video' == aImages[i].className)
        {
            aImages[i].parentNode.onclick = testAlert;
        }
    }
}

function testAlert()
{
    var aImages = this.getElementsByTagName('IMG');
    var oImage = aImages[0];
    oImage.style.display = 'none';
    var sVideoUrl = unescape(oImage.getAttribute('video'));

    swap_in_memri(this, sVideoUrl);
}