// from Google ADS
function ss(w){window.status=w;return true;}
function cs(){window.status='';}
function clk(n,el) {if(document.images){(new Image()).src="/url?sa=T&start="+n+"&url="+escape(el.href);}return true;}
function ga(o,e){if (document.getElementById){a=o.id.substring(1); p = "";r = "";g = e.target;if (g) { t = g.id;f = g.parentNode;if (f) {p = f.id;h = f.parentNode;if (h) r = h.id;}} else{h = e.srcElement;f = h.parentNode;if (f) p = f.id;t = h.id;}if (t==a || p==a || r==a) return true;
window.open(document.getElementById(a).href,'_new','');
//location.href=document.getElementById(a).href
}}


function SupportEmail()
{
    return 'mailto:javidiez@adinet.com.uy';
}

function checkAlphanumerical(theField) {
  str = theField.value;

  if (str.indexOf("$") == 0)
      str = str.substring(1, str.length);
  str = str.replace(/^\s*/, "");
  str = str.replace(/\s*$/, "");
  
  //theField.value = "$" + str;
  theField.value = str;
 
  str = str.replace(/^[^a-zA-Z]/, "?");
  str = str.replace(/[^a-zA-Z_0-9]/g, "?");

  ret = (str.indexOf("?") == -1);

  if (!ret)
  {
    alert("Variable names must start with a letter and may be composed from letters, numbers and the underscore '_' character.");
  }

  return ret;
}



//These functions, from andrewu.co.uk
//PARAMETER encodingDegree maybe 1 ("PARTIAL") or 0 ("FULL")

function CharacterEncodeString(inputStr, encodingDegree) {
	var htmlEncoded		= "";
	var fullHtmlEncoded	= "";

	for (var i=0; i<inputStr.length; ++i) {
		var chrAtI	= inputStr.charAt(i);
		var chr		= inputStr.charCodeAt(i);

		if (isNaN(chr)) {
			fullHtmlEncoded += chrAtI;
			htmlEncoded += charAtI;
		}
		else {
			fullHtmlEncoded += "&#" + chr + ";";
			if (chrAtI.match(/[\w\s]/)) {
				htmlEncoded += chrAtI;
			}
			else {
				htmlEncoded += "&#" + chr + ";";
			}
		}
	}
	return (encodingDegree == 1 ? htmlEncoded : fullHtmlEncoded);
}

function CharacterDecodeString(inputStr) {
	var htmlEncoded = inputStr;
	var entityReg	= /&#(\d+);/ig;
	var plainText	= "";

	while(htmlEncoded.match(entityReg)) {
		var currentEntityReg = new RegExp("&#" + RegExp.$1 + ";", "ig");
		htmlEncoded = htmlEncoded.replace(currentEntityReg, String.fromCharCode(RegExp.$1));
	}
	plainText = htmlEncoded;
	return plainText;
}

function padout(number) { return (number < 10) ? '0' + number : number; }
function y2k(number)    { return (number < 1000) ? number + 1900 : number; }

function UpdateStatusAndDate(levelsUp)
{
    var theForm = new Object();

    if (levelsUp == 1)
	theForm = window.opener.form;
    else if (levelsUp == 2)
	theForm = window.opener.window.opener.form;    

    theStatus = theForm.status.value;
    theDate = theForm.klsDateSent.value;
    
    if (theStatus == 2)
	theForm.status.value=3;

    if (theDate == 'DD/MM/YYYY')
    {
	var theDateObject = new Date();
	theDay = padout(theDateObject.getDate());
	theMonth = padout(theDateObject.getMonth()+1);
	theYear = y2k(theDateObject.getYear());
	theNewDate = theDay + '/' + theMonth + '/' + theYear;

	//alert(theDateObject.toString());
	//alert(theNewDate);

	theForm.klsDateSent.value = theNewDate;
    }

    if (levelsUp == 2)
	window.opener.window.close();

    return 1;
}

function ShowJS(inputName, inputValue)
{
    document.write("<input type=hidden name=" + inputName + " value = '");
    document.write(CharacterEncodeString(inputValue, 1) + "'>");
    //document.write(inputValue + "'>");
}


function make_domain(theURL) {
  start = theURL.indexOf("//");
  if (start >= 0)
	theURL = theURL.substring(start+2, theURL.length);
  end = theURL.indexOf("/");
  if (end>=0)
	theURL = theURL.substring(0, end);
  start = theURL.indexOf(".");
  if (start >= 0)
	theURL = theURL.substring(start+1, theURL.length);

  //alert(theURL);

  return theURL;
}


function check_dirFree(field1) {
  ret = (field1.value!=-2);

  msg = "Please select an 'Allows free' option and then submit.";

  //if (!ret) alert("Incompatible URL and Domain Name!");
  if (!ret) alert(msg);

  return ret;
}

function check_domain(field1, field2) {
  ret = (field1.value==make_domain(field2.value));
  msg = "The Home Page must be of the domain name entered. Please check and try again.";

  //if (!ret) alert("Incompatible URL and Domain Name!");
  if (!ret) alert(msg);

  return ret;
}

function check_empty(field) {
  ret = (field.value != "");
  msg = "Please enter your email address in the email field and try again.";

  //if (!ret) alert("Incompatible URL and Domain Name!");
  if (!ret) alert(msg);

  return ret;
}

function check_pwd_and_domain(field1, field2) {
  ret1 = check_pwd();
  ret2 = check_domain(field1, field2);
  ret = ret1 && ret2;

  return ret;
}


function is_full_temp(val1, val2) {
  if (val1 < val2)
	ret=1;
  else
	ret=0;
  msg = "No more free spaces at the temporary list.";

  //if (!ret) alert("Incompatible URL and Domain Name!");
  if (!ret) alert(msg);
  //alert(msg);

  return 1;
}


function OnDeleteDirectory(idDel)
{
  if (idDel >= 0)
  {
    if (confirm("Are you sure?"))
  	{
	document.location = "dirDelete_do.php?dirID="+idDel;
	//LPost(window,document);
	}
  }
/*  else if (idDel == -1)
  {
    //DELETE ALL
    //if (confirm("Are you sure you want to delete ALL?"))
    //{
	//document.location = "klsDelete_do.php?klsID=-1";

confirmWnd = window.open('popupConfirm.php', 'popupWnd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=220');
    //}
  }
*/
}

function OnDeleteNewsletter(idDel)
{
  if (idDel >= 0)
  {
    if (confirm("Are you sure?"))
  	{
	document.location = "newDelete_do.php?newID="+idDel;
	//LPost(window,document);
	}
  }
/*  else if (idDel == -1)
  {
    //DELETE ALL
    //if (confirm("Are you sure you want to delete ALL?"))
    //{
	//document.location = "klsDelete_do.php?klsID=-1";

confirmWnd = window.open('popupConfirm.php', 'popupWnd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=220');
    //}
  }
*/
}

function OnDeleteForum(idDel)
{
  if (idDel >= 0)
  {
    if (confirm("Are you sure?"))
  	{
	document.location = "forDelete_do.php?forID="+idDel;
	//LPost(window,document);
	}
  }
/*  else if (idDel == -1)
  {
    //DELETE ALL
    //if (confirm("Are you sure you want to delete ALL?"))
    //{
	//document.location = "klsDelete_do.php?klsID=-1";

confirmWnd = window.open('popupConfirm.php', 'popupWnd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=220');
    //}
  }
*/
}

function OnDeleteKLSite(idDel)
{
  if (idDel >= 0)
  {
    if (confirm("Are you sure?"))
  	{
	document.location = "klsDelete_do.php?klsID="+idDel;
	//LPost(window,document);
	}
  }
  else if (idDel == -1)
  {
    //DELETE ALL
    //if (confirm("Are you sure you want to delete ALL?"))
    //{
	//document.location = "klsDelete_do.php?klsID=-1";

confirmWnd = window.open('popupConfirm.php', 'popupWnd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=220');
    //}
  }
}

function OnDeleteTransaction(idDel)
{
    if (confirm("Are you sure?"))
	document.location = "delTransaction_do.php?id="+idDel;
}

function OnTerminateFreeTrial()
{
confirmWnd = window.open('popupConfirm2.php', 'popupWnd', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=250');
}

function DeleteAllKLSites()
{
    confirmWnd.close();
    confirmWnd = null;
    document.location = "klsDelete_do.php?klsID=-1";
}

function TerminateFreeTrial(idCause)
{
    confirmWnd.close();
    confirmWnd = null;
    document.location = "closeAccount_do.php?cancelSubscription="+idCause;
}



//<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
//<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

//<!-- Begin
// test variables
var myHeight = 200;
var isResizable = true;

function createTarget(form) {
_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
} else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i < _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
   }
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}
//  End -->


function AlertNoETemplateAvailable()
{
    msg = "You must define at least one email template first. Click on the 'Email' tab and consult the Help file for instructions.";

    alert(msg);
}

function doTheLink(theID)
{
    ret = 'login.php?idPage=' + theID;

    param = ret;

    idLocal = 0;

    for (i=0; i < window.formTemp.length; i++)
    {
	theName = window.formTemp.elements[i].name;
	if (window.formTemp.elements[i].checked)
	    theValue = 1;
	else
	    theValue = 0;
	//name1 = theName.substring(0, 5);
	if (theName.indexOf("check") == 0)
	{
	    startID = theName.indexOf("[")+1;
	    endID = theName.indexOf("]");
	    theID = theName.substring(startID, endID);

//	    FORMAT 1
/*	    idLocal++;
	    label1 = 'id' + idLocal;
	    label1 = label1 + '=';
	    label2 = 'val' + idLocal;
	    label2 = label2 + '=';

	    
	    param = param + '&';
	    param = param + label1;
	    param = param + theID;
	    param = param + '&'
	    param = param + label2;
	    param = param + theValue;
*/
//	    FORMAT 2
/*	    if (theValue)
	    {
		idLocal++;
		label1 = 'id' + idLocal;
		label1 = label1 + '=';

		param = param + '&';
		param = param + label1;
		param = param + theID;
*/
//	    FORMAT3
	    if (theValue)
	    {
		idLocal++;
		if (idLocal == 1)
		    param = param + '&checkIDs=';

		param = param + theID;
		param = param + "k";		
	    }
	}
    }

    //alert(param);
    ret = param;

    document.location.href = ret;
}

function sendForm(theID, theForm)
{
    ret = 'login.php?show=' + theID;

    if (theForm.hidIsEditing.value == 1)
    {
        theForm.gotoVars.value = theID;
	theForm.submit();
    }
    else
	document.location.href = ret;
}

function doTheCheck(form)
{
for (i=0; i < form.length; i++)
    //if (form.elements[i].type = checkbox)
    if (form.elements[i].name != "allChecked")
    	if (form.allChecked.checked)
	    form.elements[i].checked = true;
	else
	    form.elements[i].checked = false;
}

function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

//  End -->
