function lnk(param,trgt)
{
	
	var contenturl="";
	if (param.substring(0,4)=="[ta]")
	{
		param=param.substring(4);
		var url="",url2="",url3="";
		endstr="";
		t_url=param.split("|");
		for (i=0; i<t_url.length; i++) { 
			if(i!=((t_url.length)-1)) { endstr="/"; } else {endstr="";}
			url=url+t_url[i]+endstr;
		}
		t_url2=url.split("[");
		for (i=0; i<t_url2.length; i++) { 
			if(i!=((t_url2.length)-1)) { endstr="_est_"; } else {endstr="";}
			url2=url2+t_url2[i]+endstr;
		}
		t_url3=url2.split("]");
		for (i=0; i<t_url3.length; i++) { 
			if(i!=((t_url3.length)-1) &&  i!=((t_url3.length)-2)) { endstr="_puis_"; } else {endstr="";}
			url3=url3+t_url3[i]+endstr;
		}
		contenturl=url3+".html";
		
	} else {
		t=param.split("-[");
		
		rg1=new RegExp("[|]","g");
		rg2=new RegExp("[[]","g");
		rg3=new RegExp("]","g");
		for (i=0; i<t.length; i++)
		{
			if (t[i].substring(0,2)=="s]") {
				contenturl+=t[i].substring(2)+"://";
			} else if(t[i].substring(0,2)=="h]") {
				t[i]=t[i].replace(rg1, "/");
				contenturl+=t[i].substring(2);		
			} else if(t[i].substring(0,2)=="q]") {
				t[i]=t[i].replace(rg2, "=");
				t[i]=t[i].replace(rg3, "&");
				t[i]=t[i].replace(rg1, "/");
				contenturl+="?"+t[i].substring(2);	
			} else if(t[i].substring(0,2)=="a]"){
				contenturl+="#"+t[i].substring(2);		
			} 
		}
		contenturl=contenturl.replace("undefined","");
		
	}
	
	if (trgt=="b") //b for blank
	{	
		window.open(contenturl); 
	}
	else if (trgt=="r") //r for RAW
	{
		return contenturl;
	}
	else {
		window.location=contenturl;	
	}
	
}
function popup_milieu(link,name,larg,haut,options)
{
  var top=(screen.height-haut)/2;
  var left=(screen.width-larg)/2;

window.open(link,name,'top=' + top + ',left=' + left + ',width=' +larg+ ',height=' + haut + ',' + options);
}

function popup(link,name,size)
{
	newwin = window.open(link,name,size);

}
function popupRW(link,name,size)
{
	
	window.open(lnk(link,'r'),name,size);
	//alert(link+"\n"+lnk(link,'r'));
}
function go(x) {
	document.location.href=x;
		 
}

function aff_no(idd){if(idd){document.getElementById(idd).style.display='none';}}
function aff_yes(idd){	if(idd){document.getElementById(idd).style.display='block';}}
function SHul(MonId, AObj, cat)
{
	imgcat="2";
	MyObj=document.getElementById(MonId);
	ObjImg = AObj.getElementsByTagName("img");
	if (MyObj.style.display=='block') {
		ObjImg[0].src="/images/interface/exp"+imgcat+".gif";
		MyObj.style.display='none';
	} else {
		ObjImg[0].src="/images/interface/shr"+imgcat+".gif";
		MyObj.style.display='block';	
	}
}


$(document).ready(function() {
	
	$("div#blocCross").find("div.lineProductCross").hover(
		function() { 
			var htmlShortDescLabel = '';
			heightBoxShortDescLabel = 0;
			myObjLine = $(this);
			shortDescLabel = myObjLine.find("input.shortDescLabel").val();
			
			if (shortDescLabel!=undefined && $.trim(shortDescLabel)!='') {  //shortDescLabel!='' || 
				htmlShortDescLabel = "<div id='boxShortDescLabel' style='background:#DDD;padding:3px;text-align:center;'>"+shortDescLabel+"</div>";
				
			} 
			
			myObjLine.css({background:'#DDD'});
			$("div#crossHoverImage").show().html( "<img src="+ myObjLine.attr('pathimg') +">" + htmlShortDescLabel ) ;
			
			if ($.browser.msie) $("div#crossHoverImage").css({right:25});
		},
		function() { 
			myObjLine=$(this); 
			myObjLine.css({background:'#FFF'});
			$("div#crossHoverImage").hide();
			
		}
	).click( function(event) {
		
		if (event.target.nodeName!='INPUT' && event.target.nodeName!='A'){
			window.open($(this).find("a").attr('href'));	
		}
	});
	
	$("#unfold-reviews").click(function() {
		
		$("#lesavis").slideToggle("slow")
	});
	$('.homeBoxWList div[mylink]').click(function() { lnk( $(this).attr('mylink'),'' );} );

	$("div#boxShopList").find("span.btnExp").toggle(
		 function() {
			$(this).parents("li").find("ul").show();
			$(this).css({background:'url(http://www.topachat.com/images/interface/ui-topachat.png) -588px -440px no-repeat'});	
		},function() {
			$(this).parents("li").find("ul").hide();
			$(this).css({background:'url(http://www.topachat.com/images/interface/ui-topachat.png) -588px -415px no-repeat'});			
		}
	);	
	$("div#mainBoxCategoryList").find("span.btnExp").toggle(
		 function() {
		 	myBtn = $(this);
		 	myUl = myBtn.parents("li").find("ul");
		 	if( myUl.css("display")=='block') {myUl.hide();	myBtn.css({background:'url(/images/interface/ui-topachat.png) -588px -417px no-repeat'});}  
		 	else {	myUl.show();myBtn.css({background:'url(/images/interface/ui-topachat.png) -588px -442px no-repeat'});}	
		 		
		},function() {
			myBtn = $(this);
		 	myUl = myBtn.parents("li").find("ul");
			if( myUl.css("display")=='none') {myUl.show();myBtn.css({background:'url(/images/interface/ui-topachat.png) -588px -442px no-repeat'});} 
			else {myUl.hide();myBtn.css({background:'url(/images/interface/ui-topachat.png) -588px -417px no-repeat'});}		
		}
	);
	$("div#mainBoxCategoryList").find("ul.open").prevAll("span.btnExp").css({background:'url(/images/interface/ui-topachat.png) -588px -442px no-repeat'});
	$("#btnVoirTouteLaDescription").click( function () { 
		$("#secondPartDescriptionCategory").slideToggle('slow');
	});

	(function($)
	{
		$.fn.blink = function(options)
		{
			var defaults = { delay:500 };
			var options = $.extend(defaults, options);
			
			return this.each(function()
			{
				var obj = $(this);
				setInterval(function()
				{
					if($(obj).css("opacity") == 1)	$(obj).animate({ opacity: 0.2 },250);
					else $(obj).animate({ opacity: 1 },250);
				}, options.delay);
			});
		}
	}(jQuery));

});
