﻿$(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'); 
	//$('a#banner_baia_a').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; 					
	});
	
	$(".tutu").css("cursor", "default"); 
	$(".tutu").click(function(){ return false; });
	
	$(".calendar_mes a").click(function(){ return false; });
	$(".calendar_dia a").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"); 
	
	//  Yellow input field Chrome
	
	if ($.browser.webkit) {
		$('input[name="passwrd"]').attr('autocomplete', 'off');
		$('input[name="user"]').attr('autocomplete', 'off');
	}

});


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

/* BUTTON COOKIE TOPLINKS */
	
$(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 contact
	
	$('#contact_button').click(function() {
		Show_Popup_ctc();
		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;	});
	
	$('.popword').click(function() {
		var x = $(this).attr('id'); 
		var data = "x=" + x; 
		$('#popup').fadeIn(10);
		$('#window_word').fadeIn(10);
		$('#window_word').load('glo_word.php?'+data);
		return false;
	});	
	
	
	// CLOSE POPUPS
	
	/*
	$('#page-wrap').live("click", function(){	
		$('#popup').fadeOut(100);
		$("#window_log").css("display", "none"); 		
		$("#window_tem").css("display", "none"); 
		$("#window_ctc").css("display", "none"); 
	});	
	*/
	
});



