
	function showHide(ID, action){
		//alert(action);
		if(action == 'hide'){
			$(ID).style.display = 'none';	
		} 
		if(action == 'show'){
			$(ID).style.display = '';		
		}
		
	}
	
	function toggleDisplay(ID){
		//alert(action);
		if($(ID).style.display == 'none'){
			$(ID).style.display = '';	
		} else {
			$(ID).style.display = 'none';		
		}
		
	}
	
	function activateField(FieldID){
		
		$(FieldID).disabled = false;
		
	}		
	
	function stripAlphaChars(pstrSource) { 
	
		var m_strOut = new String(pstrSource); 
    m_strOut = m_strOut.replace(/[^0-9]/gi, ''); 
    return m_strOut; 
	}

	
	function addCommas(nStr){
	
		var nStr = stripAlphaChars(nStr);
		
		var forcur = nStr;
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 3 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
		var ret_value = x1 + x2; 
		
		return ret_value;  // retorna o numero formatado
	}
	
	function validateEmailAddress(VALUE){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(VALUE)){
			return true;
		} else {
			return false;		
		}
	}
	
	function limiter(field, counter_field, option){	
		
		if(option == 1){
			var count = "500";
		}
		if(option == 2){
			var count = "255";
		}
		if(option == 3){
			var count = "50";
		}
		if(option == 4){
			var count = "1000";
		}
		
		var tex = $(field).value;
		var len = tex.length;
		if(len > count){
			tex = tex.substring(0,count);
			$(field).value =tex;
			return false;
		}
		$(counter_field).value = count-len;
			
		//$(counter_field).innerHTML = count-len;
	}
	
	function getTheChars(field, limiter, option){
			
		if(option == 1){
			var count = "500";
		}
		if(option == 2){
			var count = "255";
		}
		if(option == 3){
			var count = "50";
		}
		if(option == 4){
			var count = "1000";
		}
		
		var boxchars = $(field).value;
				
		var rest = count - boxchars.length;
				
		$(limiter).value = rest;
				
	}
			
	
	function dateValidation(VALUE){
		// vALIDATE A DATE IN YYYY/MM/DD FROMAT 		
		if (/^(19|20)?(\d{2})-(0?[1-9]|1[0-2])-(0?[1-9]|[12]\d|3[01])$/.test(VALUE)){
			return true;
		} else {
			return false;		
		}
	}
	
	function abrir_modal(valor, element_id){
	$(element_id).href=valor;
	//alert($(row_id).href);
	
	var m = new Control.Modal(element_id,{
            iframe: true,
            width: 530,            
						height: 400
					});
	m.open();
	}
	
		function abrir_modal_leed_updt(valor, element_id){
			$(element_id).href=valor;
			//alert($(row_id).href);
	
			var m = new Control.Modal(element_id,{
           	 iframe: true,
           	 width: 530,            
						height: 700
					});
	m.open();
	}

	function abrir_modal_leed(valor, element_id){
	$(element_id).href=valor;
	//alert($(row_id).href);
	
	var m2 = new Control.Modal(element_id,{
            iframe: true,
            width: 600,            
						height: 450
						//, opacity: 0.80
					});
	m2.open();
	}
	
	function AddFavorite(ELEMENT, TYPE, REF_CLIENT, PRFX){
	
		new Ajax.Request('ajax/ajax_user_actions.php', {
			method: 'post',
			parameters: {
			add_favorite: '1',
			fav_element: ELEMENT, 
			fav_type: TYPE,
			user_id: REF_CLIENT
			},
				onCreate: function(){
					$('fav_img'+PRFX).style.display = 'none';
					$('fav_on'+PRFX).style.display = '';
				},
				onComplete: function(transport) {
					
					$('fav_on'+PRFX).style.display = 'none';
					$('fav_ok'+PRFX).style.display = '';
					
					//if(transport.responseText == 1){   	// Response is ok 
					
					//document.location.href='my_account_favorites.php';
					//} 
				}
		});
	}
	
	function RemoveFavorite(favorito){  // não implementado ainda
		
		new Ajax.Request('ajax/ajax_user_actions.php', {
			method: 'post',
			parameters: {
			remove_favorite: '1',
			fav_id: favorito 
			},
				onCreate: function(){
				//	$('favorite_on').style.display = '';
				//	$('fav_del').style.display = 'none';
				},
				onComplete: function(transport) {
					
					//$('favorite_on').style.display = 'none';
					
					
					//if(transport.responseText == 1){   	// Response is ok 
					
					document.location.href='my_account.php?screen=12';
					//} 
				}
		});
	}
