﻿
    /*
     * DEFAULT OPTIONS
     *
     options: {
     template:"yourMenuVoiceTemplate",--> the url that returns the menu voices via ajax. the data passed in the request is the "menu" attribute value as "menuId"
     additionalData:"",								--> if you need additional data to pass to the ajax call
     menuSelector:".menuContainer",		--> the css class for the menu container
     menuWidth:150,										--> min menu width
     openOnRight:false,								--> if the menu has to open on the right insted of bottom
     iconPath:"ico/",									--> the path for the icons on the left of the menu voice
     hasImages:true,									--> if the menuvoices have an icon (a space on the left is added for the icon)
     fadeInTime:100,									--> time in milliseconds to fade in the menu once you roll over the root voice
     fadeOutTime:200,									--> time in milliseconds to fade out the menu once you close the menu
     menuTop:0,												--> top space from the menu voice caller
     menuLeft:0,											--> left space from the menu voice caller
     submenuTop:0,										--> top space from the submenu voice caller
     submenuLeft:4,										--> left space from the submenu voice caller
     opacity:1,												--> opacity of the menu
     shadow:false,										--> if the menu has a shadow
     shadowColor:"black",							--> the color of the shadow
     shadowOpacity:.2,								--> the opacity of the shadow
     openOnClick:true,								--> if the menu has to be opened by a click event (otherwise is opened by a hover event)
     closeOnMouseOut:false,						--> if the menu has to be cloesed on mouse out
     closeAfter:500,									--> time in millisecond to whait befor closing menu once you mouse out
     minZindex:"auto", 								--> if set to "auto" the zIndex is automatically evaluate, otherwise it start from your settings ("auto" or int)
     hoverInted:0, 										--> if you use jquery.hoverinted.js set this to time in milliseconds to delay the hover event (0= false)
     onContextualMenu:function(o,e){} --> a function invoked once you call a contextual menu; it pass o (the menu you clicked on) and e (the event)
     },
     */

    $(function(){
      $(".myMenu").buildMenu(
      {
        template:"",
        additionalData:"",
        menuWidth:200,
        openOnRight:false,
        menuSelector: ".menuContainer",
        iconPath:"ico/",
        hasImages:true,
        fadeInTime:300,
        fadeOutTime:300,
        adjustLeft:2,
        minZindex:"auto",
        adjustTop:10,
		menuTop:6,
     	menuLeft:12,
        opacity:.90,
		shadowOpacity:.0,
        shadow:false,
        shadowColor:"#ccc",
        hoverIntent:0,
        openOnClick:false,
        closeOnMouseOut:true,
        closeAfter:500,
        submenuHoverIntent:400
      });

      $(".vertMenu").buildMenu(
      {
        template:"",
        menuWidth:170,
        openOnRight:true,
        menuSelector: ".menuContainer",
        iconPath:"ico/",
        hasImages:true,
        fadeInTime:200,
        fadeOutTime:200,
        adjustLeft:0,
        adjustTop:12,
        opacity:.95,
        openOnClick:false,
        minZindex:200,
        shadow:false,
		shadowOpacity:.0,
        hoverIntent:300,
        submenuHoverIntent:300,
        closeOnMouseOut:true
      });

      $(document).buildContextualMenu(
      {
        template:"",
        menuWidth:200,
        overflow:2,
        menuSelector: ".menuContainer",
        iconPath:"ico/",
        hasImages:false,
        fadeInTime:100,
        fadeOutTime:100,
        adjustLeft:0,
        adjustTop:0,
        opacity:.99,
		openOnClick:false,
        closeOnMouseOut:true,
		shadow:true,
		shadowOpacity:.0,
        onContextualMenu:function(){} //params: o,e
        
      });

	  $("#foto_o").fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
	  
	  $(".refer1").fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});


    });

    //this function get the id of the element that fires the context menu.
    function testForContextMenu(el){
      if (!el) el= $.mbMenu.lastContextMenuEl;
      alert("the ID of the element is:   "+$(el).attr("id"));
    }

    function recallcMenu(el){
      if (!el) el= $.mbMenu.lastContextMenuEl;
      var cmenu=+$(el).attr("cmenu");
      $(cmenu).remove();
    }
	
	function nagerShow(nr) {
	$('#WrapPage').show();
	$("#texterWewTyt").fadeIn(700);
	$("#txt1").fadeIn(1100);
	$('#niebieski_st').fadeOut(100);
		if (nr>0) { osoby(); } else { grafnag(); }
	}
	
	function osoby() { 
						
		
		
		
		$.ajax({
			    type: "POST",
				url: 'robot.php?akcja=fotooso',
				contentType: "application/json; charset=utf-8",
				dataType: 'json',
				success: function(data, sTextStatus, oXMLHttpRequest){
					
						$("#sent01").fadeOut(300);
						$("#sent02").fadeOut(400);
						$("#foto_oso").fadeOut(500);
						$("#foto_podpis").fadeOut(600);
						setTimeout(function() {
									foso = "<img src='oso/"+data.foto+".jpg' />";
									$("#foto_oso").html(foso);
									pod = data.podpis1+" <strong>"+data.podpis+"</strong>";
									$("#foto_podpis").html(pod);
									$("#sent01").html(data.sent1);
									senta = "<strong>"+data.sent2+"</strong>";
									$("#sent02").html(senta);
									$("#sent01").fadeIn(600);
									$("#sent02").fadeIn(800);
									$("#foto_oso").fadeIn(1000);
									$("#foto_podpis").fadeIn(1200);
								}, 600);
						
						
						setTimeout(function() {
									osoby();
								}, 10000);

				},
					error: function (XMLHttpRequest, textStatus, errorThrown) {
					// alert(XMLHttpRequest.responseText);
					}
			});
		
	
	}
	
	
	function grafnag() {
		$('#miastagraf').animate({
				width: '100%'
			  }, 1500);

	//	$("#miastagraf").fadeIn(2500);	
	}
