


// opens a dialog. needs id, e.g.  dlg_ContactName
// psParams - pass in $(this).attr('params')
function openAnyDialog(psDialogID, pnWidth, pnHeight, psParams, pbResizable)
{
    
	var sSelector='#dlg_'+psDialogID;
    
    if (pbResizable != true)
    {
        pbResizable = false;
    }
    
	parent.$(sSelector).dialog(
		{autoOpen: false, 
		width: pnWidth, 
		height: pnHeight, 
		resizable: pbResizable,
        autoResize: false,
		modal: false, 
		overlay: 'none', //{ backgroundColor: '#000000', opacity: '0.4' }, 
		stack: true, 
		open: function() 
			{ eval('parent.Open_'+psDialogID+'_Dialog();'); }
		/*close: function() 
			{ eval('parent.Close_'+psDialogID+'_Dialog();'); }*/
		});
		
	parent.$('#hid_params').val(psParams);
    parent.$(sSelector).addClass('nopadding');
    parent.$(sSelector).find('iframe').attr('style','width: '+pnWidth+'px; height: '+(pnHeight-30)+'px;');
    parent.$(sSelector).dialog('open');
}


    function getIFrameDocument(aID){
      if (document.getElementById(aID).contentDocument){  
        return document.getElementById(aID).contentDocument;
      } else {
        return document.frames[aID].document;
       }
     }
     
    function doRichEditCommand(psID, aName, aArg)
    {
      try {
        getIFrameDocument(psID).execCommand(aName,false, aArg);
        document.getElementById(psID).contentWindow.focus();
      } catch(ex) {
        // do nothing - just to hide any errors (i.e. no text selected)
      }
      
    } 
    
    
function echeck(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (lstr==0){
	   return false;
	}
	
	if (str.indexOf(at)==-1){
	   return false;
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false;
	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
	    return false;
	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false;
	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
	    return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false;
	 }
	 return true;					
}
    
