

function toggleVisibility(elementId, show, anchorTo){
    var anchorObj = document.getElementById(anchorTo);
   
	var obj = document.getElementById(elementId);	
    if(obj != null){
    	//if(anchorObj != null){
    	
    		//obj.style.left = findPosY(anchorObj);
    		//obj.style.top = findPosX(anchorObj);
    	//}        
        if(show == true){
    		obj.style.visibility = 'visible';
    	}else{
    		obj.style.visibility = 'hidden';
    	}
    }
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function validateEmail(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    
    //no @ or @ at end or beginning
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){           
       return false;
    }

    //no dot or dot at end or beginning
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr -1){           
        return false;
    }
    
    //more than 1 @
    if (str.indexOf(at,(lat+1))!=-1){
       return false;
    }
    
    //dot straight before or after @
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
       return false;
    }
    
    //at least one char after @ before dot
    if (str.indexOf(dot,(lat+2))==-1){
       return false;
    }
    //no spaces
    if (str.indexOf(" ")!=-1){
       return false;
    }

    return true;                  
}

function isEmail(aValue){
	if (aValue.indexOf('@') > -1){           
       return true;
    }
}
///preload the wait image
if (document.images){
     waitImage= new Image(32,32);
     waitImage.src="images/loading.gif";      
}      
