// Defaults
var isSelected = false;
var IE = document.all ? true : false;
var selLength;
var selStart;
var selEnd;

// USAGE:
// return confirmSubmit(this, 'Da li ste sigurni?', 'delete');

function confirmSubmit2(theButton, theQuestion)
{
    alert(theQuestion);


    return false;
} // 
function confirmSubmit(theButton, theQuestion, chgName)
{
    var is_confirmed = confirm(theQuestion);
    if (is_confirmed) theButton.name = chgName;

    return is_confirmed;
} // end of the 'confirmLink()' function

function showText(txt)
{
	alert(txt);
	return false;
}

function markSelection ( txtObj )
{
 if (IE && txtObj.createTextRange)
 {
   txtObj.caretPos = document.selection.createRange().duplicate();
   if  (txtObj.caretPos.text != '') isSelected = true;
   else isSelected = false;
 }
 else if (!IE)
 {
  	selLength = txtObj.textLength;
  	selStart = txtObj.selectionStart;
  	selEnd = txtObj.selectionEnd;
  	if (selEnd==1 || selEnd==2) selEnd=selLength;
  	isSelected = selEnd-selStart>0 ? true : false;
 }
}

function insertTag ( txtObj, tag1, tag2, innerText )
{
 if (!IE)
 {
 	if (tag1)
 	{
 		if (document.getSelection()) // Opera
 		{
 			innerText = document.getSelection();
		}
		else // NN, Firefox
		{
 			var v = txtObj.value;
			var s1 = (v).substring(0,selStart);
  			var s3 = (v).substring(selEnd, selLength);
		}

 		if (!tag2) tag2 = tag1;
  		if (!innerText) innerText = (v).substring(selStart, selEnd);

 		txtObj.value = s1 + "["+tag1+"]"+innerText+"[/"+tag2+"]"+s3;
 	}
 }
 else // IE
 {
	txtObj.focus();

	if (tag1)
 	{
		var caretPos = txtObj.caretPos;
		if (!innerText)	innerText = caretPos.text;
 		if (!tag2) tag2 = tag1;
		caretPos.text = "["+tag1+"]"+innerText+"[/"+tag2+"]";
	}
	isSelected=false;
 }


}

function insertLinkTag( textObj, inputLinkStr, inputNameStr)
{
	var linkStr = prompt(inputLinkStr,'http://');
	if (!linkStr)
		return;
	else
	{
		if (!isSelected)
			var innerText = prompt(inputNameStr,'');
		return insertTag ( textObj, 'LINK='+linkStr, 'LINK', innerText );
	}
}

function showText(txt)
{
	alert(txt);
	return false;
}

function flash(url)
{
			var so = new SWFObject(url, "zgradaFlash", "760", "300", "9.0.0", "#fff");

			so.addParam("wmode","transparent");

			so.write("zgradaFlash");

}
function changeLink(url)
{
	flash(url);

}
