/*!
 * Telemaque JavaScript Library v0.3
 * http://www.telemaque.fr
 *
 * Copyright (c) 2009 Telemaque
 * Author : Florent Manas
 * Dual licensed under the MIT and GPL licenses.
 * http://www.telemaque.fr/cgv
 *
 * Date: 2009-10-20 10:22:05 -0500 (Wed, 20 Oct 2009)
 * Revision: 355
 */
var hfr_ad_cookie = 'horoscope_fr_home_ad_new';
var flash_version = {major: 0, minor: 0, release: 0};
var IE6 = false;
var IE7 = false;
var IE8 = false;
var OPERA = false;
var debugging = true;
var CDNPATH = 'http://cdn1.horoscope.fr/';

$(document).ready(function() {
	IE6 = $.browser.msie && $.browser.version.indexOf('6.') != -1;
	IE7 = $.browser.msie && $.browser.version.indexOf('7.') != -1;
	IE8 = $.browser.msie && $.browser.version.indexOf('8.') != -1;
	OPERA = $.browser.opera;

	if (typeof $.fn.pngfix == 'function' && IE6) {
		$('.imgtofix, .bgtofix').pngfix();
		//$('.normal .fun_box td').pngfix({imageFixSrc: CDNPATH+'blank.gif', sizingMethod: 'scale'});	
	}

	var _search = window.location.search.replace('?','');//.split('&');
	var _auth = _search.match('auth=1');
	if(_auth && _auth.length>0){
		displayOnePop('/common/lab/log_subscriber/_end_optin_pop');
	} 
	
	if (typeof(swfobject) != 'undefined') flash_version = swfobject.getFlashPlayerVersion();
	
	if (typeof onDocumentLoaded == 'function')    onDocumentLoaded();
	if (typeof handleShortLogin == 'function')    handleShortLogin();
	if (typeof handleHeader == 'function')        handleHeader();
	if (typeof handleComments == 'function')      handleComments();
	if (typeof handleSmartPhone == 'function')    handleSmartPhone();
	if (typeof $.fn.replaceAnchors == 'function') $('a[href*="#"]').replaceAnchors();
	if (typeof $.fn.applyRating == 'function')    $('form[class*="rating_form"]').applyRating({});
	if (typeof $.fn.handleMenu == 'function')     $('#navigation a').handleMenu();
	if (typeof $.fn.handleSelect == 'function')   $('.teleSelect').handleSelect();
	if (typeof $.fn.handleFooter == 'function')   $('#footer .main .categories').handleFooter();
	
	//if (typeof $.fn.rotateSigns == 'function')		$('.buttons .sign').rotateSigns();

	
	// IE7 fix buttons
	$('.button').click(function() {
		if ($(this).parent().attr('tagName') == 'A')			
 			document.location.href = $(this).parent().attr('href');
	});
	
	// Google Analytics
	$('.GA_tracker').each(function(i,v){
		$(this).click(function(){
			recordOutboundLink(this, $(this).attr('data-cat') || 'Outbound Links',$(this).attr('data-ga'));
			return false;
		})
	});
	$('.GA_tracker_pub').each(function(i,v){
		$(this).click(function(){
			recordClick(this);
			return false;
		})
	});
	$('.GA_tracker_menu').each(function(i,v){
		$(this).click(function(){
			recordClick(this);
			return false;
		})
	});
	
	$('.menu_pub_visio').attr('href',$('.menu_pub_visio').attr('href')+'?utm_source=horoscope.fr&utm_medium=pub&utm_campaign=chat_voyance');
	
	var now = new Date();
	if($.cookie('summer') == null){ 
		date = now.getDate()+'/'+parseInt(now.getMonth()+1)+'/'+now.getFullYear();
		if(date == '4/10/2011' || date == '5/10/2011'){
			$.cookie('summer', true, { path: '/', expires: 1});
			setTimeout(displaySummer, 100);
		}
	}
	if($.cookie('popchat2') == null){ 
		date = now.getDate()+'/'+parseInt(now.getMonth()+1)+'/'+now.getFullYear();
		if(date == '10/6/2011' || date == '11/6/2011'){
			$.cookie('popchat2', true, { path: '/', expires: 1});
			setTimeout(displayPopChat, 100);
		}
	}

	if($.cookie('allopub') == null){ 
		date = now.getDate()+'/'+parseInt(now.getMonth()+1)+'/'+now.getFullYear();
		if(date == '26/10/2011'){
			$.cookie('allopub', true, { path: '/', expires: 1});
			setTimeout(displayAlloPub, 100);
		}
	}

	// AB Testing
	$('a').each(function() {
		if (typeof(ab_testing_links) == 'object' && ($.inArray($(this).attr('href'), ab_testing_links) > -1 || $(this).hasClass('ab_testing_tracking_link')))
			$(this).click(track_AB_testing);
	});
	
	var thash = document.location.hash.split('_');
	if(thash[0]=='#comments') displayOnePop('/common/lab/comment_pop/_give_comment_pop?pid='+thash[1]);
	
});

var handleSmartPhone = function() {
	/*document.location.pathname != '/' || */
	if (document.location.search.indexOf('cf=smartphone') != -1)
		return true;
		
	var deviceAgent = navigator.userAgent.toLowerCase();
	if($.browser.msie) var language = 'fr-fr';
	else var language = navigator.language.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad|android|firefox)/);
		
	if (agentID) {
		var smartp_names = ['android', 'iphone_fr', 'iphone'];
		var smartp_links = ['market://details?id=fr.telemaque.horoscope', 'http://clk.tradedoubler.com/click?p=23753&a=1950832&g=0&td_partnerId=2003&url=http://itunes.apple.com/fr/app/horoscope/id329504506?mt=8', 'http://itunes.apple.com/fr/app/horoscope/id329504506?mt=8'];
		
		var smartp_name = null;
		var _name = null;
		if (deviceAgent.match(/iphone/)) { var _name = 'iphone'; var smartp_name = 'iPhone '; }
		if (deviceAgent.match(/iphone/) && language.match(/fr/)) { var _name = 'iphone_fr'; var smartp_name = 'iPhone'; }
		if (deviceAgent.match(/ipod/)) { var _name = 'iphone'; var smartp_name = 'iPod'; }
		if (deviceAgent.match(/ipad/)) { var _name = 'iphone'; var smartp_name = 'iPad'; }
		if (deviceAgent.match(/android/)) { var _name = 'android'; var smartp_name = 'Smartphone'; } //var smartp_name = 'smp';
		//if (deviceAgent.match(/windows ce/)) { var smartp_name = 'Window Mobile'; }

		if (_name == null || smartp_name == null)
			return false;
		//var _name = 'iphone_fr'; var smartp_name = 'iPhone';
		//var message = 'Consult all your free astro predictions on your ' + smartp_name + ' !';
		var message = 'Téléchargez gratuitement l\'application Horoscope.fr sur votre ' + smartp_name + ' !';
		var expire = smartp_name == 'iPad' ? 30 : 15;
		
		if ($.cookie('hfr_smartp_link_cookie') == null) {
			recordOutboundLink(false, 'alert_mobile_'+_name, 'display_'+_name); 
			/*if(confirm(message)){
				recordOutboundLink({'href':(smartp_links[$.inArray(_name, smartp_names)])}, 'alert_mobile_'+_name, 'gotostore_'+_name); 
			}*/
			/*jqmobile = {};
			jqmobile.s = document.createElement('script');
			jqmobile.s.src = '/js/ui/mobile/jquery.mobile-1.0a4.1.min.js';
			document.getElementsByTagName('head')[0].appendChild(jqmobile.s);*/
			
			cssmobile = {};
			cssmobile.s = document.createElement('link');
			cssmobile.s.rel = 'stylesheet';
			cssmobile.s.type = 'text/css';
			cssmobile.s.href = '/css/ui/mobile/jquery.mobile-1.0a4.1.min.css';
			document.getElementsByTagName('head')[0].appendChild(cssmobile.s);
			
			//if (_name = 'iphone')
			//	$('head').append('<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">');

			var smartpRecordOutboundLink = function() { recordOutboundLink({'href':(smartp_links[$.inArray(_name, smartp_names)])}, 'alert_mobile_'+_name, 'gotostore_'+_name);  };

			var smartpExpire = function(e) { $.cookie('hfr_smartp_link_cookie', true, {'path': '/', 'expires': expire}); displayConfirmationCloseFunction(); };
			var smartpLater = function(e) { $.cookie('hfr_smartp_link_cookie', true, {'path': '/', 'expires': 7}); displayConfirmationCloseFunction(); };
			var smartpDL = function(e) { smartpExpire(); smartpRecordOutboundLink(); };
			
			var smartpOpen = function(e) { $('#smartp_dl').click(smartpDL); $('#smartp_later').click(smartpLater); $('#smartp_own').click(displayConfirmationCloseFunction); $('#tele_box_confirmation').addClass('iphone'); };

			var choices = $('<span />');
			var choice1 = $('<button id="smartp_dl" class="iphone button action primary ui-telelab-corner-all ui-shadow ui-btn-up-c">Télécharger</button>');
			var choice2 = $('<button id="smartp_later" class="iphone button action primary ui-telelab-corner-all ui-shadow ui-btn-up-c">Plus tard</button>');
			var choice3 = $('<button id="smartp_own" class="iphone button action primary ui-telelab-corner-all ui-shadow ui-btn-up-c">Je l\'ai déjà</button>');
			
			//<a href="index.html" data-role="button">Link button</a> 
			
			choices.append(choice1, choice2, choice3, '<hr />');
			
			displayConfirmation({'data': {'tele_box': {'box_css': {'width': 820, 'padding': '10px', 'border-radius': '8px'}, 'onOpen': smartpOpen, 'onAfterClose': function() { $('#tele_box_confirmation').removeClass('iphone'); }}, 'icon': null, 'message': message, 'additional': choices.html(), 'button': {'primary': 'Non merci'}, 'classes': {'primary': 'iphone ui-shadow ui-btn-up-c'}, 'confirmFunction': smartpExpire}});
			
			
		}
		// recordOutboundLink(false, 'alert_mobile_'+_name, 'display_'+_name); 
		// if ($.cookie('hfr_smartp_link_cookie') == null && confirm(message)) {
			// $.cookie('hfr_smartp_link_cookie', true, {path: '/', expires: 15});
			// recordOutboundLink({'href':(smartp_links[$.inArray(_name, smartp_names)])}, 'alert_mobile_'+_name, 'gotostore_'+_name); 
			// // document.location.href = (smartp_links[$.inArray(_name, smartp_names)]);
		// } else if (smartp_name == 'iPad') {
			// // set cookie by 30 day
			// $.cookie('hfr_smartp_link_cookie', true, {path: '/15', expires: 30});		
		// } else {
			// $.cookie('hfr_smartp_link_cookie', true, {path: '/', expires: });
		// }
		
		return true;
	}
};

function get_margins(el){
	var res = 0;
	var mt = el.css('margin-top');
	var mb = el.css('margin-bottom');
	if(mt == "auto") mt = 0;
	if(mb == "auto") mb = 0;
	res += parseInt(mt) + parseInt(mb);
	return res;
}

function loadFlash(so, element) {
  if (flash_version['major'] < 8) {
    //$(element).html('<center>Votre navigateur ne poss�de pas le lecteur Flash ou sa derni�re version, pour l\'installer, rendez-vous � la page de t�l�chargement en cliquant <a href=\"http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&Lang=French\" title=\"T�l�charger Flash\">ici</a></center>');
		return false;
  } else {
    so.write(element);
		return true;
  } 
}
 
function handleHeader() {
	
	
	$('#tools_recherche_input').autocomplete('/lab/ajax/_search_all', {
		width: 250,
		align: 'right',
		max: 0,
		highlight: false,
		delay: 500,
		scroll: true,
		scrollHeight: 150,
		cacheLength: false,	
		matchContains: false,
		inputClass: 'header_ac_input',
		resultsClass: 'header_ac_results',
		loadingClass: 'header_ac_loading',
		hoverClass: 'header_ac_hover',
		arrowClass: 'header_ac_arrow',
		oddClass: 'header_ac_odd',
		evenClass: 'header_ac_even',
		/*dataType: 'json',*/ 
		formatItem: function(row, i, max, term) {
			/* return '<img width="25" src="' + row[1] + '"/><span>' + row[0] + '</span>';  */ // desactive icono produit
			return '<span>' + row[0] + '</span>'; 
		},
		formatResult: function(row, i) {
			return row[0];
		}
	}).result(function(event, row, formatted) {
		document.location.href = row[2];
	});
	
	$('#blog_submit').click(function() {
		//alert($('#tools_recherche_input').val());			
		$('#tools_recherche_input').search();
	});
}


// TOOLS
// custom easing called "custom" 
$.fn.handleFooter = function() {
	//if (footer_in_cache == undefined || footer_in_cache == false) {
		$(this).masonry();
		/*$.ajax({
				type: 'post',
				url: '/lab/ajax/_cache_footer',
				data: {'footer': $('<div />').append($('#footer .categories').clone()).html(), 'url': document.location.href }
		});*/
	//}
}

//function to get random number upto m
/*$.random = function(minVal, maxVal, floatVal) {
	floatVal = 0 || floatVal;
  var randVal = minVal + (Math.random() * (maxVal - minVal));
  return typeof floatVal == 'undefined' ? Math.round(randVal) : randVal.toFixed(floatVal);
}*/

$.fn.replaceAnchors = function() {
  this.each(function(){
		var anchor = $(this);
    if (anchor.hasClass('scroll_to')) {
      anchor.click(function() {				
        var div = anchor.attr('href');
				var y   = parseInt($(div).offset().top + $(div).scrollTop());
				
				options = {axis: 'y', onAfter: function() { document.location.href = div; }};
				if (anchor.has('offset')) {
					$.extend(options, {offset: parseInt(anchor.attr('offset'))});
				}

				//anchor.removeAttr('href');
        $(window).scrollTo({top: y, left: 0}, 500, options);
      });
    }
  });
}

// TIRAGES
$.fn.handleDrawing = function(type) {
	var type = type || 'marseille';
		
	this.live('click', function() {
		var rand = $.random(1, 22);

		if (this.value == 0) {
			if (drawings.length != $.grep(drawings, function(i) { return i != rand; }).length)
				rand = $.random(1, 22);
				
			this.value = rand;
			drawings.push(rand);
			$(this).attr('src', CDNPATH+'blank.gif').addClass('loading').attr('src', CDNPATH+'icons/' + type + '/' + this.value + '.jpg').bind('load', function(event) { $(event.target); }).removeClass('loading');
		}
		return false;
	});
}

$.fn.applyRating = function(options) {
	options = $.extend({}, options);

	this.each(function() {
		var form = $(this);

		$(this).show();
		rating = $(this).children('input[name="rating"]').val();
		//$('#rating_form_64_534845').children('input[name="rate"]').rating().rating('select', '4').rating('readOnly', true);
		if ($(this).attr('readonly') != undefined)
			$(this).children('input[name="rate"]').rating(options).rating('select', rating).rating('readOnly', true);
		else
			$(this).children('input[name="rate"]').rating('select', rating).rating(options);
	});
	
	return this;
}

$.fn.rotateSigns = function() {
	if (!$.browser.msie) {
		$(this).each(function() {
			var current = $(this);
			current.data('rotateSign', {'max': randomXToY(4, 8), 'now': 0, 'direction': 1});
			intervalRotateSigns = setInterval(function() { current.rotateSign(); }, randomXToY(20, 50));
		});
		
	}
}

function randomXToY(minVal, maxVal, floatVal) {
	var randVal = minVal + (Math.random() * (maxVal - minVal));
	return typeof floatVal == 'undefined' ? Math.round(randVal) : randVal.toFixed(floatVal);
}

function recordEventGoogle(category, action) {
	try {
		var pageTracker=_gat._getTracker("UA-1910060-1");
		pageTracker._trackEvent(category, action);
	}catch(err){}
}


function recordOutboundLink(link, category, action) {
	if(typeof(action)=='undefined') action = 'no_action';
	try {
		var pageTracker=_gat._getTracker("UA-1910060-1");
		pageTracker._trackEvent(category, action);
		if(link!=false){
			if(link.target=="_blank"){
				// setTimeout('window.open("' + link.href + '")', 100);			
				window.open(link.href);
			} else {
				setTimeout('document.location = "' + link.href + '"', 100);
			}
		}
	}catch(err){/*alert(err);*/}
}

function recordClick(link) {
	try {
		var pageTracker=_gat._getTracker("UA-1910060-1");
		if($(link).attr('data-ga')!="") pageTracker._trackPageview($(link).attr('data-ga'));
		else pageTracker._trackPageview(link.title);
		if(link.target=="_blank"){
			// setTimeout('window.open("' + link.href + '")', 100);			
			window.open(link.href);			
		} else {
			setTimeout('document.location = "' + link.href + '"', 100);
		}
	}catch(err){/*alert(err);*/}
}

// A/B testing
var track_AB_testing = function(e) {
	e.preventDefault();

	elt = $(this);

	var test_id = ab_testing && (0 in ab_testing) ? ab_testing[0] : 1;

	try {
		$.ajax({
			'method': 'POST',
			'url': '/common/lab/ab/track?id=' + test_id + '&url=' + escape(elt.attr('href')),
			'success': function(data) {
				if (elt) {
					if (elt.attr('target') == '_blank') {
						window.open(elt.attr('href'));
					} else {
						//setTimeout('document.location = "' + elt.attr('href') + '"', 200);
						document.location = elt.attr('href');
					}
				}
				
				elt.unbind('click');
			}
		});
	} catch(err) {
		
	}
};

var handleTooltip = function(obj) {
	obj.find('ul li').first().addClass('ui-telelab-corner-top').end().last().addClass('ui-telelab-corner-bottom');
}

var last_angle = 0;
var container_roue, paper_roue;

var selectMySign = function(i, animate) {
	if ($('#label_sign .center').html() == '') {
		$('#label_sign').children('.first').animate({'padding-top': 60});
	}
	
	$('#label_sign').children('.center').html(zodiac_signs[(i - 1)]);
	$('map area[alt=center_wheel]').attr({'href':'/horoscopes/horoscope_'+str_replace('é','e',zodiac_signs[(i - 1)].toLowerCase())+'.html','title':'Horoscope '+zodiac_signs[(i - 1)]});
	i -= 2;

	// Angles de 0 à 330 : steps = 30
	var angle = (((i + 12) % 12) * 30);
	rotation = 0;
	//debug('angle : ' + angle);
	
	if (animate) {
		// Différence entre l'angle pointé et l'ancien angle
		if (last_angle >= 0) {
			var diff = angle - last_angle;
			//debug('> 0 : diff : ' + diff + ' = ' + angle + ' - ' + last_angle);
		} else {
			//	Math.abs(Math.floor(last_angle / 360)) + 1; 
			var diff = last_angle - (last_angle - angle);
			//debug('< 0 : diff : ' + diff + ' = ' + last_angle + ' - (' + last_angle + ') - ' + angle);
		}
		
		// Si la différence est plus grande que 180, on prend le chemin le plus court
		if (diff >= 180) {
			if (last_angle < 180 && angle >= 180) {
				rotation = -(360 - diff);
				//debug('> 180 : rotation : ' + rotation + ' = -(' + 360 + ' - ' + diff + ')');	
			} else {
				rotation = -(360 - diff);
				//debug('> 180 : rotation : ' + rotation + ' = -(' + 360 + ' - ' + diff + ')');	
			}
		} else {
			if (last_angle > 180 && angle <= 180) {
				//if (last_angle > 0)
				//	last_angle = 
				rotation = last_angle + diff;
				//debug('< 180 : rotation : ' + rotation + ' = ' + last_angle + ' + ' + diff);
			} else {
				rotation = angle;
				//debug('< 180 : rotation : ' + rotation + ' = ' + angle);
			}
		}
		
		container_roue.animate({'rotation': rotation}, 200);
	} else {
		container_roue.rotate(angle, true);
	}
	
	last_angle = rotation;
}

$.fn.hideIt = function() {
	if ($.browser.msie) this.addClass('invisiblie'); else this.addClass('invisible');
	return this;
}

$.fn.showIt = function() {
	if ($.browser.msie) this.removeClass('invisiblie'); else this.removeClass('invisible');
	return this;
}			

var tele_box_summer;
var displaySummer = function(reason) {	
	if (tele_box_summer == null) {
		tele_box_summer = new TeleBox({
			name: 'summer',
			isCrossImg: true,
			multi: true,
			loader_class: 'loading_white',
			content: '<a href="/horoscopes/horoscope-2012/?ctx=horoscope/jour_2"><img src="http://cdn1.horoscope.fr/1/base/horos-2012.png" width="737px" height="652px"/></a>',
			cross_css: { 'top': '210px'},
			box_class: 'round_10',
			mask_css: {'background-color': '#FFF', 'z-index': 12},
			box_css: {'width': '737px', 'height': '652px', 'position' : 'absolute', 'border': '0 none', 'background': '#FFF', 'margin-top':'40px', 'padding': '0', 'opacity': 1.0, 'font-size': '12px', 'display': 'none', 'border':'1px solid #c1bc9e'}
		});
	}
	tele_box_summer.exec();
};

var tele_box_allopub;
var displayAlloPub = function() {	
	if(!IE7){
		$('body').before('<div id="allopub_pop" style="position:absolute; top:0px; height:1050px; width:100%; background:url(/images/common/pop/allopub.jpg) no-repeat top center black; z-index:1000;"><div id="gohome" style="position:absolute; width:238px; height:26px;top:99px; left:935px; cursor:pointer;"></div><a href="http://chat.horoscope.fr" id="gochat" style="position:absolute; width:625px; height:500px; top:278px; left:520px; cursor:pointer;"></a></div>');
		$('body').append('<div id="allopub_overlay" style="position: fixed; left: 0px; top: 0px; background-color: black; z-index: 12; width: 100%; height: 100%;"></div>');
	} else {
		$('body').append('<div id="allopub_overlay" style="position: fixed; left: 0px; top: 0px; background-color: black; z-index: 12; width: 100%; height: 100%;"></div>');
		$('body').append('<div id="allopub_pop" style="position:absolute; top:0px; height:1050px; width:100%; background:url(/images/common/pop/allopub.jpg) no-repeat top center black; z-index:1000;"><div id="gohome" style="position:absolute; width:238px; height:26px;top:99px; left:935px; cursor:pointer;"></div><a href="http://chat.horoscope.fr" id="gochat" style="position:absolute; width:625px; height:500px; top:278px; left:520px; cursor:pointer;"></a></div>');
	}
	$('#allopub_pop #gohome').click(function(){
		$('#allopub_overlay, #allopub_pop').fadeOut(800,function(){
			$('#allopub_overlay, #allopub_pop').remove();
		});
	});
	window.setTimeout('closeAllopub()',10000);
};

var closeAllopub = function() {
	$('#allopub_overlay, #allopub_pop').fadeOut(500,function(){
		$('#allopub_overlay, #allopub_pop').remove();
	});
};

var tele_box_popchat;
var displayPopChat = function(reason) {	
	if (tele_box_popchat == null) {
		tele_box_popchat = new TeleBox({
			name: 'popchat',
			isCrossImg: true,
			multi: true,
			loader_class: 'loading_white',
			content: '<a href="http://chat.horoscope.fr"><img src="http://cdn1.horoscope.fr/1/base/popchat2.png" width="484px" height="563px"/></a>',
			cross_css: { 'top': '210px'},
			box_class: 'round_10',
			mask_css: {'background-color': '#FFF', 'z-index': 12},
			box_css: {'width': '484px', 'height': '563px', 'position' : 'absolute', 'border': '0 none', 'background': '#FFF', 'margin-top':'40px', 'padding': '0', 'opacity': 1.0, 'font-size': '12px', 'display': 'none', 'border':'1px solid #c1bc9e'}
		});
	}
	tele_box_popchat.exec();
};

var tele_box_pophfr;
var displayPopHfr = function(src,lien,h,w,c) {	
//alert(src+'-'+lien);
	if(typeof(h)=='undefined' || h==0) h=563;
	if(typeof(w)=='undefined' || w==0) w=484;
	if(typeof(c)=='undefined' || c==0) c=210;
	if (tele_box_pophfr == null) {
		tele_box_pophfr = new TeleBox({
			name: 'pophfr',
			isCrossImg: true,
			multi: true,
			loader_class: 'loading_white',
			//content: '<a href="'+ lien +'"><img src="http://cdn1.horoscope.fr/1/base/popup/'+src+'" width="484px" height="563px"/></a>',
			content: '<a href="'+ lien +'"><img src="http://www.horoscope.fr/images/1/base/popup/'+src+'" width="'+w+'px" height="'+h+'px"/></a>',
			cross_css: { 'top': c+'px'},
			box_class: 'round_10',
			mask_css: {'background-color': '#FFF', 'z-index': 12},
			box_css: {'width': w+'px', 'height': h+'px', 'position' : 'absolute', 'border': '0 none', 'background': '#FFF', 'margin-top':'40px', 'padding': '0', 'opacity': 1.0, 'font-size': '12px', 'display': 'none', 'border':'1px solid #c1bc9e'}
		});
	}
	tele_box_pophfr.exec();
};

var tele_box_login;
var displayLogin = function(type,link) {	
	if(type=='inscription'){
		_linkBox = (typeof link=='string')?link:'/membre/_inscription?has_layout=false';
		_width = '840px';
		_height = '710px'
	} else {
		_linkBox = (typeof link=='string')?link:'/lab/popup/_main?has_layout=false';		
		_width = '780px';
		_height = 'auto'; 
	}
	if (tele_box_login == null) {
		tele_box_login = new TeleBox({
			name: 'login',
			isCrossImg: true,
			multi: true,
			loadURL: true,
			content: _linkBox,
			cross_css: {'display':'none', 'width':'0', 'height':'0', 'padding':'0', 'margin':'0'},
			box_class: 'round_10',
			box_css: {'width':_width, 'height': _height, 'position' : 'absolute', 'border': '0 none', 'background': 'url("http://cdn1.horoscope.fr/1/popup_ident/bg.jpg") repeat-x center bottom #FFF', 'padding': '15px', 'opacity': 1.0, 'font-size': '12px', 'display': 'none', 'border':'1px solid #c1bc9e'},
			onAppend:function(tb){
				if(type=='inscription') $('#tele_box_login').append("<div id='grenouille_deco'></div><span id='popup_close'></span>");
				else $('#tele_box_login #ident_box_content').fadeIn(300);
				$('#tele_box_login #popup_close').click(function(){ tele_box_login._hide(); });
			}
		});
	}
	tele_box_login.exec(_linkBox);
};

