//simple form message
function formvalidateonsubmit(form,divID,loading){
		

		if (Spry.Widget.Form.validate(form) == true){
			
			
			Spry.Utils.submitForm(form, function(req){Spry.Utils.setInnerHTML(divID, req.xhRequest.responseText);});
			
			Spry.Utils.setInnerHTML(divID, '<div class="loading">'+loading+'</div>');
			
			return false;
		}
		return false;
	}
//ajax load content
function updateContent(divID,url,loading){
				
		
		Spry.Utils.setInnerHTML(divID, '<div class="loading">'+loading+'</div>');
		
		Spry.Utils.updateContent(divID,url);
		
		return false;

	}
	
//loading
function remove_loading(){
	var targelem=$('#chargement');
	targelem.animate({opacity:'hide'},"slow");
	
};
//menu

function mainmenu(){
$(" #nav_list ul ").css({display: "none"}); // Opera Fix
$(" #nav_list li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(900);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
$("#nav_list li").click(function(){
	
	$(this).faceOut();
	
		});


 
$(document).ready(function(){					
	mainmenu();
});

//open dialog
function OpenDialog(secteur) {	

	$(".dialog").animate({ opacity: 'hide' }, "fast");		
	$("#dialog-"+secteur+"").animate({ opacity: 'show' }, "slow");
	 
}
 
//animate scoll to 
function scollThis(vari){
$('html, body').animate({
scrollTop: $(vari).offset().top}, 2000);
} 
// click all list and closer
$(document).ready(function(){


	$('#sidebar1, #sidebar2').find('div:last').addClass('box-bottom');
						   
	$(".close").click(function(){
		$(this).parents(".dialog").animate({ opacity: 'hide' }, "slow");
		
	});	
	
	$(".download_pdf, .download").click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});
	
	$(".link").click(function(){		
		 scollThis("body");
		return false;
	});
	
	$('#password').val('123456');
	
	$('#password').focus(function(){
		
	$('#password').val('');
		
	});

});

//printing

function Imprimer(obj) 

{
var zone_impr = document.getElementById(obj).innerHTML;
var full_url = '<div id="url">'+document.location.href+'</div>';
var set_css = '<style>body {background-color:#FFF; color:#000; font-size: 18px; font-weight:bold; line-height:26px; padding:20px; direction:rtl;}.tools {display:none;} #url {direction:ltr !important; text-align:left; color:#666; font-size:14px;}</style>';
// Ouvre une nouvelle fenetre
var open_pop = window.open("", "", "height=650, width=650,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");
open_pop.document.body.innerHTML += " " + set_css + " "+ zone_impr + " "+ full_url + " ";

open_pop.window.print();
open_pop.window.close();
}
//password
function evalPwd(s)
{
	var cmpx = 0;
	
	if (s.length >= 4)
	{
		cmpx++;
		
		if (s.search("[A-Z]") != -1)
		{
			cmpx++;
		}
		
		if (s.search("[0-9]") != -1)
		{
			cmpx++;
		}
		
		if (s.length >= 8 || s.search("[\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]") != -1)
		{
			cmpx++;
		}
	}
	
	if (cmpx == 0)
	{
		document.getElementById("weak").className = "nrm";
		document.getElementById("medium").className = "nrm";
		document.getElementById("strong").className = "nrm";
	}
	else if (cmpx == 1)
	{
		document.getElementById("weak").className = "red";
		document.getElementById("medium").className = "nrm";
		document.getElementById("strong").className = "nrm";
	}
	else if (cmpx == 2)
	{
		document.getElementById("weak").className = "yellow";
		document.getElementById("medium").className = "yellow";
		document.getElementById("strong").className = "nrm";
	}
	else
	{
		document.getElementById("weak").className = "green";
		document.getElementById("medium").className = "green";
		document.getElementById("strong").className = "green";
	}
}
//scren size controller
$(document).ready(function() {

if ((screen.width==1152)) {
$('.content').css({'width' : '573px'});
$('.container').css({'width' : '990px'});
$('.nav ul li').addClass('small_li');
}

if ((screen.width==1024)) {
$('.content').css({'width' : '553px'});
$('.container').css({'width' : '970px'});
$('.nav ul li').addClass('small_li');
}


});


 function bookmark() {
	 
	 
 title = "UGEP Maroc"; 
 url = "http://www.ugep.ma/";
 

{
	if (window.sidebar)
		return window.sidebar.addPanel(title, url, "");
	else if ( window.external )
		return window.external.AddFavorite( url, title);
	else if (window.opera && window.print)
		return true;
	return true;
}

 } 

 
