﻿function ReplaceURL(objID,replaceURL)
{
var obj=document.getElementById(objID);
	if(obj)
	{
		obj.href=replaceURL;		
	}
}
function contactusValidation()
{
mes=new String();
if(document.getElementById("ctl00_MainContent_ctl00_txtFirstName").value=='')
{
mes+="Si prega di inserire il nome prima.\n";
}
if(document.getElementById("ctl00_MainContent_ctl00_txtLastName").value=='')
{
mes+="Si prega di inserire il cognome.\n";
}
if(document.getElementById("ctl00_MainContent_ctl00_txtEmail").value=='')
{
mes+="Si prega di inserire l'indirizzo e-mail.";
}
else if(isEmail(document.getElementById("ctl00_MainContent_ctl00_txtEmail").value)==false)
{
mes+="Si prega di inserire l'indirizzo email valido.";
}
if(mes=='')
{
return true;
}
else
{
alert(mes);
return false;
}
}
function isEmail(string) 
{
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}
var XmlHttp;
function trackEntry(counter)
{
    pageTracker._trackEvent('Clicks','confronta-home');
    var requestUrl = "/assicurazione-CallBack.aspx?Option=InsertCounter&counter=" + counter;
    WebHTTPCall(requestUrl);
}
function WebHTTPCall(requestUrl)
{CreateXmlHttp();
if(XmlHttp){
XmlHttp.onreadystatechange = HandleResponse;
XmlHttp.open("GET", requestUrl,  true);
XmlHttp.send(null);}
}
function HandleResponse()
{
    if(XmlHttp.readyState == 4){
        if(XmlHttp.status == 200){}}
}
function CreateXmlHttp()
{
    try{XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e) {try{XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");} 
        catch(oc){XmlHttp = null;}//Creating object of XMLHTTP in Mozilla and Safari 
        if(!XmlHttp && typeof XMLHttpRequest != "undefined"){XmlHttp = new XMLHttpRequest();}}
}
function SurveyHideShow(obj)
{
ShowHideItem(obj)
}


function popup(url)
{
window.open(url);
return false;
}
//Remove//
function ContactanosValidation()
{
    var objtxtEmail=document.getElementById("ctl00_ContentTop_txtEmail");
    var objtxtSugerencias=document.getElementById("ctl00_ContentTop_txtSugerencias");
    var objtxtCustomerName=document.getElementById("ctl00_ContentTop_txtCustomerName");
    if(objtxtCustomerName.value=="")
    {
        alert("por favor, introduzca Nombre");
        objtxtCustomerName.focus();
        return false;   
    }
    if(!emailValid(objtxtEmail.id))
    {
        alert("Por favor, introduce una direcci\u00F3n de e-mail correcta");        
        return false;
    }
    if(objtxtEmail.value=="")
    {
        alert("por favor, introduzca Email");
        objtxtEmail.focus();
        return false;
    }
    if(objtxtSugerencias.value=="")
    {
        alert("por favor, introduzca Comentario");
        objtxtSugerencias.focus();
        return false;
    }
}function emailValid(id1) 
{
    if (document.getElementById(id1).value=="") 
      {      
        return false;
      }     
     var emailPat =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
     var emailid=document.getElementById(id1).value;
     var matchArray = emailid.match(emailPat);     
     if (matchArray == null)
        {        
          document.getElementById(id1).focus();
          return false;
        }     
        
    var source=document.getElementById(id1).value;
    var ext=source.substring(source.lastIndexOf("@")+1);
        
    var digits="(~`!#$%^&*_+|-=}{'?/)";
    var temp;
    for (var i=0;i<ext.length;i++)
    {
       temp=ext.substring(i,i+1);
       if (digits.indexOf(temp)>=0)
       {
        document.getElementById(id1).focus();
        return false;       
        }
    }
    return true;
}
function mailtofriend()
{
var currentPageTitle="";
var objCurrentPageTitle=document.getElementById("ContentPageTitle");
if(objCurrentPageTitle)
{
currentPageTitle=objCurrentPageTitle.innerHTML;
}
tb_show("","/mailtofriend.aspx?currentPageTitle=" + currentPageTitle + "&TB_iframe=true&height=200&width=420",false);
return false;
}
function validateMailToFriend()
{
var objtxtName=document.getElementById("txtName");
var objtxtEmail=document.getElementById("txtEmail");
 if(objtxtName.value=="")
    {
        alert("por favor, Tu Nombre");
        objtxtName.focus();
        return false;
    }
    if(!multipleEmailValidate(objtxtEmail.id))
    {
        alert("Por favor, introduce una direcci\u00F3n de e-mail correcta");        
        return false;
    }
}
function multipleEmailValidate(id1) //function to validate Email format
{
    if (document.getElementById(id1).value=="") 
      {      
        return false;
      }  
      
     var objemail=document.getElementById(id1);
     
     var email = objemail.value.split(',');
        //alert(email.length);       
     for (var i = 0; i < email.length; i++) 
     {    
         var emailPat =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
         var emailid=email[i];
         //alert(emailid);
         var matchArray = emailid.match(emailPat);     
         if (matchArray == null)
            {        
              document.getElementById(id1).focus();
              return false;
            }     
            
        var source=email[i];
        var ext=source.substring(source.lastIndexOf("@")+1);
            
        var digits="(~`!#$%^&*_+|-=}{'?/)";
        var temp;
        for (var i=0;i<ext.length;i++)
        {
           temp=ext.substring(i,i+1);
           if (digits.indexOf(temp)>=0)
           {
            document.getElementById(id1).focus();
            return false;       
            }
        }
    }
    return true;
}
function stopRKey(e)
 {
    var evt = (e) ? e : window.event;
    var key = (evt.keyCode) ? evt.keyCode : evt.which;
     if (key == 13)
     {   
     SearchTrack();   
        return false;         
     }
  }
  
function ShowHideNewsItem(obj,classObj)
{
    var Itemobj=document.getElementById(obj);
    var AnchorTagObj=document.getElementById(classObj);
    if(Itemobj.style.display=="none")
    {
    Itemobj.style.display="";
    AnchorTagObj.className="bg_sna_link bg_sna_open";
    }
    else
    {
    Itemobj.style.display="none";
    AnchorTagObj.className="bg_sna_link bg_sna_closed";
    }
}
function ShowHideItem(obj)
{
    var Itemobj=document.getElementById(obj);    
    if(Itemobj.style.display=="none")
    {
    Itemobj.style.display="";
    }
    else
    {
    Itemobj.style.display="none";
    }
}
 function mouseOverImage(controlID) {    
document.getElementById(controlID.id).src = "/NewImages/btn_confronta_f_hover.gif";
}
function mouseOutImage(controlID) {    
document.getElementById(controlID.id).src = "/NewImages/btn_confronta_f.gif";
}
function lnkReplaceCall() 
{
    lnkReplace('lnkFaceBook');
    lnkReplace('lnkDelicious');
    lnkReplace('lnkDigg');
    lnkReplace('lnkTwitter');
    lnkReplace('lnkTechnorati');
    lnkReplace('lnkGoogle');
    lnkReplace('lnkYahoo');
    lnkReplace('lnkWikio');
    lnkReplace('lnkFresqui');
    lnkReplace('lnkLinkedin');
}
function lnkReplace(objID) {
    var currentPageUrl = window.location;
    var currentPageTitle = "";
    var objCurrentPageTitle = document.getElementById("ContentPageTitle");
    if (objCurrentPageTitle) {
        //currentPageTitle = RTrim((LTrim(objCurrentPageTitle.innerHTML)));
        currentPageTitle = RTrim((LTrim(objCurrentPageTitle.innerHTML)));
    }
    var obj = document.getElementById(objID);
    if (obj) {
        var objhref = obj.href;
        objhref = objhref.replace('*PageURL*', currentPageUrl);
        objhref = objhref.replace('*Pagetitle*', currentPageTitle);
        objhref = objhref.replace('*Pagetitle*', currentPageTitle);
        objhref = objhref.replace('*PageURL*', currentPageUrl);
        obj.href = objhref;
    }
}
function LTrim(value) {
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");

}
// Removes ending whitespaces
function RTrim(value) {
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");
}
function ConfrontaButtonClick()
{
winURL=window.location.href;
window.location.href='/tracker.aspx?Counter=it.car.Confronta.buttonclick&amp;URL='+winURL;
}









