
 /****************************************************************************\
	 Creation date :-> 16-03-2007 [dd-mm-yyyy]
	 Last update   :-> 16-03-2007 [dd-mm-yyyy]

	 Author        :-> Alen Simec  <alen@eburza.hr>
 \****************************************************************************/

/***** USER Administration *****/

function Edit(uid) {
	document.Administration.action = "index.php?menu=104";
	document.Administration._action_.value = "EditProduct";
	document.Administration.meteo_id.value = uid;
	document.Administration.submit();
} // end of the 'Administration()' function

function Delete(uid) {
	var is_confirmed = confirm("Želite li obrisati?");
	if(is_confirmed) {
		document.Administration.action = "include/trigger.php";
		document.Administration._action_.value = "DeleteProduct";
		document.Administration.meteo_id.value = uid;
		document.Administration.submit();
	}
} // end of the 'PortfolioDelete()' function

function reportError(request) {
	alert('The requested URL was not found on this server.');
}

/********* RTEditor *********/

function InsertCode(tag, desc, textarea) {
	// our open tag
	var open = "<" + tag + ">";
	
	// our close tag
	var close = "</" + tag + ">";
	
	if(!textarea.setSelectionRange) {
		var selected = document.selection.createRange().text; 
		if(selected.length <= 0) { 
			// no text was selected so prompt the user for some text
			textarea.value += open + prompt("Upišite tekst koji želite " + desc, "") + close;
		}
		else {
			// put the code around the selected text
			document.selection.createRange().text = open + selected + close; 
		}
	}
	else {
		// the text before the selection
		var pretext = textarea.value.substring(0, textarea.selectionStart);
		
		// the selected text with tags before and after
		var codetext = open + textarea.value.substring(textarea.selectionStart, textarea.selectionEnd) + close;
		
		// the text after the selection
		var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length)
		
		// check if there was a selection
		if(codetext == open + close) {
			//prompt the user
			codetext = open + prompt("Upišite tekst koji želite " + desc, "") + close;
		}
		
		// update the text field
		textarea.value = pretext + codetext + posttext;
	}
	
	// set the focus on the text field
	textarea.focus();
}

// inserts a link by prompting the user for a url
function InsertLink(textarea) {
	// our link
	var url = prompt("Upišite url", "http://");
	var link = "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>";
	
	if(!textarea.setSelectionRange) {
		// get selected text
		var selected = document.selection.createRange().text; 
		
		if(selected.length <= 0) { 
			// no text was selected so add the link to the end
			textarea.value += link;
		}
		else {
			// replace the selection with the link
			document.selection.createRange().text = link; 
		}
	}
	else {
		// the text before the selection
		var pretext = textarea.value.substring(0, textarea.selectionStart);
		
		// the text after the selection
		var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length)
		
		// update the text field
		textarea.value = pretext + link + posttext;
	}
	
	// set the focus on the text field
	textarea.focus();
}
/********* End RTEditor *********/