// Author Frank Cefalu


function gotfragwysiwyg(t){

//crappy browser sniffer 
var isFF = false; 
var textSelected = false; 
if(navigator.userAgent.toLowerCase().indexOf("firefox") > 0){ 
isFF = true; 
} 
var myarea = document.getElementById("textbox_comment"); 
var begin,selection,end; 
if (isFF == true){ 
if (myarea.selectionStart!= undefined) {  
begin = myarea.value.substr(0, myarea.selectionStart);  
selection = myarea.value.substr(myarea.selectionStart, myarea.selectionEnd - myarea.selectionStart);  
end = myarea.value.substr(myarea.selectionEnd); 
if (selection.length > 0){ 
textSelected = true; 
} 
} 
}else{ 
if (window.getSelection){ 	 
selection = window.getSelection(); 
}else if (document.getselection){  
selection = document.getselection(); 
}else if (document.selection){  
selection = document.selection.createRange().text; 
} 
var startPos = myarea.value.indexOf(selection); 
if (startPos == 0){ 
var endPos = myarea.value.indexOf(selection) + selection.length; 
begin = myarea.value.substr(0,startPos); 
end = myarea.value.substr(endPos, myarea.value.length); 
textSelected = true; 
} 
} 
if(textSelected == true){ 
switch (t){ 
case "quote": 
startTag = "[QUOTE]"; 
endTag = "[/QUOTE]"; 
break; 

case "bold":
startTag = "[B]";
endTag = "[/B]";
break;

case "italic":
startTag = "[I]";
endTag = "[/I]";
break;

case "underline":
startTag = "[U]";
endTag = "[/U]";
break;

case "strike":
startTag = "[S]";
endTag = "[/S]";
break;
}
myarea.value = begin + startTag + selection + endTag + end;
myarea.focus();
}else{



switch (t){ 
case "quote": 
startTag = "[QUOTE]"; 
endTag = "[/QUOTE]"; 
break; 

case "bold":
startTag = "[B]";
endTag = "[/B]";
break;

case "italic":
startTag = "[I]";
endTag = "[/I]";
break;

case "underline":
startTag = "[U]";
endTag = "[/U]";
break;

case "strike":
startTag = "[S]";
endTag = "[/S]";
break;
}

myarea.value += startTag + endTag;

}




}

	
	function playvideo(num){
	newtitle = document.getElementById('title'+num).innerHTML;
	newdescr = document.getElementById('description'+num).innerHTML;
	newvideo = document.getElementById('vid'+num).value;
	
	$('renderedtitle').innerHTML = newtitle;
	$('rendereddescr').innerHTML = newdescr;
	$('renderedvideo').innerHTML = '<embed src="http://media.mlgpro.com/content/2008/topten/flvplayer/mediaplayer.swf" autoplay="true" width="600" height="338" allowscriptaccess="always" allowfullscreen="true"flashvars="autostart=true&height=338&width=600&file='+newvideo+'"/>';
	
		
	
	
	}

