   function ClientValidateEmail(source, clientside_arguments)
   {         
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(clientside_arguments.Value)) 
            clientside_arguments.IsValid=true;   
        else {clientside_arguments.IsValid=false};
   }
   
   function ClientValidatePassword(source, clientside_arguments)
   {         
        var ok = true;
        if (clientside_arguments.Value.length < 5) ok = false;
        if (!clientside_arguments.Value.match(/([a-z]|[A-Z])/)) ok = false;
        if (!clientside_arguments.Value.match(/([0-9])/)) ok = false;        
        clientside_arguments.IsValid=ok;
   }   
   
   function ClientValidateCheckBox(source, clientside_arguments)
   {         
        var cb =  document.getElementById(source.getAttribute('cid'));
        if (cb.checked) 
            clientside_arguments.IsValid=true;
        else clientside_arguments.IsValid=false;
   }    
   
   function ClientValidateSelect(source, clientside_arguments)
   {         
         sel = document.getElementById(source.id.replace('CV_','')); 
         if (sel.options.length > 0) clientside_arguments.IsValid=true;
         else clientside_arguments.IsValid=false;
   }       
   
   function ClientValidateHidden(source, clientside_arguments)
   {         
        if (clientside_arguments.Value != "1") clientside_arguments.IsValid=true;
        else clientside_arguments.IsValid=false;
   }     
   
   function popup(url,w,h,title)
   {
        var nw=window.open(url,title,'resizable=yes,scrollbars=auto,menubar=no,width='+w+',height='+h+';');
        if (window.focus) {nw.focus()}
   }
   
   function button_md(t)
   {
        if (t.src.indexOf("_.")==-1) t.src=t.src.replace('.gif','_.gif')
   }
   
   function button_mu(t)
   {
        t.src=t.src.replace('_.gif','.gif')
   }
   

function addOption(theHid, theSel, theText, theValue, mode)
{
	var newOpt = new Option(theText, theValue);
	//newOpt.selected = true;
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
    if (mode == 1) theHid.value = theHid.value + theValue + ',';
}

function deleteOption(theHid, theSel, theIndex , mode)
{	
	var selLength = theSel.length;
	if(selLength>0)
	{ 
	    if (mode == 0)
	    {
	        var item = ',' + theSel.options[theIndex].value + ','; 
	        theHid.value = theHid.value.replace(item,',');
	    }    
		theSel.options[theIndex] = null;
	}
}


function moveOptions(theHiddenId,theSelFromId, theSelToId,mode)
{
	var theHidden = document.getElementById(theHiddenId);
	var theSelFrom = document.getElementById(theSelFromId);
	var theSelTo = document.getElementById(theSelToId);
	var selLength = theSelFrom.length;
	var selectedText = new Array();
	var selectedValues = new Array();
	var selectedCount = 0;
	var i;
	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			selectedText[selectedCount] = theSelFrom.options[i].text;
			selectedValues[selectedCount] = theSelFrom.options[i].value;
			deleteOption(theHidden,theSelFrom,i,mode);
			selectedCount++;
		}
	}
	for(i=selectedCount-1; i>=0; i--)
	{
		addOption(theHidden, theSelTo, selectedText[i], selectedValues[i],mode);
	}
}  
