var urlstring=(location.href);
if ((urlstring.indexOf("mail.sonatrach.com.pe")!=-1) || (urlstring.indexOf("ultraworld.eu")!=-1)) {
 alert('ACHTUNG! DIES IST NICHT RICARDO.CH! Bitte loeschen Sie die erhaltene Mail und schliessen Sie diese Seite.');
 alert('ATTENTION! CECI N EST PAS RICARDO.CH! MERCI DE FERMER CE SITE.');
}

function test (){
   alert('test estelle');
}

function getObj(targetDocument, name)
{
  // retrieve an object with its ID
  if (targetDocument.getElementById)
  	return targetDocument.getElementById(name);
  else if (targetDocument.all)
	return targetDocument.all[name];
  else if (targetDocument.layers)
   	return targetDocument.layers[name];
}

function getSelectedIndex(listbox)
{
	return listbox.options.selectedIndex;
}

function getSelectedValue(listbox)
{
	// return value of a selected line in a listbox
	if (getSelectedIndex(listbox) != -1)
		return listbox.options[getSelectedIndex(listbox)].value;
	
	return '';
}

function getSelectedName(listbox)
{
	// return value of a selected line in a listbox
	if (getSelectedIndex(listbox) != -1)
		return listbox.options[getSelectedIndex(listbox)].text;
	
	return '';
}

function isDivVisible(targetDocument, divname)
{
	// true if visible, false if not.
	if (targetDocument.getElementById)
		return (targetDocument.getElementById(divname).style.display != "none")
	else if (targetDocument.all)
		return (targetDocument.all[name].style.display != "none")
	else if (targetDocument.layers)
		return (targetDocument.layers[divname].display != "none");
}


function setDivStatus(targetDocument, divname, isVisible)
{
	// will be shown if isVisible is true
	if (targetDocument.getElementById)
		targetDocument.getElementById(divname).style.display  = (isVisible) ? "" : "none";
	else if (targetDocument.all)
		targetDocument.all[name].style.display  = (isVisible) ? "" : "none";
	else if (targetDocument.layers)
		targetDocument.layers[divname].display  = (isVisible) ? "" : "none";
}

function uncheckOthers(checkboxUsed, namePattern)
{

	var chkIndex = 0;
	var objCheck = getObj(document, namePattern + chkIndex);
	
	while (objCheck)
	{
		objCheck.checked = false;
		objCheck = getObj(document, namePattern + ++chkIndex);
	}

	if (checkboxUsed)
		checkboxUsed.checked = true;
}

function showModalPopup(url, name, width, height, isCentered)
{		
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var ID = name;
	
	if (!isCentered)
	{
		left=10;
		top=10
	}
	
	if (window.showModalDialog)
	{
		var dialogArguments = new Object();
		var _R = window.showModalDialog(url, dialogArguments, "dialogWidth="+width+"px;dialogHeight="+height+"px;scroll=no;status=no;");
		if ("undefined" != typeof(_R))
		{
			SetName(_R.strName);	
		}
	}		
	else	//NS			
	{  	
 		winHandle = window.open(url, ID, "modal,toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,left="+left+",top="+top+",width="+width+",height="+height);
		winHandle.focus();
	}
	return false;
}



function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

   function ReplaceCommaByPoint(value) {
       return value.replace(',', '.');
   }

//subtitle
function copyInTextArea(fromTextInput, toTextReminder) {
    var inputTitle = getObj(document, fromTextInput); //'Title');
    var inputCopyTitle = getObj(document, toTextReminder); //'TitleReminder');
    if (inputTitle && inputCopyTitle)
        inputCopyTitle.value = inputTitle.value;

}

function checkSubtitleText(chkhasSubtitle, inputSubtitle, cacheSubtitle) {
    //var chkhasSubtitle = getObj(document, 'hasSubtitle');
    //var inputSubtitle = getObj(document, 'Subtitle');
    //var cacheSubtitle = getObj(document, 'cacheSubtitle');

    var chkhasSubtitle = getObj(document, chkhasSubtitle);
    var inputSubtitle = getObj(document, inputSubtitle);
    var cacheSubtitle = getObj(document, cacheSubtitle);


    if (chkhasSubtitle && inputSubtitle && cacheSubtitle) {
        if (chkhasSubtitle.checked) {
            inputSubtitle.value = cacheSubtitle.value;
            inputSubtitle.focus();
        }
        else {
            cacheSubtitle.value = inputSubtitle.value;
            inputSubtitle.value = '';
        }
    }
}

function checkSubtitleStatus() {
    var chkhasSubtitle = getObj(document, 'hasSubtitle');
    var inputSubtitle = getObj(document, 'Subtitle');

    if (chkhasSubtitle && inputSubtitle)
        chkhasSubtitle.checked = (inputSubtitle.value.length > 0);
}

function checkSubtitleValue() {
    var chkhasSubtitle = getObj(document, 'hasSubtitle');
    var inputSubtitle = getObj(document, 'Subtitle');
    if (chkhasSubtitle.checked && (inputSubtitle.value.length < 1)) {
        getObj(document, 'hasSubtitle').checked = false;
    }
}

