/************************************************
* Métodos Comuns (FO/BO)						*
*************************************************/

function popper(thisUrl,thisWidth,thisHeight,thisTop,thisLeft)
{
if (!thisLeft)
	var thisLeft=(screen.width-thisWidth)/2; // get center of screen minus popup width
if (!thisTop)
	var thisTop=(screen.height-thisHeight)/2; // get center of screen minus popup height

var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=yes,scrollbars=no');
mainWin = window.open(thisUrl,'editorHtmlWindow',optionString);
mainWin.focus();
}

function popperScroll(thisUrl,thisWidth,thisHeight,thisTop,thisLeft,thisWindowName)
{

if (!thisLeft)
	var thisLeft=(screen.width-thisWidth)/2; // get center of screen minus popup width
if (!thisTop)
	var thisTop=(screen.height-thisHeight)/2; // get center of screen minus popup height
if(!thisWindowName)
{
	var thisWindowName = 'mainWindow';
}

var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=yes,scrollbars=yes');
mainWin = window.open(thisUrl,thisWindowName,optionString);
mainWin.focus();
}

function dialogBox(thisUrl,thisWidth,thisHeight,thisTop,thisLeft)
{
var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=no,scrollbars=yes');
mainWin = window.showModalDialog(thisUrl,'',optionString);

}

//Validação Input
function validatedFilename(string) {
    for (var i=0, output='', valid="_-0123456789abcdefghijklmnopqrstuvwxyz"; i<string.length; i++)
       if (valid.indexOf(string.charAt(i)) != -1)
          output += string.charAt(i)
		  
    return output;
}

cont = 0;

//Validação Input
function validatedTitle(string) {
    for (var i=0, output='', invalid="'\""; i<string.length; i++)
	{
		if (invalid.indexOf(string.charAt(i)) == -1){
			output += string.charAt(i)
		}
		else if (string.charAt(i) == '\''){
			cont++;
			if(cont%2 == 0){
				output += '´';
			}
			else{
				output += '`';
			}
		}
		else if (string.charAt(i) == '"'){
			cont++;
			if(cont%2 == 0){
				output += '»';
			}
			else{
				output += '«';
			}
		}
	}
    return output;
}

//Validação Input
function validatedPageTitle(string) {
    for (var i=0, output='', invalid="'\"&"; i<string.length; i++)
       if (invalid.indexOf(string.charAt(i)) == -1){
          output += string.charAt(i)
	   }
	   else if (string.charAt(i) == '&'){
			output += 'e';
	   }
		  
    return output;
}

