﻿
$(document).ready(function () {
	ph = $("body").height(); $('#popup').css('height', ph); 
	
	$('div#menu_subcats').css('display', 'none').fadeIn(400);
	
	$('a[href^=http]').attr('target', '_blank');
	$('a#footer_logo_baia').attr('target', '_self');
	
	// LOGIN BOX : AJAX STUFF related to the SUBMIT button 
	
	$("#fofo").submit(function(){
		var user = $("#user").val();
		var passwrd = $("#passwrd").val();
		if ( (user) && (passwrd) ) {
			$.ajax({
			type: "POST",
			url: "toplinks.php?admin=sapo",
			data: $(this).serialize(), 		//this sends the forms data to cookie.php
			success: function(msg){
				$("#toplinks").html(msg);
			}
			});
			
			$.ajax({
			type: "POST",
			url: "divadmin.php",
			data: $(this).serialize(), 		//this sends the forms data to cookie.php
			success: function(msg){
				$("#divadmin").html(msg);
			}
			});
			Close_Popup_log();	
			
			
			// Insert Admin Edit Links
			
			//$zou = $(".adm_edit");
			//if (empty($zou)) {
				$p = $("table[id]");		
				$p.each(function() {
					$truc = $(this).attr("id");
					var nouvo = '<a class="adm_edit" href="admin/index.php?page=new_article&clean=1&edit=1&member_id=555&article_id=' + $truc + '">Edit</a>';
					$(this).before(nouvo);
				});
			//}
			
		}
		return false; 					
	});
	
	/*
	$("#toplink_disco").live("click", function(){ 
		//alert('caca');
		//return false; 
		
		// Remove Admin Edit Links
		
		//$(".adm_edit").remove();
		alert('caca');
		
		/*		
		$p = $("table[id]");		
		$p.each(function() {
			$truc = $(this).attr("id");
			var nouvo = '<a class="adm_edit" target="_blank" href="admin/index.php?page=new_article&clean=1&edit=1&member_id=555&article_id=' + $truc + '">caca</a>';
			$(this).before(nouvo);
		});
		
	});
	*/
	
	
	
	
	$(".tutu").css("cursor", "default"); 
	$(".tutu").click(function(){ return false; });
	
	// LINKS ICONS
	
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("a_pdf");
 
	// Add txt icons to document links (doc, rtf, txt)
	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("a_def");
 
	// Add zip icons to Zip file links (zip, rar)
	$("a[href$='.exe'], a[href$='.rar']").addClass("a_exe"); 

});


function submitform()	{
	document.search_form.submit();
}


/* BUTTON COOKIE TOPILINKS */
	
$(function(){

	// Applying the skin indicated in the cookie if there is one
	
	if ($.cookie("skin")) {
		$("link").eq(2).attr("href",$.cookie("skin"));
	}
		
	// popup associated with toplink skin button
	
	$('#skin_button').click(function() {
		Show_Popup_tem();
		return false;
	});
	
	// popup skin thumbs generate cookies
	
	var cookie_name = 'skin';
	var options = { path: '/', expires: 100 };
	
	$('.thumb1').click(function() {	 $("link").eq(2).attr("href",$(this).attr('rel')); $.cookie(cookie_name, 'skin01.css', options);	Close_Popup_tem();	return false;	});
	$('.thumb2').click(function() {	 $("link").eq(2).attr("href",$(this).attr('rel')); $.cookie(cookie_name, 'skin02.css', options);	Close_Popup_tem();	return false;	});
	$('.thumb3').click(function() {	 return false;	});
});


