//'###########################################################################
function trim(strComp){
	ltrim = /^\s+/
	rtrim = /\s+$/
	strComp = strComp.replace(ltrim,'');
	strComp = strComp.replace(rtrim,'');
	return strComp;
}
//'###########################################################################
function displayProperties(obj) {
	var str = "";
	var arrProp = new Array();
	var prop;
	var arrIndex = 0;

	if(typeof(obj) == "undefined"){
		alert('displayProperties: Parameter is not an object!');
		return false;
	}
	
	if(typeof(obj[0]) != "undefined") {
		for(prop = 0;prop < obj.length;prop++) {
			str += "\n" + prop + "=" + obj[prop];
			arrProp[arrIndex++] = "\n" + prop + "=" + obj[prop];
		}
	}
	else {
		for(prop in obj) {
			str += "\n" + prop + "=" + eval("obj." + prop);
			arrProp[arrIndex++] = "\n" + prop + "=" + obj[prop];
		}
	}
	alert(arrProp.sort());
}
//'###########################################################################
function ToggleSearchType(tdCountryCode,tdZip,lnkSearchType,txtZipCode){	
	//var strInnerText = new string(lnkSearchType.innerText.toLowerCase());
	var strInnerText = lnkSearchType.innerText.toLowerCase();
	tdCountryCode.style.display = tdCountryCode.style.display=='none'? '':'none';
	tdZip.style.display = tdZip.style.display=='none'? '':'none';
	if(strInnerText.indexOf("zip",0)<0)
		txtZipCode.value = "";
	strInnerText = strInnerText.indexOf("zip",0)>0 ? "Search to Country" : "Search to Zip Code";
	lnkSearchType.innerText = strInnerText;
}
//'###########################################################################
function Redirect()
{
	
}
//'###########################################################################
function ToggleCollapseExpand(strTableId,objInput)
{	
	var ctrl = document.getElementById(strTableId);
	var strState = ctrl.style.display=='none'?'':'none';
	var strText = '';
	if(objInput){
		strText = ctrl.style.display=='none'? 'Less' : 'More'
	}
	try{
		for(i=0; i < trList.length; i++){
			if(strTableId == trList[i]){				
				if(objInput)
					CollapseExpand(trList[i],objInput,strState,strText);
				else
					CollapseExpand(trList[i],null,strState,strText);
			}else{
				if(objInput)
					CollapseExpand(trList[i],objInput,'none',strText);
				else
					CollapseExpand(trList[i],null,'none',strText);
			}
		}	
	}
	catch(exc){
		alert(exc.message);
	}
}
//'###########################################################################
 function TgCollapseExpandFriend(strTableId,objInput)
 {
	
	var ctrl = document.getElementById(strTableId);
	var strState = ctrl.style.display=='none'?'':'none';
	var strText = '';
	if(objInput){
		strText = ctrl.style.display=='none'? 'Click To Collapse (-)' : 'Click To Collapse (+)'
	}
	try{
		for(i=0; i < trList.length; i++){
			if(strTableId == trList[i]){				
				if(objInput)
					CollapseExpand(trList[i],objInput,strState,strText);
				else
					CollapseExpand(trList[i],null,strState,strText);
			}else{
				if(objInput)
					CollapseExpand(trList[i],objInput,'none',strText);
				else
					CollapseExpand(trList[i],null,'none',strText);
			}
		}	
	}
	catch(exc){
		alert(exc.message);
	}
 }
//############################################################################
function CollapseExpand(strTableId,objInput,strState,strText){
	var ctrl = document.getElementById(strTableId);	
	try	{		
		if(ctrl!=null)
		{			
			ctrl.style.display = strState;
			if(objInput != null)
				objInput.innerText = strText;
/*				
			if(ctrl.style.display.toLowerCase()=="none"){
				ctrl.style.display = strState;
				if(objInput != null)
					objInput.innerText = strText;
			}
			else if(ctrl.style.display.toLowerCase()==""){
				ctrl.style.display = 'none';
				if(objInput != null)
					objInput.innerText = 'More...';
			}
*/			
		}
	}
	catch(exc)
	{
		alert(exc.message);
	}
}
//'###########################################################################
function IAgreeValidate(objInput)
{	
	var strErrMessage = "Please enter 'I Agree' in the given box before continuing.";
	var blnReturnValue;
	if(trim(objInput.value) != '')
	{
		if(objInput.value.toLowerCase() == 'i agree')
			blnReturnValue =  true;
		else
			blnReturnValue =  false;
	}
	else
		blnReturnValue =  false;
	if(!blnReturnValue){
		alert(strErrMessage);								
		event.returnValue = false;
	}
}

//'###########################################################################
function ValidateUserNameLength(sender,args)
{
	args.IsValid = args.Value.length >= 3;
}
//'###########################################################################
function ValidateEMail(sender,args){
	displayProperties(sender)
	if(args.Value.length == '') 
	{
		
	} 
}
//'###########################################################################
function SelectedUsers(objInput){
	var ctrlUserList = document.getElementById('txtUserIds');
	var ctrlSend = document.getElementById('imgbtnSend');
	if(ctrlUserList != null || typeof(ctrlUserList) != 'undefined'){
		if(objInput.checked)
			ctrlUserList.value = AddUser(objInput.id,ctrlUserList.value);
		else
			ctrlUserList.value = RemoveUser(objInput.id,ctrlUserList.value);		
		if(trim(ctrlUserList.value)!='' && ctrlSend!=null)
			ctrlSend.disabled=false;
		else if(trim(ctrlUserList.value)=='' && ctrlSend!=null)
			ctrlSend.disabled=true;
	}
}
//'###########################################################################
function MessageValidate(){
	var ctrlMessage = document.getElementById('txtMessage');	
	
	if(ctrlMessage!=null && trim(ctrlMessage.value)!= '')
		return true;
	else{
		alert('Please enter some message before continuing.');
		return false;
	}
}
//'###########################################################################
function AddUser(strUserId,strUserList){
	var strUsers = strUserList;
	if(trim(strUserList) == '')
		return (strUserId);
	else{
		strUsers = ',' + strUserList + ',';		
		if(strUsers.indexOf(','+strUserId+',')>=0){
			return (strUserList);
		}
		else
			return (strUserList + ',' + strUserId);
	}
}
//'###########################################################################
function RemoveUser(strUserId,strUserList){		
	var strUsers = strUserList;
	var intIndex;
	if(trim(strUserList) == '')
		return (strUserList);
	else{ 
		strUsers = ',' + strUserList + ',';
		intIndex = strUsers.indexOf(','+trim(strUserId)+',');
		if(intIndex==0){
			//Begnining of the string.			
			var strValue = strUsers.replace(','+strUserId+',','');
			return (strValue.substring(0,strValue.length-1));
		}else if(intIndex >0 &&  parseInt(intIndex+2)==parseInt(strUsers.length-1)){
			//In end of the string.			
			return (strUsers.substring(1,strUsers.length).replace(','+strUserId+',',''));
		}else if(intIndex>0){
			//In middle of the string						
			return(strUsers.substring(1,strUsers.length-1).replace(','+strUserId,''));
		}
					
	}
}
//'###########################################################################
function textboxChange(elemId, charElemId, maxLen) {
   var txtelem = document.getElementById(elemId);
   if (txtelem) {
      var curvalue = String(txtelem.value);
      if (curvalue.length > maxLen) {
         txtelem.value = curvalue.substring(0, maxLen);
      }

      var charelem = document.getElementById(charElemId);
      if (charelem) {
         charelem.innerHTML = String(maxLen - txtelem.value.length);
      }
   }
}
//'###########################################################################
function SetMaxLengthLabel(objInput,lblLabel,intMaxLength,args){	
	try{
		//displayProperties(args);
		//args.keyCode = 8;
		if(parseInt(intMaxLength) - parseInt(objInput.value.length)>=0){
			lblLabel.innerText = parseInt(intMaxLength) - parseInt(objInput.value.length);
		}
		if(parseInt(objInput.value.length) > parseInt(intMaxLength)) {
			objInput.value = objInput.value.substring(0, intMaxLength);
		}
	}catch(Exc){
		alert(Exc.message);
	}
}
//'###########################################################################
function CheckAll(objInput){
	var ctrl;	
	var blnChekced = objInput.checked;
	for(var i=0;i<chkArr.length;i++){
		ctrl = document.getElementById(chkArr[i]);
		if(ctrl)
			ctrl.checked = blnChekced;
	}
}
//'###########################################################################
function OCheckAll(objInput,strGridId){
	
}
//'###########################################################################
function TgCollapseExpand(strTableId)
{	
	//alert("first " + strTableId);	
	//var ctrl = document.getElementById(strTableId);
	//alert("second " + typeof(ctrl));	
	//alert("third "  + strTableId.style.display);
	if (tblBasicTrust.style.display == null)
	{
		tblBasicTrust.style.display = "none";
	}
	else
	{
		tblBasicTrust.style.display = "block";
	}
}

//'##########################################################

var ieDOM = false, nsDOM = false;
var stdDOM = document.getElementById; function initMethod()
{
//Determine the browser support for the DOM
if( !stdDOM )

{
ieDOM = document.all;

if( !ieDOM )

{
nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
}
}

passwordChanged();
}

function getObject(objectId)

{
if (stdDOM) return document.getElementById(objectId);
if (ieDOM) return document.all[objectId];
if (nsDOM) return document.layers[objectId];
}

function getObjectStyle(objectId)

{
if (nsDOM) return getObject(objectId);

var obj = getObject(objectId);

return obj.style;
}

function showDefault(objectId)

{
showCell(objectId, "#E2E2E2", "#E2E2E2");
}

function showCell(objectId, foreColor, backColor)
{
getObjectStyle(objectId).color = foreColor;

getObjectStyle(objectId).backgroundColor = backColor;
}

function showWeak()

{
showCell("pwWeak", "Black", "#FF6666");

showDefault("pwMedium");

showDefault("pwStrong");
}

function showMedium()

{
showCell("pwWeak", "#FFCC66", "#FFCC66");
showCell("pwMedium", "Black", "#FFCC66");

showDefault("pwStrong");
}

function showStrong()

{
showCell("pwWeak", "#80FF80", "#80FF80");
showCell("pwMedium", "#80FF80", "#80FF80");
showCell("pwStrong", "Black", "#80FF80");
}

function showUndetermined()

{
showDefault("pwWeak");
showDefault("pwMedium");
showDefault("pwStrong");
}


function passwordChanged(field)
{
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");


var pwd = field.value;
if( false == enoughRegex.test(pwd) )
{
showUndetermined();
}
else if( strongRegex.test(pwd) )
{
showStrong();
}
else if( mediumRegex.test( pwd ) )
{
showMedium();
}
else
{
showWeak();
}
}
		
		
//'##########################################################################
		   
var ic = 4;     
var xoxo = new Array(ic);  
        
xoxo[0] = "main_image-ran/01.gif";
xoxo[1] = "main_image-ran/02.gif";
xoxo[2] = "main_image-ran/03.gif";
xoxo[3] = "main_image-ran/02.gif";

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}

var choice = pickRandom(ic);
//'##########################################################################

<!-- Begin

window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" 
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" 
 && bVer < 4);
 var blink_speed=700;
 var i=0;
 
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}

//BLINKING
function Blink(layerName){
 if (NS4 || IE4) { 
 if(i%2==0)
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="visible"');
 }
 else
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="hidden"');
 }
 } 
 if(i<1)
 {
 i++;
 } 
 else
 {
 i--
 }
 setTimeout("Blink('"+layerName+"')",blink_speed);
}
//'##########################################################################

var state = 'none'; 

function showhide(layer_ref) { 

if (state == 'block') { 
state = 'none'; 
} 
else { 
state = 'block'; 
} 
if (document.all) { //IS IE 4 or 5 (or 6 beta) 
eval( "document.all." + layer_ref + ".style.display = state"); 
} 
if (document.layers) { //IS NETSCAPE 4 or below 
document.layers[layer_ref].display = state; 
} 
if (document.getElementById &&!document.all) { 
hza = document.getElementById(layer_ref); 
hza.style.display = state; 
} 
} 
//'##########################################################################

function CaricaFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}
