 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-24807963-14']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
function expandCollapse(ElementId)
{
  var theElement = document.getElementById(ElementId);
  theElement.style.display = (theElement.style.display == 'none') ? 'block' : 'none';
}



$(document).ready(function(){

    $(".tooltips input").hover(function() {
    $(this).next("p").stop(true, true).animate({opacity: "show", top: "-30"}, "slow");
    }, function() {
    $(this).next("p").animate({opacity: "hide", top: "-40"}, "fast");
    });

});


 function ajaxContet(formid,php,target)
 {
    $.ajax({
      type: "POST",
      data: $("#"+formid).serialize(),
      url: '/modules/'+php+'.php',
      success: function(data) {
        $('.'+target).html(data);
      }
    });
 }

 function loadContent(php,target)
 {
    $.ajax({
      type: "POST",
      url: '/modules/'+php+'.php',
      success: function(data) {
        $('.'+target).html(data).slideToggle("fast");
      }
    });
 }

  function  insertComment(id)
  {
      $('.commentsholder').slideUp();
      $('.loadingnow').slideDown();

     $.ajax({
      type: "POST",
      data: $("#postform").serialize(),
      url: '/modules/ajaxbridge.php',
      success: function(data) {
        $('#result').html(data);
        $('.loadingnow').slideUp();
        $('.commentsnow').slideDown();
        $('#replyto').fadeOut();
        $('#addcommentholder').slideToggle(function(){alertbox("Vélemény elküldve és megjelenítve");  });
        
      }
    });
  }

  function  insertSmallComment(id)
  {
     $.ajax({
      type: "POST",
      data: $("#postform"+id).serialize(),
      url: '/modules/ajaxbridge.php',
      success: function(data) {
        $('#result'+id).html(data).slideToggle("500");
        $('#commentform'+id).html(data).slideToggle("500");
      }
    });
  }

  function  insertStatus(id,url)
  {
     $.ajax({
      type: "POST",
      data: $("#poststatus").serialize(),
      url: '/modules/ajaxbridge.php',
      success: function(data) {
        self.location=url;
      }
    });
  }



function refreshimage()
{
    $.ajax({ url: "/modules/ajax/userpic.php", success: function(data){
        $('#userpicture').html(data);
        $('#userpicture2').html(data);
      }});
}

function like(action,content,ctype,big,owner,title,linkes)
{
   $('#like'+content).fadeOut("200");
   $.ajax({
   type: "POST",
   url: "/modules/ajaxbridge.php",
   data: 'action='+action+'&content='+content+'&ctype='+ctype+'&big='+big+'&owner='+owner+'&title='+title+'&links='+linkes+'',
   success: function(data){
       $('#like'+content).html(data).fadeIn("200");
       if(big)showlikes(content,ctype);
   }
 });
}


function showlikes(content,ctype,owner,title,sharelink)
{
    $.ajax({ type: "POST", url: "/modules/ajax/likelist.php", data: 'content='+content+'&ctype='+ctype+'&owner='+owner+'&title='+title+'&sharelink='+sharelink+'', success: function(data){
        $('#likelist').html(data).fadeIn();
      }});
}

 function ajaxSave(formid,target)
 {
    $.ajax({
      type: "POST",
      data: $("#"+formid).serialize(),
      url: '/modules/ajaxbridge.php',
      success: function(data) {
        $('#'+target).html(data);
      }
    });
 }

 function startMessage(from,to,type,reply,check)
 {
     //type 1 - welcome
     //type 2 - replymsg
     $.ajax({
      type: "POST",
      data: 'from='+from+'&to='+to+'&type='+type+'&reply='+reply+'&check='+check+'',
      url: '/modules/sendmessage.php',
      success: function(data) {
        $('#startmessage').html(data);
      }
    });

 }

function showconversation(id,noslide)
 {
     //$('#conversation'+id).removeClass('unreaded').addClass("readed");
     $.ajax({
      type: "POST",
      data: 'id='+id+'',
      url: '/modules/viewconversation.php',
      success: function(data) {
        $('#message'+id).html(data);

        if(noslide!='noslide'){$('#message'+id).slideToggle();}
      }
    });

 }

function searchmessages()
{


        var search =$("#searchform").val();
        $.ajax({ type: "POST", data: 'search='+search, url: "/modules/privatemessages.php", success: function(data){ $('.messagelist').html(data); }});

}




 function sendpm(reply,fullmsg)
 {


     if($('#to').val().length!='0')
     {
     $("#sendpm_text").val($("#editor").html())
     $.ajax({
      type: "POST",
      data:  $("#sendpm").serialize(),
      url: '/modules/sendmessage.php',
      success: function(data) {
       $('.sendmessage').html(data).delay(1400).queue(function(){$.fancybox.close(); });
       $('.regok').fadeIn();

        if(reply)
            {
                showconversation(reply,'noslide');
            }

        if(fullmsg)
            {
            $.ajax({ type: "POST", data: 'check=yes', url: "/modules/privatemessages.php", success: function(data){ $('.messagelist').html(data); }});
            }

      }

    });
     }
     else
     {
         $('#reqf').addClass('requiredfield');
     }
 }



 function delconversation(reply)
    {
    $.ajax({ type: "POST", data: 'delcon='+reply, url: "/modules/privatemessages.php", success: function(data){
        $('.messagelist').html(data);
      }});
    }

 function changehoroscope(to)
 {
     $.post("/modules/ajaxbridge.php", {horoscope: to});
     $('#monthly').fadeOut();
     $('#daily').fadeOut();
     $('#year').fadeOut();
     $('#'+to).fadeIn();
 }



 function showonline()
 {
       $.ajax({ url: "/modules/chat/onlineusers.php", success: function(data){ $('#onlinemembers').html(data); $('.onlinelist').slideToggle();}});

 }

 function alertbox(msg) {
    jQuery.fancybox({
        'modal' : true,
        'padding': 1,
        'content' : "<div style=\"margin:0px;width:240px; text-align: left; padding: 20px; \">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><a href=\"JavaScript:void(0);\" onclick=\"jQuery.fancybox.close();\" class=\"bbutton rounded\">Ok</a></div></div>"
    });

}

function confirmbox(msg,callback,id) {
    var ret;
    jQuery.fancybox({
        modal : true,
        content : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><a href=\"JavaScript:void(0);\" id=\"fancyConfirm_cancel\" class=\"vbutton rounded\">mégse</a>&nbsp;<a href=\"JavaScript:void(0);\" id=\"fancyConfirm_ok\" class=\"bbutton rounded\">ok</a></div></div>",
        onComplete : function() {
            jQuery("#fancyConfirm_cancel").click(function() {
                ret = false;
                jQuery.fancybox.close();
            })
            jQuery("#fancyConfirm_ok").click(function() {
                ret = true;
                jQuery.fancybox.close();

                if(callback=='delmsg')
                {
                    delconversation(id);
                }

                if(callback=='logout')
                {
                    self.location='http://www.furedpizza.net/logout'
                }

            })
        }
    });
    $(".rounded").corner("5px");
}

function uploadnow()
{
    $.ajax({ type: "POST", url: "/modules/uploadpic/index.php", success: function(data){
        $('#uploadnow').html(data).fadeIn();
      }});
}

function uploadnow()
{
    $.ajax({ type: "POST", url: "/modules/uploadpic/index.php", success: function(data){
        $('#uploadnow').html(data).fadeIn();
      }});
}

function delgalpic(image)
{
$.ajax({ type: "POST", data: 'delimg='+image+'&show=yes', url: "/modules/profile_gallery.php", success: function(data){
    $('#usergallery').html(data);
  }});
}

function reportspam(id)
{
       $.ajax({ type: "POST", data: 'spam='+id, url: "/modules/ajaxbridge.php"});
}

function replyto(id)
{
       $.ajax({ type: "POST", data: 'replyto='+id, url: "/modules/ajaxbridge.php", success: function(data){
        $('#replyto').html(data).fadeIn();
      }});
}

function lostpass()
{
       $.ajax({ type: "POST", data:  $("#form").serialize(), url: "/modules/lostpass.php",success: function(data) { $('#lostpass').html(data); }});
}

function loginnow(url)
{
 // alert(url);     
  $.ajax({ type: "POST", data:  $("#loginform").serialize(), url: "/modules/login.php",success: function(data) { $('#logindata').html(data); if(data=='<div style="display:none">ok</div>'){self.location=url} }});

}


/*
function addfeltet(id,kajaid,userid,session,domain)
{
    if ($("#cb"+id).is(":checked"))
        {
          	if($('#toprod').val()!=''){var regival=$('#toprod').val(); }
          	var size=$('#size').val();
            var toprod=$('#toprod').val();
            $.ajax({ type: "POST", data: 'size='+size+'&feltetid='+id+'&toprod='+toprod+'&kajaid='+kajaid+'&userid='+userid+'&session='+session+'&domain='+domain+'&action=add', url: "/modules/ajaxbridge.php", success: function(data){
            $('#cart').html(data).fadeIn(); }});
            //alertbox('Feltét hozzáadva a kosárba');
            if(regival!=''){$('#toprod').val(regival);}
        }
        else
        {
        var size=$('#size').val();
        var toprod=$('#toprod').val();
          $.ajax({ type: "POST", data: 'size='+size+'&feltetid='+id+'&toprod='+toprod+'&kajaid='+kajaid+'&userid='+userid+'&session='+session+'&domain='+domain+'&action=remove', url: "/modules/ajaxbridge.php", success: function(data){
            $('#cart').html(data).fadeIn(); }});
            //alertbox('Feltét elvéve a kosárból');
        }

}
*/
function addfeltet(id,kajaid,userid,session,domain)
{

            if($('#toprod').val()!=''){var regival=$('#toprod').val(); }
            var toprod=$('#toprod').val();
            $.ajax({ type: "POST", data: 'size='+size+'&feltetid='+id+'&toprod='+toprod+'&kajaid='+kajaid+'&userid='+userid+'&session='+session+'&domain='+domain+'&action=add', url: "/modules/ajaxbridge.php", success: function(data){
            $('#cart').html(data).fadeIn(); }});
            //alertbox('Feltét hozzáadva a kosárba');


}

function addtocart(kajaid,userid,session,size,domain)
{

            $.ajax({ type: "POST", data: 'size='+size+'&kajaid='+kajaid+'&userid='+userid+'&session='+session+'&domain='+domain+'&action=add', url: "/modules/ajaxbridge.php", success: function(data){
            $('#cart').html(data).fadeIn(); }});
            $('#success1').slideDown().delay(2600).slideUp();
            $('#ok'+size).delay(800).fadeIn();
            alertbox('Termék hozzáadva a kosarába, amennyiben szertne több darabot nyomja meg ismét a kosárba gombot!');

            //feltetlista(size,kajaid);


}


function feltetlista(size,prodid)
{
       $.ajax({ type: "POST", data: 'size='+size+'&prodid='+prodid, url: "/modules/products-feltet.php", success: function(data){
        $('#feltetlista').html(data).fadeIn();
      }});
}

function removefromcart(cartid,userid,session,domain)
{

    $.ajax({ type: "POST", data: 'cartid='+cartid+'&userid='+userid+'&session='+session+'&domain='+domain+'&action=remc', url: "/modules/ajaxbridge.php", success: function(data){
    $('#cart').html(data).fadeIn();
    
          $.ajax({ type: "POST", data: 'datashow=1', url: "/modules/cart.php", success: function(data){
        $('#showcarts').html(data);
      }});
    
    }});



}

function savenote(session,userid,link)
{
    var note=$('#note').val();
    $.ajax({ type: "POST", data: 'addnote='+note+'&session='+session+'&userid='+userid, url: "/modules/ajaxbridge.php", success: function(data){self.location=link;}});


}



  function reload() {setTimeout('reloadImg("refresh")',60000)};    // 1000 = 1 second. I'd suggest a reasonable minumum of 350
  function reloadImg(id)
  {
   var obj = document.getElementById(id);
   var rand = Math.random();
   obj.src = "http://gyongyospizza.dyndns.org:151/snapshot.cgi?user=teszt&pwd=teszt&t="+rand;
  }

function play(){
	$('#play').html('<a href="#" class="play"><img src="http://gyongyospizza.dyndns.org:151/videostream.cgi?user=teszt&pwd=teszt" alt="" width="296" /></a>');
}

function chvalset()
{
   var chnowval=$('#chval').val();

   if(chnowval=='yes')
   {
	  $('#chval').val('no');
   }
   else
   {
   	  $('#chval').val('yes');
   }
}

function chvalset2()
{
   var chnowval=$('#chval2').val();

   if(chnowval=='yes')
   {
	  $('#chval2').val('no');
   }
   else
   {
   	  $('#chval2').val('yes');
   }
}



