
function call_show_page(page)
{
agent.call(page,'show','callback_show_page');
}


function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}


function getObjectFromID(id){
	var theObject;
	if(document.getElementById)
		theObject=document.getElementById(id);
	else
		theObject=document.all[id];
	return theObject;
}

function toggleLayer(whichLayer)
{

if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="none";
}
//alert(whichLayer);
//alert(style2.display);
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;

if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="none";
}
}
else if (document.layers)
{
// this is the way nn4 works

var style2 = document.layers[whichLayer].style;

if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="none";
}
}
}//end function



function checkMessages(theBox) {
		var theArray=document.getElementsByName('array[]');	
			if ( theBox.checked ) {
				for (i = 0; i < theArray.length; i++) {
					theArray[i].checked = true ;
				}
				if ( typeof theArray[0] != 'object' ) {
					theArray.checked = true;
				}
				theBox.form.all1.checked = true;
				theBox.form.all2.checked = true;
			} else {
				for (i = 0; i < theArray.length; i++) {
					theArray[i].checked = false ;
				}
				if ( typeof theArray[0] != 'object' ) {
					theArray.checked = false;
				}
				theBox.form.all1.checked = false;
				theBox.form.all2.checked = false;
			}
}


function lengthCheck(comments) {
	var textValue = comments.replace(/\n/g, '\r\n').replace(/\r\r/g, '\r');
	if (textValue.length > 2000) {
		alert("Your comment is too long (" + textValue.length + " characters).\nThe limit is 2000 characters.");
		return false;
	}
	return true;
}


function isInteger (s)
{
      var i;

      if (isEmpty(s))
      
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
}

function isEmpty(s)
{
      return ((s == null) || (s.length == 0))
}

function isDigit (c)
{
      return ((c >= "0") && (c <= "9"))
}
function showLayer(whichLayer)
{

if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="block";
}
//alert(whichLayer);
//alert(style2.display);
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;

if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="block";
}
}
else if (document.layers)
{
// this is the way nn4 works

var style2 = document.layers[whichLayer].style;

if(style2.display =="none"){
style2.display="block";	
}else{
style2.display="block";
}
}
}//end function


function call_import_login(theForm)
{
   var username=theForm.username.value;
   var password=theForm.password.value;
   var typename=theForm.typename.value;		
   
   var checkimport = true;
   if(checkspace(username)) {
	theForm.username.focus();
        alert("Please input user name");
	checkimport = false;
	return false;
   }
   if(checkspace(password)) {
	theForm.password.focus();
        alert("Please input password");
	checkimport = false;
	return false;
   }
   
   if(checkimport){
   	theForm.importb.disabled = true;
	ajax_loadContent('featureSubNav_target', _SITELETPATH + 'importer.php?type='+typename+'&username='+ username +'&password='+ password);
	//call_show_page();
   }
   else{
   return false;
   }
}

function sendemail()
{
	var sendForm = getObjectFromID('arrayForm');
	
	var checkemail = true;
	
	/*if(checkspace(sendForm.subject.value)) {
		sendForm.subject.focus();
	        alert("Please input subject");
		checkemail = false;
		return false;
	}*/
	
	/*if(checkspace(sendForm.emailbody.value)) {
		sendForm.emailbody.focus();
	        alert("Please input email body");
		checkemail = false;
		return false;
	}*/
	
	var selectemail = false;
	var theArray=document.getElementsByName('array[]');
	for (i = 0; i < theArray.length; i++) {
		if(theArray[i].checked == true){
			selectemail = true;
			document.getElementById('frmtargets').value += theArray[i].value + ',';
		}
	}
	if(!selectemail)
	{
		checkemail = false;
		alert("Please select more than one email address");
	}

}
