﻿if (!document.getElementById && document.all) { document.getElementById = new Function('id', 'return document.all[id]') }

var colsel = 'null' ;

function valid_email(field) 
{
  var str = field.value;
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }
    field.focus();
    field.select();
    return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    field.focus();
    field.select();
    return false;
  }
}

function LoadImgMap()
{
	//$ Préparation de l'URL
	//GEN_strUrlMap = "http://www.multimap.com/clients/gif.cgi?client=piaget_01&width=400&height=300&lon="+GEN_fMylon+"&lat="+GEN_fMylat+"&ds="+GEN_iDelta;
	GEN_strUrlMap = "http://www.multimap.com/clients/gif.cgi?client=piaget_01&width=500&height=400&lon="+GEN_fMylon+"&lat="+GEN_fMylat+"&ds="+GEN_iDelta;
	
	
	//$ Se déplacer dans la carte
	document.getElementById('mapimg').onload = ChangeUmgUrl;
	document.getElementById('mapimg').src="img/map_loading_en.gif";	
}

function LoadDivMap(lat, longitude, desc) 
{
    // GMapOptions opt ;
    opt = { size: new GSize(500, 400)};
    //opt.size = new GSize(500, 300) ;    
    var point = new GLatLng(lat,longitude);
    var googlemap = new GMap2(document.getElementById("googlemap"), opt) ;
    var googlemap_print = new GMap2(document.getElementById("googlemap_print"), opt) ;
    
    googlemap.setCenter(point, 16);
    googlemap.addControl(new GMapTypeControl());
    googlemap.addControl(new GSmallMapControl());
    //if (GBrowserIsCompatible()) 
    {
       
        //googlemap.panTo(point);
    //googlemap.openInfoWindowHtml(googlemap.getCenter(), desc);
    googlemap.addOverlay(new GMarker(point));
      }
      
    googlemap_print.setCenter(point, 16);
    googlemap_print.addControl(new GMapTypeControl());
    googlemap_print.addControl(new GSmallMapControl());
    googlemap_print.addOverlay(new GMarker(point));
    //if (GBrowserIsCompatible()) 
    {
       
        //googlemap_print.panTo(point);
    //googlemap_print.openInfoWindowHtml(googlemap_print.getCenter(), desc);
      }
}

function ChangeUmgUrl()
{
	document.getElementById('mapimg').onload = null;
	document.getElementById('mapimg').src = GEN_strUrlMap;
	document.getElementById('mapimgprint').src = GEN_strUrlMap;
}

function ChangeDelta(strDelta)
{
	//$ Changement du Delta
	switch(strDelta)
	{
		//$ Si - on décrémente le Delta courant
		case '-':
			GEN_iDelta--;
			break;
		//$ Si + on incrémente le Delta courant
		case '+':
			GEN_iDelta++;
			break;
		//$ Initialiser avec la valeur passée en paramètre
		default:			
			GEN_iDelta=parseInt(strDelta);
			break;
	}
	if( GEN_iDelta > 5 ) GEN_iDelta = 5;
	if( GEN_iDelta < 0 ) GEN_iDelta = 0;
	
	//$ Charger l'image
	LoadImgMap();
}

function popUpStore(idstore,idcity,idlang)
{
   urlmulti = '/index.php5?pge=POPUP_MULTIMAP&idstore='+idstore+'&idcity='+idcity+'&lang='+idlang ; 
   window.open(urlmulti, 'Piaget', 'menubar=no, status=no, scrollbars=no, menubar=no, width=766, height=427') ;
}

function makeBig()
{
 window.resizeTo(screen.availWidth,screen.availHeight);
 window.moveTo(0,0);
}

function open_limelight(lang) 
{
  //newWindow=window.open(url,'piagetfull', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=740,left = 400,top = 4000');
  var wid = screen.availWidth ;
  var hei = screen.availHeight ;
  lime=window.open('/minisites/limelight/'+lang+'/index2.html','piagetlimelight', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+wid+',height='+hei+',left=0,top=0');
  //newWindow.moveTo(0,0);
  //newWindow.resizeTo(screen.availWidth,screen.availHeight);
}

function open_protocole_email(zone, lang, langid) 
{
  //newWindow=window.open(url,'piagetfull', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=740,left = 400,top = 4000');
  var wid = screen.availWidth ;
  var hei = screen.availHeight ;
  lime=window.open('/minisites/missprotocole_email/email.php5?LANGCODE='+lang+'&ZONECODE='+zone+'&LANGID='+langid,'piagetemail', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+wid+',height='+hei+',left=0,top=0');
  //newWindow.moveTo(0,0);
  //newWindow.resizeTo(screen.availWidth,screen.availHeight);
}

function openNewWindowX(url) 
{
  //newWindow=window.open(url,'piagetfull', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=740,left = 400,top = 4000');
  var wid = screen.availWidth ;
  var hei = screen.availHeight ;
  newWindow=window.open(url,'piagetfull', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+wid+',height='+hei+',left=0,top=0');
  //newWindow.moveTo(0,0);
  //newWindow.resizeTo(screen.availWidth,screen.availHeight);
}
function openNewWindowXX(url) 
{

	var site_to_go=url;
  //newWindow=window.open(url,'piagetfull', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=740,left = 400,top = 4000');
  var wid = screen.availWidth ;
  var hei = screen.availHeight ;
  var newWindow=window.open(url,'piagetfull2', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+wid+',height='+hei+',left=0,top=0');
  //newWindow.moveTo(0,0);
  //newWindow.resizeTo(screen.availWidth,screen.availHeight);
  if(!newWindow){
		//alert("Anti pop up");
		  if (navigator.appName.indexOf("Microsoft") != -1) {
		  var navigateur="explorer";
		  }else{
		   var navigateur="firefox";
		   alert("Please Disable your Anti Pop Up to access "+site_to_go);
		  }
		 popup_problem(site_to_go,navigateur);	
	}
}

function popup_problem(site_to_go,navigateur){
//
// appelle le fonction flash qui alerte d'un probleme de pup up
//
 thisMovie("intro").popup_problem(site_to_go,navigateur);
}
function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName]
     }
     else {
          return document[movieName]
     }
}

function valid_form_newsletter(msgpwd, msgemail)
{
	if(!valid_email(document.getElementById('email')))
	{
		alert(msgemail) ;
		document.getElementById('email').focus() ;
		return false ;
	}
	else if(document.getElementById('pwd').value != document.getElementById('pwd2').value)
	{
		alert(msgpwd) ;
		document.getElementById('pwd').focus() ;
		return false ;
	}
	else document.getElementById('form').submit() ;
	
}


function show_delete_sentence()
{
	document.getElementById('unsubscribe').className = 'c_visible' ;	
}

function hide_delete_sentence()
{
	document.getElementById('unsubscribe').className = 'c_hidden' ;	
}

function valid_delete_newsletter()
{
	document.getElementById('pge').value = 'DELETE_NEWSLETTER' ;
	document.getElementById('form').submit() ;
}

function open_popup(nam, url, w, h)
{
   return window.open(url, nam, 'menubar=no, status=no, scrollbars=yes, width='+w+', height='+h) ;
}

function open_press()
{
	open_popup('backoffpress', '/0site/backoffice/index.php5', screen.availWidth , screen.availHeight) ;
	makeBig() ;
}

function open_estara(lang, zone)
{
	var estara_url ;
	var name_popup ;
	var left = screen.availWidth - 440 ;
	
	if(zone == 'NA')
	{
		if(lang == 'FR')
		{
			estara_url =  'http://as00.estara.com/ep/?ulbid=165283' ;
			name_popup = 'fr_estara' ;
		}
		else if(lang == 'EN')
		{
			estara_url = 'http://as00.estara.com/ep/?ulbid=165273' ;
			name_popup = 'en_estara' ; 
		}
		else if(lang == 'SP')
		{
			estara_url = 'http://as00.estara.com/ep/?ulbid=165276' ;
			name_popup = 'sp_estara' ; 
		}
	
	}
	else if(zone == 'EU')
	{
		if(lang == 'EN')
		{
			estara_url = 'http://as00.estara.com/ep/?ulbid=243283' ;
			name_popup = 'en_estara' ; 		
		}
		
		if(lang == 'FR')
		{
			estara_url = 'http://as00.estara.com/ep/?ulbid=243303' ;
			name_popup = 'fr_estara' ;		
		}	
	}

	var newWindow=window.open(estara_url, name_popup, 'C, scrollbars=yes, width=430,height=378,top=0,left='+left) ;
	 if(!newWindow){
		//alert("Anti pop up");
		  if (navigator.appName.indexOf("Microsoft") != -1) {
		  var navigateur="explorer";
		  }else{
		   var navigateur="firefox";
		   alert("Please Disable your Anti Pop Up to access this page.");
		  }
		 popup_problem(estara_url,navigateur);	
	}
}

function open_events(idlang)
{
	window.open('http://www.piaget.com/events/', 'events', 'scrollbars=yes, menubar=yes, status=yes, toolbar=yes, location=yes, directories=yes, width='+screen.availWidth+', height='+screen.availHeight) ;		
}

function open_terms(lang, racine)
{
	var newWindow=window.open(racine+'index.php5?pge=TERMS&lang='+lang,'popupterms2', 'menubar=no, status=no, scrollbars=yes, width=380, height=400') ;
	 if(!newWindow){
		//alert("Anti pop up");
		  if (navigator.appName.indexOf("Microsoft") != -1) {
		  var navigateur="explorer";
		  }else{
		   var navigateur="firefox";
		   alert("Please Disable your Anti Pop Up to access "+"Terms & Conditions");
		  }
		 popup_problem(racine+'index.php5?pge=TERMS&lang='+lang,navigateur);	
	}
}

function forget_password()
{
	document.getElementById('emailpiaget').value=document.getElementById('logpiaget').value ;
	document.getElementById('pass_forget').className='c_visible' ;
}

function show_prods(col_click)
{
	if(colsel != col_click)
	{
		if(colsel != 'null')document.getElementById(colsel).className='c_hidden' ;
		document.getElementById(col_click).className='c_visible' ;
		colsel = col_click ;
	}
}

function openContactForm(id_localisation){
    var width = 350;
    var height = 600;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var url = racine + "/formulaire?css=popup&typeForm=contact&inside=layoutHtml&legacy_localisation="+id_localisation+"&origine="+origine+"&ref=&url=&gaCode=UA-15249600-1&gaPage="+gaPage+"&";
    var newWindow=window.open(url,'piagetcontact', "menubar=no, status=no, scrollbars=yes, width="+width+", height="+height+",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top) ;
}
function openNewsletter(){
	var width = 350;
    var height = 350;
	var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
	var url = racine + "/formulaire?css=popup&typeForm=newsletter&inside=layoutHtml&legacy_localisation="+id_localisation+"&origine="+origine+"&ref=&url=&gaCode=UA-15249600-1&gaPage="+gaPage+"&";
	var newWindow=window.open(url,'piagetcontact', "menubar=no, status=no, scrollbars=yes, width="+width+", height="+height+",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top) ;
}
