/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 Wednesday, November 10, 2004 2:27:12 PM
 HAPedit 3.1.11.111
 - - - - - - - - - - - - - - - - - - - - - - - */
function changeColor(colorType)
{
   preview = "ColorPreview" + colorType;
   edit =  "ColorHex" + colorType;
   document.getElementById(preview).style.backgroundColor = document.getElementById(edit).value;
}
function openColorPicker(page, editColor, controlColor)
{

    color = document.getElementById(editColor).value;
    color = color.substr(1,6);
    window_link = page + '?color=' + color + '&edit_color=' + editColor + '&control_color=' + controlColor;
    newWindow = window.open( window_link , '', 'dependent=yes,scrollbars=0,width=270,height=190,top=150,left=150,resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=yes,copyhistory=0' );
    if (document.images) newWindow.focus()
}
function checkEmail(email)
{
    var pattern = new RegExp("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$");
    if (email.search(pattern) == -1)
    {
        return false;
    }
    else
    {       
        return true;
    }
}
function isEmptyString(strValue) {
   	var strTemp = strValue;
   		strTemp = trimAll(strTemp);
   		if(strTemp.length > 0){
 		return false;
   		}
   		return true;		
}

function trimAll( strValue ) {
 	var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}





