
$j(document).ready(function() {
	/*
	$j(".topmenu .sub-menu .parent a:first").click(function() {
		$j(this).parent().children("ul").slideToggle(200);
		$j(this).parent().toggleClass("open");
	});
	*/

	$j(".sub-menu").parent("li").addClass("parent");
	$j(".sub-menu li:first-child").addClass("first");
	$j(".sub-menu li:last-child").addClass("last");

	$j(".topmenu .sub-menu .parent a").click(function() {
		$j(this).parent().children("ul").slideToggle(200);
		$j(this).parent().toggleClass("open");
	});
			
	$j("ul.tabs").tabs("> .tabcontent", {tabs: 'li'});
	$j(".row .col:first-child").addClass("alpha");
	$j(".row .col:last-child").addClass("omega"); 
	
// toggle content
	$j(".toggle_content").hide(); 
	
	$j("h3.toggle").toggle(function(){
		$j(this).addClass("active");
		}, function () {
		$j(this).removeClass("active");
	});
	
	$j("h3.toggle").click(function(){
		$j(this).next(".toggle_content").slideToggle();
	});


// pagination
	var islast = $j(".pagination .inner a:last").hasClass('page_current');
	if(islast) $j(".pagination .inner").css('padding-right','35px');

	if ($j.browser.msie  && parseInt($j.browser.version) == 7) {
	 	var ispageprev = $j(".pagination .inner a").hasClass('page_prev');
		if(ispageprev) $j(".pagination, .pagination .inner").css('padding-left','0px');
	}



// gallery
	$j(".gl_col_2 .gallery-item::nth-child(2n)").addClass("nomargin");
	$j(".gl_col_3 .gallery-item::nth-child(3n)").addClass("nomargin");
	$j(".gl_col_4 .gallery-item::nth-child(4n)").addClass("nomargin");
	
	$j(".gallery-image a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast'});
		
});

$j(function () {  
     $j(window).scroll(function () {  
         if ($j(this).scrollTop() != 0) {  
             $j('.link-top').fadeIn();  
         } else {  
             $j('.link-top').fadeOut();  
         }  
     });  
     $j('.link-top').click(function () {  
         $j('body,html').animate({  
             scrollTop: 0  
         },  
         1500);  
     });  
 });
  
 /* SERGE */
 
$j(function () {
	if ($j('#newsCatChooser').length > 0){
		$j('#jsContainer').html($j('#newsCatChooser').html());
		$j('#newsCatChooser').html('');
	}
	if ($j('#sd-1').length > 0){
		$j('#sd1').css('top','-10px');console.log('1');
	}
	if ($j('#sd-2').length > 0){
		$j('#sd2').css('top','-10px');console.log('2');
	}
	if ($j('#sd-3').length > 0){
		$j('#sd3').css('top','-10px');console.log('3');
	}

	
	$j("#customers").click(function(){
		$j("#overlay").css("display","block");
		$j("#boxCustomers").css("display","block");
	});
	
	$j("#overlay,#closeCustomers").click(function(){
		$j("#overlay").css("display","none");
		$j("#boxCustomers").css("display","none");
	});
	
	if ($j("#loadingIndicator").length==1 && $j("#neoNewsPlacerContent_49_1").length==1) {	
		$j("#neoNewsPlacerContent_49_1").sortable({
				update: function(event, ui) { 
					var order_49_1 = new Array();
					$j("#neoNewsPlacerContent_49_1 .menuPortBox").each(function(){
						 order_49_1.push($j(this).attr("news_id"));						 
					});
					$j.ajax({
						 type: "GET",
						 async: false,
						 url: "/_includes/mods/artwhere/store_order_49_1.php",
						 data: "page_id="+CURRENT_FID+"&order="+order_49_1.join(","),
						 success: function(msg){

						 }
					});
				}
		});
	}
	
	$j.ajax({
		type: "GET",
		async: true,
		url: "/_includes/mods/artwhere/twitter_get.php",
		data: "",
		success: function(msg){
			$j(".liker").each(function() {
				$j(this).append("<div id='twitterTop'>"+msg+"</div>");
			});
		}
	});
	
});

function login_facebook() {
	window.open('https://graph.facebook.com/oauth/authorize?display=popup&client_id=215789318450448&scope=user_location,email&redirect_uri=https%3A%2F%2Fwww.artwhere.me%2Fsocial%2Ffb_gateway.php','','toolbar=no,width=550,height=400');
	return false;
}

function login_twitter() {
	window.open('https://www.artwhere.me/social/twitter/connect.php','','toolbar=no,width=550,height=400');
	return false;
}

function login_linkedin() {
	window.open('https://www.artwhere.me/social/linkedin/connect.php','','toolbar=no,width=550,height=400');
	return false;
}

function already_artwhere_me(username) {
	$j(function() {
		$j("#leftPart").html("<div style='padding:20px;'>Bienvenue <b>"+username+"</b>, cliquez sur le bouton ci-dessous pour rejoindre votre interface client <div id='OKConnect' onclick=\"document.location.href='https://www.artwhere.me'\"><input type='button'  value='OK'></div></div>");
		$j("#leftPart").css("margin-top","10px");
	});
}

$j(document).ready(function() {
	$j("#secure_zone").insertBefore(".boutons_row2");
	$j("#secure_zone").prepend("<div style='clear:both'></div>");
});



