// johann 16/07/2010 visite virtuelle 
function openPhotoDetail(idPhoto, idChaine, idAnnonce, versionAnnonce, url_visitVirt){
	//alert(url_visitVirt);
	window.location.href='#';
	hideSelect();
	
	var myAjax = new Ajax.Request(
		'/communfo/popincommunfo/default/backvisiophotos/',
		{
			method: 'get',
			asynchronous: true,
			parameters: {'annonce': idAnnonce,'version': versionAnnonce,'idChaine': idChaine},
			onSuccess: function (xhr)
			{
				var liste = xhr.responseText;
				
				if(window.ActiveXObject)
				{
					xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async="false";
					xmlDoc.loadXML(liste);
				}
				else 
				{
					if(window.XMLHttpRequest)
					{
						parser=new DOMParser();
						xmlDoc=parser.parseFromString(liste,"text/xml");
					}
					else
					{
						alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
						return;
					}
				}

				lignes = xmlDoc.getElementsByTagName('ligne');
				
				cntvig = '';
				for(i=0 ; i < lignes.length ; i++)
				{
					v_src = lignes[i].getElementsByTagName('urlMiniature')[0].childNodes[0].nodeValue;
					v_idp = lignes[i].getElementsByTagName('idPhoto')[0].childNodes[0].nodeValue;
					v_pho = lignes[i].getElementsByTagName('urlPhoto')[0].childNodes[0].nodeValue;
					
					
					if(idPhoto == v_idp || (idPhoto=='' && i==0))
					{
						cntvig+= '<div class="selected">';
						$('layr_photo_pic').innerHTML = '<img onerror="this.src=\'/communfo/img/modules/visiophoto/no_vis_p.png\'" onload="redimImage(this, \'600\', \'400\')" src ="'+ v_pho +'" />';
					}
					else
					{
						cntvig+= '<div>';
					}
					cntvig += '<img onerror="this.parentNode.style.display=\'none\';" onload="redimImage(this, \'90\', \'70\')" src ="'+ v_src +'" onclick="changePhoto(this,\''+v_pho+'\')" ';
					cntvig += ' /><span></span></div>';
				}
				// johann 16/07/2010 visite virtuelle 
				if(url_visitVirt){
					if(url_visitVirt !=''){
						cntvig += '<div style="text-align:center;"><a href="'+url_visitVirt+'" target="_blank" style="color:#ffffff;"><img src="/auto-moto/images/modules/rechercheautofosinequa/demo/360_detail_auto.jpg" /><br />Voir la visite 3D</a></div>';
					}
				}
				$('layr_photo_vig').innerHTML = cntvig;
				
			}
		}
	);
	if(idChaine=='9') { idChaine = 'I'; }
	$('layr_top1').src = '/communfo/js/modules/popincommunfo/popinphoto.htm?C='+idChaine;
	
	$('fond_photo').style.height = document.body.clientHeight + 'px';
	$('fond_photo').style.display = 'block';
	$('layr_photo').style.display = 'block';

}
function changePhoto(obj,url)
{
	tbv = $('layr_photo_vig').getElementsByTagName('div');
	for(j=0 ; j < tbv.length ;j++)
	{
		tbv[j].className = '';
	}
	obj.parentNode.className = 'selected';
	$('layr_photo_pic').innerHTML = '<img src="'+ url +'" onload="redimImage(this, \'600\', \'400\');" onerror="this.src=\'/communfo/img/modules/visiophoto/no_vis_p.png\'" />';
}
function closePhoto()
{
	$('fond_photo').style.display = 'none';
	$('layr_photo').style.display = 'none';
	showSelect();
}
function showSelect()
{
	if($('pv_menu_passAnnonce')){
		$('pv_menu_passAnnonce').style.display = '';
	}
	tb = document.getElementsByTagName('select');
	for(i=0;i<tb.length;i++) { tb[i].style.visibility = 'visible'; }
}
function hideSelect()
{
	if($('pv_menu_passAnnonce')){
		$('pv_menu_passAnnonce').style.display = 'none';
	}
	tb = document.getElementsByTagName('select');
	for(i=0;i<tb.length;i++) { tb[i].style.visibility = 'hidden'; }
}

// contact+
function openPop09(namepop){
	hideSelect();
	$('fond_photo').style.height = document.body.clientHeight + 'px';
	$('fond_photo').style.display = 'block';
	/* retourbugs 181110  */
	$('fond_photo').onclick = function() {$('fond_photo').style.display = 'none';$('layr_'+namepop).style.display = 'none';showSelect();}
	/* fin retourbugs 181110  */
	var NavVersion = navigator.appVersion;

	if ((NavVersion.search("Chrome") == -1)&&(NavVersion.search("Safari") == -1)){		
		BodHeight = document.documentElement.scrollTop;
	} else {	
		BodHeight = document.body.scrollTop;
	}	

	posT = BodHeight+100;
	$('layr_'+namepop).style.top = posT+'px';
	$('layr_'+namepop).style.display = 'block';		
	
}

function closePop09(namepop){
	$('fond_photo').style.display = 'none';
	$('layr_'+namepop).style.display = 'none';		
	
	// remise à 0 des étapes
	if ($('etp3').style.display = 'block'){
		$('etp2').style.display = 'block';
		$('etp3').style.display = 'none';			
	}
	
	/* retourbugs 181110  */
	showSelect();
	/* fin retourbugs 181110  */
}

function cp_etpsuiv(ValUrl){
	$('etp2').style.display = 'none';
	$('etp3').style.display = 'block';		
}

function appelcp2(ValUrl) {

        param = $("contactplus").serialize();
       $("etp2").innerHTML = $("msgencours").innerHTML; 

        new Ajax.Request(
            ValUrl,
            {
                method: 'post',
                parameters: param,
                onSuccess: function(transport) {    $("etp2").innerHTML = transport.responseText;
                                                    tabScript = $("etp2").getElementsByTagName('script');
                                                    for (i=0; i<tabScript.length; i++) {
                                                        window.eval(tabScript[i].text);
                                                    }
                                                },
                onFailure: function(transport) { $("etp2").innerHTML = 'Une erreur technique est survenue, merci de réessayer ultérieurement.'; }
            }
        );
}

function appelcp3(ValUrl) {
        // appel DI
        var mail=$('tag_mail').value;
        var codepos=$('tag_codepos').value;
        var typenv = $('tag_typenv').value;
        var recva = '';
        var aidep = '';
        
        if ($('rdbCreeAlert0').checked) {
            recva = 'recevoir_annonce'; 
        }
        if ($('rdbAidePro0').checked) {
            aidep = 'aide_pro'; 
        }
        
        actionTagClickMTDI('', '', '', '', '', '', '', '1627', "'"+mail+"'", '', '', "'"+typenv+"'", '', '', '', '', "'"+recva+"'", "'"+aidep+"'", "'"+codepos+"'", '', '', '', '', '', '', '');
        // Fin Appel DI       
        
        
        param = $("etape2").serialize();
        $("etp3").innerHTML = $("attserv").innerHTML; 
        new Ajax.Request(
            ValUrl,
            {
                method: 'post',
                parameters: param,
                onSuccess:  function(transport) {   $("etp3").innerHTML = transport.responseText;
                                                    //Exécution de script dans AJAX
                                                    tabScript = $("etp3").getElementsByTagName('script');
                                                    for (i=0; i<tabScript.length; i++) {
                                                        window.eval(tabScript[i].text);
                                                    }

                                                  },
                onFailure: function(transport) { $("etp3").innerHTML = 'Une erreur technique est survenue, merci de réessayer ultérieurement.'; }
            }
        );
        
        $("etp2").innerHTML = '';
        
}


function appelconfirm(ValUrl) {
         // appel DI
        var mail=$('tag_mail').value;
        
        actionTagClickMTDI('', '', '', '', '', '', '', '1628', "'"+mail+"'", '', '',"'"+paramNL+"'", '', '', '', '', '', '', '', '', '', '', '', '', '', '');

        // Fin Appel DI
        param = $("etape3").serialize();
        new Ajax.Request(
            ValUrl,
            {
                method: 'post',
                parameters: $("etape3").serialize(),
                onSuccess: function(transport) {    $("etp3").innerHTML = transport.responseText;
                                                     //Exécution de script dans AJAX
                                                     
                                                    tabScript = $("etp3").getElementsByTagName('script');
                                                    for (i=0; i<tabScript.length; i++) {
                                                        window.eval(tabScript[i].text);
                                                    }
                                                },
                onFailure: function(transport) { $("etp3").innerHTML = 'Une erreur technique est survenue, merci de réessayer ultérieurement.'; }
            }
        );
        
        $("etp3").innerHTML = $("attserv").innerHTML; 

}

function verifFormEtp2() {
    var mess='';
    if (verifRadioButton('rdbCreeAlert') === false) mess +='<li>Merci de choisir si vous voulez recevoir des alertes.</li>';
    if (verifRadioButton('rdbAidePro') === false) mess +='<li>Merci de choisir si vous voulez être aidé par un professionnel.</li>';
    if ($('pass') !== null && $('pass').value === '' ) mess +="<li>Merci d'indiquer un mot de passe.</li>";
//    if ($('cp') !== null && $('cp').value === '' ) mess +="<li>Merci d'indiquer un code postal</li>";

    if (mess !== '') {
        $('contmesserr2').style.display = "block";
		$('messerr2').innerHTML = mess;
        return false;
    }
    return true;
}

var numnews = 0;
var armess = new Array();
var paramNL = '';

function verifFormEtp3() {
    var mess = '';
    paramNL = '';
    
    for (a=1; a<=numnews; a++) {
        if (verifRadioButton('newsl'+a) === false) {
            mess +='<li>'+armess[a]+'</li>';
        } else {
            paramNL += $('NL'+a).value; 
            if ($("NL"+a+"O").checked) tab = 'O';
            if ($("NL"+a+"N").checked) tab = 'N';
            
            paramNL += tab + '|';
            
            
        }
    }

    if (paramNL.charAt(paramNL.length - 1) == '|') {
        paramNL = paramNL.substring(0, paramNL.length - 1);
    }

    if (mess !== '') {
        $('contmesserr3').style.display = "block";
		$('messerr3').innerHTML = mess;
        return false;
    }
    return true;
}
// fin contact+

