$(document).ready(function() {
	var url = document.location.href;
	if (url.lastIndexOf('#') > 0 && url.substring(url.lastIndexOf('#')+2) != "") {
			var idprod = url.substring(url.lastIndexOf('#')+2,url.lastIndexOf('-'));
			var idart = url.substring(url.lastIndexOf('-')+1);
			ss_goEditor(idprod,idart);
	}
});

var cur_ssid;
var ss_descs = Array();
var mouseX;
var mouseY;
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
if (ns4) {document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove=mousemove;

var decal = Array();
decal['X'] = 20;
decal['Y'] = -20;

function mousemove(e) {
	mouseX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	mouseY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
}

function showlayer(id,op){
	div = $('div#ss_hover');
	if (op && div.css('visibility') != 'visible') {
		if (cur_ssid != id) {
			cur_ssid = id;
			if (ss_descs[id] == null) {
				$.get('/ajax/store/info.php?id='+id,function(html) {
					if (html == '') html = '<i>'+lang.store.nodesc+'</i>';
					ss_descs[id] = html;
					div.html(html);
				});
			} else {
				div.html(ss_descs[id]);
			}
		}
		div.css('visibility','visible');
	} else {
		div.css('visibility','hidden');
	}
}

function movelayer(id){
	div = $('div#ss_hover');
	posy = mouseY + positionne(div, 'Y');
	posx = mouseX + positionne(div, 'X');
	div.css('top',posy);
	div.css('left',posx);
}

function positionne(obj, p){
	if (p == 'X'){
		return decal[p];
	} else {
		rt = decal['Y'];
		var bottom = mouseY + decal['Y'] + 320;
		return rt;
	}
}

function ss_goEditor(idprod,idart) {

	$('a#ss_anchor').attr('name','e'+idprod+'-'+idart);
	location.href = '#e'+idprod+'-'+idart;

	if ($('.post #editor').css('display') == 'none') {

		$('.post #editor input[name=url]').attr('value',location.href);
		$('.post #editor').slideDown(function() {
			$.get('/ajax/store/clic.php?id='+idprod);
			$('.post #editor #ss_iframe_container').html('<iframe height="665" width="655" src="'+conf.url_ss+'/Shop/Index/Index/article/'+idart+'/product/'+idprod+'" id="ss_iframe" frameborder="0"></iframe>');
		});

	} else {

		$('.post #editor #ss_iframe_container').html('');

		$('.post #editor').slideUp(function() {

			$('.post #editor input[name=url]').attr('value',location.href);
			$('.post #editor').slideDown(function() {
				$.get('/ajax/store/clic.php?id='+idprod);
				$('.post #editor #ss_iframe_container').html('<iframe height="665" width="655" src="'+conf.url_ss+'/Shop/Index/Index/article/'+idart+'/product/'+idprod+'" id="ss_iframe" frameborder="0"></iframe>');
			});

		});

	}

	pageTracker._trackEvent("Store", "Click on an article", idprod+'-'+idart);

}

function ss_closeEditor() {

	location.href = '#';
	$('.post #editor #ss_iframe_container').html('');
	$('.post #editor').slideUp();

}