// JavaScript Ford.com.br 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function isCPF(cpf)
{
	var 
	    char_valido = 0, 
	    char_invalido = 0, 
	    digito1, 
	    digito2,
	    soma_digito1 = 0,
	    soma_digito2 = 0;
	
	if (cpf == '00000000000' || cpf == '11111111111' ||	cpf == '22222222222' || cpf == '33333333333' ||	cpf == '44444444444' || cpf == '55555555555' ||	cpf == '66666666666' || cpf == '77777777777' || cpf == '99999999999'){
		return false;
	}
			  	    
	if (cpf.length == 11)
	{	
		for (var i = 0; i <= cpf.length - 1; i++)
		{	
			if (cpf.charAt(i) >= '0' && cpf.charAt(i) <= '9')
			{
				char_valido = char_valido + 1;
			}
			else
			{
				char_invalido = char_invalido + 1;
			}
		}
		    
		if (char_valido == cpf.length)
		{
			for (i = 0; i < 9; i++)
			{
				soma_digito1 += (10 - i) * (eval(cpf.charAt(i)));
			}
			digito1 = 11 - (soma_digito1 % 11);
			        
			for (i = 0; i < 9; i++)
			{
				soma_digito2 += (11 - i) * (eval(cpf.charAt(i)));
			}
			soma_digito2 += 2 * (eval(cpf.charAt(9)));
			digito2 = 11 - (soma_digito2 % 11);
			        
			if ((soma_digito1 % 11) < 2)
			{
				digito1 = 0;
			}
			        
			if ((soma_digito2 % 11) < 2)
			{
				digito2 = 0;
			}
		        
			if (eval(cpf.charAt(9) != digito1) || eval(cpf.charAt(10) != digito2))
			{
				return false;
			}
		}
		else
		{
			return false;
		}	      
	}
	else
	{
		return false;
	}
	return true;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_moveLayers() { //v6.0
  var i,p,t,l,obj,args=MM_moveLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {l=args[i+1]; t=args[i+2];
    if (obj.style) obj=obj.style;
    if(t!='') obj.top=t;
    if(l!='') obj.left=l; }
}

function isMail(str) {
	var pass = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) pass = 1;
	}

	if (!pass)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}
	
function isDate( dd, mm, aaaa )	{
	dtm = new Date( aaaa, mm - 1, dd );
	if( dtm.getMonth() != ( mm - 1 ) )
		return false;			
	return true;	}

function Numerico( key )	{
	if( key < 48 || key > 58 )
		event.keyCode = '';	}
		
function xNumerico(evnt){
	var key=(window.event)?event.keyCode:evnt.charCode;
	if(!window.event && evnt.keyCode!=0) return true;
	if(key<48 || key>58) return false;
	return true;
}

function Trim( str )	{
	regexp	= /^\ */;
	str		= str.replace( regexp, '' );
	regexp	= /\ *$/;
	return str.replace( regexp, '' );	}
	
function pop( strPagina, intLargura, intAltura, booRolagem ){
	strJanela	=	"pop" + (intLargura+intAltura);
	var	objjan	=	window.open( strPagina, strJanela, 'width=' + intLargura + ',height=' + intAltura +',menubar=no,location=no,scrollbars=' + booRolagem + ',status=no,toolbar=no,resizable=no,top=100,left=100' );	
	objjan.focus();
}

function busca(){	
	window.opener.parent.frames['iframeContent'].location.href	=	'institucional/respostaBusca.asp@textfield='	+	document.forms[0].elements['textfield'].value;
	window.opener.focus();
}

	
	
	
var bIsIE=(navigator.appName.indexOf("Explorer")>-1);
var iVersion=(bIsIE) ? parseInt(navigator.appVersion.split("MSIE")[1]) : parseInt(navigator.appVersion);
var bIsAble=(parseInt(navigator.appVersion)>=4);
var ibama = null;

function placeLayer() {
	if (!bIsIE) return(0);
	var iScreenCenter = document.body.clientWidth;
	ibama.style.left = "" + parseInt((iScreenCenter / 2) - 371) + "px";
	ibama.style.visibility = "visible";
}

function getObject(sObjName) {
	return(document.all[sObjName]);
}

function _MenuLoad() 
{
	ibama = getObject("ibama");	
	placeLayer();
	setTimeout("placeLayer()", 500);
}



//onresize = function() {
//	placeLayer();
//}

// ALERTA
function disclaimer(url,janela){
	if(confirm('Você está saindo do ambiente www.ford.com.br\nOs conteúdos exibidos em outros sites são de responsabilidade dos mesmos. Certifique-se de que são seguros.\nClique em cancelar para permancer no site www.ford.com.br ou, se deseja continuar, clique em ok.')){	
	window.open(url,janela);
	}
}
function disclaimer2(){
	if(confirm('Você está saindo do ambiente www.ford.com.br\nOs conteúdos exibidos em outros sites são de responsabilidade dos mesmos. Certifique-se de que são seguros.\nClique em cancelar para permancer no site www.ford.com.br ou, se deseja continuar, clique em ok.')){
	window.open('../https@200.184.130.31/ford/cliente/frm_login.asp@IDArea=1&sel=Ford','remote','width=320,height=450,menubar=no,location=no,scrollbars=no,status=no,toolbar=no,resizable=no');
	}
}

function go2SalesProcess(){
	alert('Site em manutenção.')
}

