function sm_open(u){var l = (document.all ? screen.width : screen.width) * 0.9;var h = (document.all ? screen.height : screen.height-100) * 0.9;var conf = 'scrollbars=yes,toolbar=yes,location=yes,directories=yes,menubar=yes,resizable=yes,status=yes,width=' + l + ',height=' + h + ',screenX=0,screenY=0,top=0,left=0';open(u,'',conf);}
function sm_u() {var u='http://';for(i=0;i<arguments.length;i++){u=u+arguments[i];}u = u.replace(/_#s#_/g,'/');u = u.replace(/_#p#_/g,'.php');u = u.replace(/_#h#_/g,'.htm');sm_open(u);}
function r(u){location.href = u;}
function check_mail(mail) {
	var mail_ok = false;
	if (mail.length > 0){
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(mail)) mail_ok = true;
	}
	return mail_ok;
}
function valid() {
	var f = document.f_signup;
	mail_ok = check_mail(f.mail.value);
	if (f.name.value.length <= 2) { alert("Nom obligatoire !"); f.name.focus(); $('.table.signup .name').addClass('error');}
	else if (!mail_ok) { alert("Mail obligatoire !"); f.mail.focus(); $('.table.signup .mail').addClass('error');}
	else if (f.url.value.length < 10) { alert("Url obligatoire !"); f.url.focus(); $('.table.signup .url').addClass('error');}
	else if (f.city.value.length <= 0) { alert("Ville obligatoire !"); f.city.focus(); $('.table.signup .city').addClass('error');}
	else if (f.postcode.value.length < 5) { alert("Code postal obligatoire !"); f.postcode.focus(); $('.table.signup .postcode').addClass('error');}
	else if (f.longitude.value == "DD°MM'SS''") { alert("Longitude obligatoire !"); f.longitude.focus(); $('.table.signup .longitude').addClass('error');}
	else if (f.latitude.value == "DD°MM'SS''") { alert("Latitude obligatoire !"); f.latitude.focus(); $('.table.signup .latitude').addClass('error');}
	else if (f.altitude.value.length < 2) { alert("Altitude obligatoire !"); f.altitude.focus(); $('.table.signup .altitude').addClass('error');}
	else if (f.brand.value.length < 2) { alert("Marque obligatoire !"); f.brand.focus(); $('.table.signup .brand').addClass('error');}
	else if (f.ref.value.length < 2) { alert("Référence obligatoire !"); f.ref.focus(); $('.table.signup .ref').addClass('error');}
	else if (f.situation.value.length < 100) { alert("100 caractères minimum pour la situation !"); f.situation.focus(); $('.table.signup .situation').addClass('error');}
	else if (f.advices.value.length < 50) { alert("50 caractères minimum pour les conseils !"); f.advices.focus(); $('.table.signup .advices').addClass('error');}
	else if (f.soft.value.length < 1) { alert("Logiciel obligatoire !"); f.soft.focus(); $('.table.signup .soft').addClass('error');}
	else {f.submit();}
}
function eb(kw) {sm_open('http://rover.ebay.com/rover/1/709-53476-19255-0/1?type=3&campid=5336200897&toolid=10001&customid=&ext='+kw+'&satitle='+kw);}
function ssales(ProductCode) {sm_open('http://www.scientificsales.com/ProductDetails.asp?ProductCode='+ProductCode+'&Click=4899');}
function sm_flot(placeholder,cancelzoom,histo) {
	function formatDate(x) {
		var d = new Date(Math.round(x));
		var s = d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ' ' + d.getHours() + ':' + d.getMinutes();
		return s;
	}
	function showTooltip(x, y, contents) {
		$('<div id="tooltip">' + contents + '</div>').css( {
			position: 'absolute',
			display: 'none',
			top: y - 50,
			left: x + 5,
			border: '1px solid #bdd77f',
			padding: '2px',
			'background-color': '#ecfdcd',
			opacity: 0.80,
			'text-align' : 'center',
			'font-weight' : 'bold'
		}).appendTo("body").fadeIn(200);
	}
	var min = null;
	var max = null;
	if (histo[1][0].type == 'daily_rain') {
		var min = 0;
		var max = 50;
	}
	var options = {
		xaxis: {mode: "time", monthNames: ["Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Août", "Sep", "Oct", "Nov", "Déc"]},
		yaxis: { tickFormatter: function (v, axis) { return v.toFixed(axis.tickDecimals) + histo[1][0].unit }, min: min, max: max},
		lines: {show:true},
		points: {show:false},
		grid: { hoverable: true},
		selection: {mode:"x"}
	};

	var data = histo[0];
	var plot = $.plot(placeholder, data, options);

	var previousPoint = null;
	placeholder.bind("plothover", function (event, pos, item) {

		if (item) {
			if (previousPoint != item.datapoint) {
				previousPoint = item.datapoint;

				$("#tooltip").remove();
				var x = item.datapoint[0].toFixed(0),
				y = item.datapoint[1].toFixed(1);

				showTooltip(item.pageX, item.pageY,
				formatDate(x) + "<br>" + y + histo[1][0].unit);
			}
		}
		else {
			$("#tooltip").remove();
			previousPoint = null;
		}
	});

	placeholder.bind("plotselected", function(event, ranges) {
		//alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
		// similar for yaxis, secondary axes are in x2axis
		// and y2axis if present
		$.plot(placeholder, data,
		$.extend(true, {}, options, {
			xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
			yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
		}));
	});

	cancelzoom.click(function() {
		var min_range = data[0].data[0][0];
		var length = data[0].data.length - 1;
		var max_range = data[0].data[length][0];

		plot.setSelection({x1:min_range,x2:max_range});
		return false;
	});
}
function sm_medium(format) {
	switch (format) {
		case '200x200':
			/*document.write('<div class="medium200x200">');
			document.write('<a target="_blank" href="http://www.station-meteo.com/laboutiquedoptique.php?src=200x200"><img src="http://www.laboutiquedoptique.com/media/station-meteo.gif" alt="La Boutique d\'Optique.com" border="0" /></a>');
			document.write('<div style="padding:5px 0 0 0;color:#cc0000;"><b>5€ de réduction avec le code STATION-METEO (du 01/12/2010 au 31/12/2010 à partir de 50€)</b></div>');
			document.write('</div>');*/

            //document.write('<a onclick="_gaq.push([\'_trackEvent\', \'LoisirsPlaisirs\', \'Click\', \'RightCol\']);return true;" target="_blank" href="http://www.loisirsplaisirs.fr/promo-davis-instruments/index.html"><img width="250" src="/wp-content/uploads/divers/loisirs-plaisirs-vp2-noel-250x200.gif" alt="Loisirs Plaisirs" border="0" /></a>');
			document.write('<div>');
			var n = Math.random()*10;
			if (n < 5) {
				document.write('<a onclick="_gaq.push([\'_trackEvent\', \'LoisirsPlaisirs\', \'Click\', \'RightCol\']);return true;" target="_blank" href="http://www.loisirsplaisirs.fr/station-meteo-vantage-pro-2/index.html"><img width="250" src="/wp-content/uploads/divers/loisirs-plaisirs-vp2-250x200.gif" alt="Loisirs Plaisirs" border="0" /></a>');
			} else {
				document.write('<a onclick="_gaq.push([\'_trackEvent\', \'LoisirsPlaisirs\', \'Click\', \'RightCol\']);return true;" target="_blank" href="http://www.loisirsplaisirs.fr/station-meteo-pro-oregon-scientific-crosse/index.html"><img width="250" src="/wp-content/uploads/divers/loisirs-plaisirs-300x250.gif" alt="Loisirs Plaisirs" border="0" /></a>');
			}
			document.write('</div>');
			break;
		case '720x90':
			document.write('<div class="medium720x90">');
			//document.write('<a target="_blank" href="http://www.station-meteo.com/laboutiquedoptique.php?src=720x90"><img src="http://www.laboutiquedoptique.com/media/station-meteo-horizontal.gif" alt="La Boutique d\'Optique.com" border="0" /></a>');
			document.write('<center><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" id="Player_eafc2a0c-a35d-4fb7-a1fa-fd33ee0eac62"  WIDTH="600px" HEIGHT="200px"> <PARAM NAME="movie" VALUE="http://ws.amazon.fr/widgets/q?ServiceVersion=20070822&MarketPlace=FR&ID=V20070822%2FFR%2Fstatmete-21%2F8010%2Feafc2a0c-a35d-4fb7-a1fa-fd33ee0eac62&Operation=GetDisplayTemplate"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#FFFFFF"><PARAM NAME="allowscriptaccess" VALUE="always"><embed src="http://ws.amazon.fr/widgets/q?ServiceVersion=20070822&MarketPlace=FR&ID=V20070822%2FFR%2Fstatmete-21%2F8010%2Feafc2a0c-a35d-4fb7-a1fa-fd33ee0eac62&Operation=GetDisplayTemplate" id="Player_eafc2a0c-a35d-4fb7-a1fa-fd33ee0eac62" quality="high" bgcolor="#ffffff" name="Player_eafc2a0c-a35d-4fb7-a1fa-fd33ee0eac62" allowscriptaccess="always"  type="application/x-shockwave-flash" align="middle" height="200px" width="600px"></embed></OBJECT></center>');
			document.write('</div>');
			break;
		default:
			var x = Math.random();
			document.write('<div class="medium200x200"><center>');
			if (x < 0.5) {
				document.write('<iframe src="http://rcm-fr.amazon.fr/e/cm?lt1=_blank&bc1=ECFDCE&IS2=1&bg1=ECFDCE&fc1=000000&lc1=0000FF&t=statmete-21&o=8&p=8&l=as1&m=amazon&f=ifr&asins=B000G8OX0O" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>');
			} else {	
				document.write('<iframe src="http://rcm-fr.amazon.fr/e/cm?lt1=_blank&bc1=ECFDCE&IS2=1&bg1=ECFDCE&fc1=000000&lc1=0000FF&t=statmete-21&o=8&p=8&l=as1&m=amazon&f=ifr&asins=B001BKZUO4" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>');
			}	
			document.write('</center></div>');
			break;
	}
}
function sm_feedburner_form() {
	document.write('<div style="margin-top:10px;width:700px;padding:5px;background:#f1fedb;border:1px solid #bdd77f">');
	document.write('<b>Abonnez-vous gratuitement à www.station-meteo.com</b>. Vous pouvez recevoir chaque nouvel article par email. Comme lors de l\'inscription à une newsletter, il suffit simplement de renseigner le champ suivant et de répondre au message de vérification qui apparaîtra ensuite :.');
	document.write('<form style="padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open(\'http://feedburner.google.com/fb/a/mailverify?uri=Station-Meteo\', \'popupwindow\', \'scrollbars=yes,width=550,height=520\');return true">');
	document.write('Entrez votre adresse email:');
	document.write('<input type="text" style="width:140px" name="email"/>');
	document.write('<input type="hidden" value="Station-Meteo" name="uri"/>');
	document.write('<input type="hidden" name="loc" value="fr_FR"/>');
	document.write('<input type="submit" value="Souscrire" />');
	document.write('<div><img src="http://feeds.feedburner.com/~fc/Station-Meteo?bg=99CCFF&amp;fg=444444&amp;anim=0" height="26" width="88" style="border:0" alt="" /></div>');
	document.write('</form>');
	document.write('</div>');
}
function sm_addthis() {
	document.write('<!-- AddThis Button BEGIN -->');
document.write('<div class="addthis_toolbox addthis_default_style">');
document.write('<a href="http://www.addthis.com/bookmark.php?v=250&amp;pub=stationmeteo" class="addthis_button_compact">Share</a>');
document.write('<span class="addthis_separator">|</span>');
document.write('<a class="addthis_button_facebook"></a>');
document.write('<a class="addthis_button_myspace"></a>');
document.write('<a class="addthis_button_google"></a>');
document.write('<a class="addthis_button_twitter"></a>');
document.write('</div>');
document.write('<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=stationmeteo"></script>');
document.write('<!-- AddThis Button END -->');

}

function searchbox(f) {
	var type;
	switch (f.where.value) {
		case "1":type="all";break;
		case "2":type="blog";break;
		case "3":type="forum";break;
		case "4":type="shopping";break;
	}
	_gaq.push(['_trackEvent', 'Search', type, escape(f.q.value)]);
	if (f.where.value == 4) {
		var u = '/shopping/?q=' + f.q.value;
		if (f.cat != null) {
			u += '&cat=' + f.cat.options[f.cat.selectedIndex].value;
		}	
	} else {
		var u = '/search/?cx='+f.cx.value+'&cof='+f.cof.value+'&ie='+f.ie.value;
		switch (f.where.value) {
			case "1":u += '&q=' + f.q.value;break;
			case "2":u += '&q=' + f.q.value +' -inurl:forum';break;
			case "3":u += '&q=' + f.q.value +' inurl:forum';break;
		}
	}	
	document.location.href = u;
}
$(document).ready(function() {

	$("#nd_themes").click( function () { r('http://www.ndesign-studio.com/resources/wp-themes/'); return false; });
	$("#nd_icons").click( function () { r('http://www.ndesign-studio.com/stock-icons/'); return false; });
	$("#nd_home").click( function () { r('http://www.ndesign-studio.com/'); return false; });
	$("#rss2_url").click( function () { r('http://feeds2.feedburner.com/Station-Meteo'); return false; });
	$("#comments_rss2_url").click( function () { r('/comments/feed/'); return false; });
	$("#rss").click( function () { r('/recevez-les-derniers-articles-publies/'); return false; });
	$("#rss2, .rss2").click( function () { r('/recevez-les-derniers-articles-publies/'); return false; });
	$("#yahoo").click( function () { r('http://e.my.europe.yahoo.com/config/cstore?.opt=content&.lg=fr&.url=http://feeds2.feedburner.com/Station-Meteo'); return false; });
	$("#gg").click( function () { r('http://fusion.google.com/add?feedurl=http%3A//feeds2.feedburner.com/Station-Meteo'); return false; });
	$("#netvibes").click( function () { r('http://www.netvibes.com/subscribe.php?url=http://feeds2.feedburner.com/Station-Meteo'); return false; });
	$("#live").click( function () { r('http://www.live.com/?add=http://feeds2.feedburner.com/Station-Meteo'); return false; });
	$("#sm_xiti").click( function () { r('http://www.xiti.com/xiti.asp?s=375168'); return false; });
	$("#sm_sites-de-meteo").click( function () { r('/sites-de-meteo/'); return false; });
	$("#sm_contact, .sm_contact").click( function () { r('/contact/'); return false; });
	$("#sm_ajouter-votre-station, .sm_ajouter-votre-station").click( function () { r('/ajouter-votre-station/'); return false; });
	$("#sm_home").click( function () { r('/'); return false; });
	$("#sm_helpus").click( function () { r('/helpus/'); return false; });
	$("#sm_cgu").click( function () { r('/cgu/'); return false; });
	$("#mycarousel li img").click( function () { r($(this).parent().find("a").attr('href')); return false; });
	
	$(".sm_register").click( function () { r('/ajouter-votre-station//'); return false; });

	$(".ville2").hover(
	function () {
		$(this).find(".name").show();
	},
	function () {
		$(this).find(".name").hide();
	}
	);
	$(".name").hover(
	function () {
		$(this).show();
	},
	function () {
		$(this).hide();
	}
	);

	$(".sm_next").click(function() {
		r($(this).parent().parent().find("a").attr('href'));
		return false;
	});
	
	jQuery('#cse-search-results iframe').width(710);
	jQuery('.cse-branding-bottom input.q').val('');
	
});


