//CSS Browser Selector

function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);



$(document).ready(function(){
   // Your code here
$('#jcue838536').lionbars('','','true','');


if ($.readCookie( 'sessionout' )) { $('#user3hide').hide(); }
//$('.caccount').click(function() {$('#ajaxMsg').load('index.php?option=com_registration&task=register #registrationform');$('#ajaxMsg').modal();});

var items_title= new Array(); 
var items_img= new Array();
var items_link= new Array();
$('#tabmenu a').each(function() { 
   //$(this) refers to the a
  var elementa=$(this);
  
  items_link.push($(this).attr('href')); items_title.push($(this).attr('title'));
  $(elementa).find('img').each(function() {items_img.push($(this).attr('src'));});

   
});


$('.mainlevel-nav').remove();


var lanavli='';
for (var i = 0; i < items_img.length; i++)
  {
     
     lanavli= lanavli + '<a href=\"' + items_link[i] + '\" title=\"' + items_title[i] + '\" class=\"mainlevel-nav\"><img src=\"' + items_img[i] + '\" border=\"0\" alt=\"' + items_title[i] + '\" /></a>';
  }

$('#tabmenu').append(lanavli); 

$('.mainlevel-nav').hover(
  function () {
    $('#tabscontent').find('*').not('#fb_invite').remove();
    var this_title=$(this).attr('title');
    var color = $('ul[title =\"'+this_title+'\"]').attr('class');
    var tabsec = $('div[title =\"'+this_title+'\"]').html();
    var tabcat = $('ul[title =\"'+this_title+'\"]').html();
    if (!tabsec) {tabsec='';}
    if (!tabcat) {tabcat='';}

    var img=$(this).find('img').attr('src').replace('icon','icon_hover');
    $(this).find('img').attr('src', img);
    var content_title='<div class=\"title arrondi\" style=\"background-color:'+color+';\">'+$(this).attr('title')+'</div>';
    var content_main='<div id="tabmain1">'+tabsec+'</div><div id="tabmain2">'+tabcat+'</div>';
    $('#tabscontent').append(content_title);
    $('#tabscontent').append(content_main);
    if($.browser.msie && $.browser.version=='7.0') { $('#header3').css('z-index','-1');$('#mainbody').css('z-index','-1');}
    $('#tabscontent').show(400);
    $('#tabscontent a').css('color', color);

   
  }, 
  function () {
   
    img=$(this).find('img').attr('src').replace('icon_hover','icon');
    $(this).find('img').attr('src', img);
    
    
    
  }
);

$('#tabscontent').mouseleave(function() {
  $('#header3').css('z-index','10');
  $('#mainbody').css('z-index','11');
   $('#tabscontent').find('*').remove();
$('#tabscontent').css('display', 'none');

  
});
   
$('.inputboxsearch').css({'font-family':'Arial', 'font-size':'16px', 'font-weight':'bold', 'color':'#656459'});
$('.userlogin a').css('color','#808000');



$('#contactform').submit(function(){

		var action = $(this).attr('action');
 
		$('#submit')
			.before('<img src="images/stories/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');
 
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			concerning: $('#concerning').val(),
			messagetxt: $('#messagetxt').val()
		},
			function(data){
				
				$('#contactform #submit').attr('disabled','');
				$('.response').remove();
				$('#contactform').before('<span class="response">'+data+'</span>');
				$('.response').slideDown();
				$('#contactform img.loader').fadeOut(500,function(){$(this).remove()});
				
			}
		);
 
		return false;
 
	});

$('#contactform .close').click(function() { $.modal.close();});
$('#user3 a[title="تسجيل الخروج"]').click(function() {userlogout();return false});
$('#user3 a[title="رسالة الى المرشد"]').click(function() {contactus();return false});
$('#user3 a[title="دفتري الشخصي"]').click(function() {carnetShow();});

var sauvetog=0;
var helptog=0; 



//When page loads...
	$('.ctab_content').hide(); //Hide all content
	
	$('#ctabs li:first').addClass('active').show(); //Activate first tab
	//$('#faqtabs li:first').addClass('active').show(); //Activate first tab
	$('.ctab_content:first').show(); //Show first tab content
	//$('.faq_content:first').show(); //Show first tab content

	//On Click Event
	$('#ctabs li').click(function() {
		if (sauvetog==1) {sauvegarde_untoggle();}
		if (helptog==1) {help_untoggle();}
		$('#ctabs li').removeClass('active'); //Remove any "active" class
		$(this).addClass('active'); //Add "active" class to selected tab
		$('.ctab_content').hide(); //Hide all tab content

		var activeTab = $(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});


	//On Click Event
	$('#faqtabs li').click(function() {
		
		$('#faqtabs li').removeClass('active'); //Remove any "active" class
		$(this).addClass('active'); //Add "active" class to selected tab
		$('.faq_content').hide(); //Hide all tab content

		var activeFaq = $(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
		$(activeFaq).fadeIn(); //Fade in the active ID content
		window.scroll(0,200);
		return false;
	});

	
	

$('.sauvegarde').hover(function() {$('.sauvegarde').attr('src','http://www.conseil-orientation.com/elxis/templates/orientation/images/sauvegardeh.png');}, function() {$('.sauvegarde').attr('src','http://www.conseil-orientation.com/elxis/templates/orientation/images/sauvegarde.png');});
$('.help').hover(function() {$('.help').attr('src','http://www.conseil-orientation.com/elxis/templates/orientation/images/helph.png');}, function() {$('.help').attr('src','http://www.conseil-orientation.com/elxis/templates/orientation/images/help.png');});

$('.sauvegarde').click(function() {
  if (helptog==1) {help_untoggle();} 
  if (sauvetog==0) {sauvegarde_toggle();} else if (sauvetog==1) {sauvegarde_untoggle();}
});

$('.help').click(function() {
  if (sauvetog==1) {sauvegarde_untoggle();} 
  if (helptog==0) {help_toggle()} else if (helptog==1) {help_untoggle();}
});


function sauvegarde_toggle() {
				//if ($.browser.webkit) {$('.sauvegarde').animate({marginRight: "-132px"}, 1000 );} else {$('.sauvegarde').animate({marginRight: "600px"}, 1000 );} $('.ctab_container').hide(1000); $('#c_sauvegarde').show(1000);sauvetog=1;
				$('.sauvegarde').animate({marginRight: "590px"}, 1000 );
				$('.ctab_container').hide(1000); $('#c_sauvegarde').show(1000);sauvetog=1;
}

function sauvegarde_untoggle() {
				//if ($.browser.webkit) {$('.sauvegarde').animate({marginRight: "-708px"}, 1000 );} else {$('.sauvegarde').animate({marginRight: "25px"}, 1000 );} $('.ctab_container').show(1000); $('#c_sauvegarde').hide(1000);sauvetog=0;
				$('.sauvegarde').animate({marginRight: "20px"}, 1000 );
				$('.ctab_container').show(1000); $('#c_sauvegarde').hide(1000);sauvetog=0;
}

function help_toggle() {
			//if ($.browser.webkit) {$('.help').animate({marginRight: "-672px"}, 1000 );} else {$('.help').animate({marginRight: "60px"}, 1000 );} $('.ctab_container').hide(1000); $('#c_help').show(1000);helptog=1;
			$('.help').animate({marginRight: "60px"}, 1000 );
			$('.ctab_container').hide(1000); $('#c_help').show(1000);helptog=1;
}

function help_untoggle() {
			  //if ($.browser.webkit) {$('.help').animate({marginRight: "-97px"}, 1000 );} else {$('.help').animate({marginRight: "635px"}, 1000 );} $('.ctab_container').show(1000); $('#c_help').hide(1000);helptog=0;
			  $('.help').animate({marginRight: "630px"}, 1000 );
			  $('.ctab_container').show(1000); $('#c_help').hide(1000);helptog=0;
}

$('.cajout_m').mouseenter(function() {$('#cajout_menu').show();});
$('#cajout_menu').mouseleave(function() {$('#cajout_menu').hide();});
$('#cajout_menu a').css('color','#000');

$('.slider').sliderNav();


////////////////////////////////////////////////////////////////////////////////////////////
//AutoHeight Iframe
//////////////////////////////////////////////////////////////////////////////////////////
function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(e){
	if(e.contentDocument){
		var link = $('#myframe').attr('src');
		if (((link.indexOf('http://www.conseil-orientation.com/elxis/components/com_tests/index.php?sid=16685')) == 0) ||
		    ((link.indexOf('http://www.conseil-orientation.com/elxis/components/com_tests/index.php?sid=72271') == 0))) 
													{ e.height = e.contentDocument.body.offsetHeight + 5035; }
		else {
		  e.height = e.contentDocument.body.offsetHeight + 35;
		}	
			    }
		 else {
			e.height = e.contentWindow.document.body.scrollHeight;
		    }
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}



/////////////////////////////////Some Remove After Iframe Insertion//////////////////////////////////////////////////////
//$(".testclick").click(function(){$(".componentheading").remove();$(".contentdescription").remove();$(".table").remove();});
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
});

 
function carnetShow() {

if ($.readCookie( 'redirect' )) {$('#carnet_personnel').modal({minWidth:700, minHeight:400, onClose: function() {window.location.href='index.php'; $.modal.close();} });} else {$.modal('<center><h3>يتوجّب عليك تسجيل الدّخول حتّى تتمكّن من استخدام هذه الخدمة</h3></center>', {maxWidth:400, maxHeight:50, containerCss:{borderColor:"#ad2323"}});}
}

function browser() {//$.modal('<center><h3>ننصحك باستخدام متصفّح الواب <a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank">موزيلا فيرفوكس</a> لتتمكّن من عرض كافة موارد الموقع وصفحاته دون مشاكل.</h3><br><a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank"><img src="http://www.conseil-orientation.com/elxis/firefox.jpg" align="middle" /></a></center>', {minWidth:500, minHeight:120, containerCss:{borderColor:"#ad2323"}});
		    $.modal('<center><h3>ننصحك باستخدام متصفّح الواب <a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank">موزيلا فيرفوكس</a> لتتمكّن من عرض كافة موارد الموقع وصفحاته دون مشاكل.</h3><br><a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank"><img src="http://www.conseil-orientation.com/elxis/firefox.jpg" align="middle" /></a></center>', {minWidth:500, minHeight:120, containerCss:{borderColor:"#ad2323"}});
}
