<?php 
$longMonth = array("01" => "Enero", "02" => "Febrero", "03"=> "Marzo", "04" => "Abril", "05"=> "Mayo", "06" => "Junio", "07"=> "Julio", "08" => "Agosto", "09"=> "Septiembre", "10" => "Octubre", "11"=> "Noviembre","12" => "Diciembre");
$shortMonth = array("01" => "Ene", "02" => "Feb", "03"=> "Mar", "04" => "Abr", "05"=> "May", "06" => "Jun", "07"=> "Jul", "08" => "Ago", "09"=> "Sept", "10" => "Oct", "11"=> "Nov","12" => "Dic");
$arrOrigenes = array(
	"google" => 0,
	"facebook" => 0,
	"labmoreira" => 0,
	"live" => 0,
	"yahoo" => 0,
	"bing" => 0,
	"prodigy" => 0,
	"babylon" => 0,
	"terra" => 0,
	"itesm" => 0,
	
);

//global $numMaximo;
$numMaximo = 0;
$strUrl = "";
$strUrlImages = "";
$sDominio = "softwaremedicodigital.com";
$strDireccion = "Ave. Chapultepec #800 B-238, Col. Paraiso, Gpe, NL";
$strTerminos = "Terminos y condiciones:<br/><br/>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
 . <a href='".$strUrl."terminosycondiciones.php' target='_blank'>Ver terminos y condiciones</a>";
$strTelefonoContacto = "8122324046";
$strEmailContacto = "soporte@softwaremedicodigital.com";

function limpiar_caracteres_especiales($s) {
	//$s = strtolower($s);
	
	$s = preg_replace("[áàâãªä@]","a",$s);
	$s = preg_replace("[ÁÀÂÃÄ]","A",$s);
	$s = preg_replace("[éèêë]","e",$s);
	$s = preg_replace("[ÉÈÊË]","E",$s);
	$s = preg_replace("[íìîï]","i",$s);
	$s = preg_replace("[ÍÌÎÏ]","I",$s);
	$s = preg_replace("[óòôõºö]","o",$s);
	$s = preg_replace("[ÓÒÔÕÖ]","O",$s);
	$s = preg_replace("[úùûü]","u",$s);
	$s = preg_replace("[ÚÙÛÜ]","U",$s);
	//$s = str_replace("[¿?\]","_",$s);
	//$s = str_replace(" ","-",$s);
	//$s = str_replace("ñ","n",$s);
	//$s = str_replace("Ñ","N",$s);
	//para ampliar los caracteres a reemplazar agregar lineas de este tipo:
	//$s = str_replace("caracter-que-queremos-cambiar”,”caracter-por-el-cual-lo-vamos-a-cambiar”,$s);
	
	//$s = preg_replace("[ÚÙÛÜ]","U",$s);
    //$s = preg_replace(array("\r\n", "\n", "\r"), '<br/>', $s);
    $s = preg_replace("/(\s*[\r\n]+\s*)/", "<br>", $s);
    
	return $s;
}

function setMaximo($intCuantos){
	global $numMaximo;
	if($intCuantos > $numMaximo){
		$numMaximo = $intCuantos;
	}	
}
function getMaximo(){
	return $numMaximo;
}
function session_validation(){
	if(!isset($_SESSION['intEmpresa'])){
		exit('<script type="text/javascript">location.replace("index.php")</script>');
	}
}
//FORMATO ESPERADO: YYYY-MM-DD
function dateFormatted($strDate){
	global $shortMonth;
	$data = explode("-",$strDate);
	return $data[2]."/".$shortMonth[$data[1]]."/".$data[0];
}
//FORMATO ESPERADO: YYYYMMDD
function fnDateFormat($strDate){
	global $shortMonth;
	$anio = substr($strDate, 2, 2);
	$mes = substr($strDate, 4, 2);
	$dia = substr($strDate, -2);
	///exit($anio." - ". $mes . " - ". $dia);
	return $shortMonth[$mes]." ".$dia." ".$anio;
}
	
function getAgeByBirthYear($year){
	$currentYear = date("Y");
	$age = $currentYear - intval($year);
	
	return $age;
}

function SLERI_LOG($Mensaje){
	$MyFile = "LOG.txt";
	$fh = fopen($MyFile,'w+');
	fwrite($fh, $Mensaje);
	fclose($fh);	
}

function fnFormatDescripcion($strDescripcion){ // MODIFICACION DE STRDESCRIPCION
	
	$strDescripcion = str_replace("&","&", str_replace("&MODE=1&","", str_replace(">","", str_replace("<","", $strDescripcion))));
	//$strDescripcion = str_replace("&","&", str_replace("&MODE=2&","", str_replace(">","", str_replace("<","", $strDescripcion))));
	$arr = explode("&", $strDescripcion);
	
	$ii=0;
	$strReturn = "";
	foreach ($arr as $valor) {
		if($ii==0){ //SUCURSALES ITEM
			$valor = str_replace("sucursales=","", $valor);
			$arrSucs = explode(",", $valor);
			
			$strSucs = "";
			foreach ($arrSucs as $idSuc) {
				$strSucs .= getSuc($idSuc).",";
			}
			
			$strReturn .= "Sucursales=".substr($strSucs, 0, -1)." | ";
			
		}else{
			$pos = strpos($valor, "random");
			if($pos === false){
				$strReturn .= $valor." | ";
			}
		}
		
		$ii++;
	}
	
	return substr($strReturn, 0, -3);

}

/*function enviarEmail($strEmail, $strDetalleEmail){
	global $sDominio;
	
	$cuerpo = "<html><head><meta charset="windows-1252"><title>HTML email</title></head><body>";
	$cuerpo .= $strDetalleEmail ."<br/><br/> \n\n";
	
	//$cuerpo .= "Email:". $strEmail ." <br/><br/> \n\n";
	//$strEmail = "kropijac@hotmail.com";

	$cuerpo .= "</body></html>";
				
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
	// More headers
	$headers .= "From: Capacitacion KyK <info@". $sDominio . ">\r\n"; 

	mail($strEmail, "Nuevo Mensaje", $cuerpo, $headers);

}
*/
?>