try {
$(document).ready(function() {
	var chosen = null;
    
    function getParameterByName(name) {
      var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == name) {
                var str = pair[1];
                str = decodeURIComponent(str);
                str = str.replace (/\+/g, "%20");
                return decodeURIComponent(str);
            }
        }
        return ("");
    }
    
    /* Check for captcha error */
    hu = window.location.search.substring(1);
    if (hu != "") {
	  var name = getParameterByName("name");
      var email = getParameterByName("email");
      var subject = getParameterByName("subject");
      var message = getParameterByName("message");      
      $('input[name="name"]').val(name);
      $('input[name="email"]').val(email);
      $('input[name="subject"]').val(subject);
      $('textarea[name="message"]').val(message);
	  if (getParameterByName("result") != "ok")
		$("#contact_form_error").html(getParameterByName("result"));
	  else
		$("#contact_form_error").html(":D");
    }
    
  $('.photo_about > img').hover ( 
    function () {
      $(this).stop(true).fadeTo("normal",1);
    }, 
    function () {
      $(this).fadeTo("normal",0);
    }
  );

    
  $('#logo').hover ( 
    function () {
      $(this).stop(true).fadeTo("normal",1);
    }, 
    function () {
      $(this).fadeTo("normal",0);
    }
  );
  
  $('.btnprev > img').hover ( 
    function () {
      $(this).stop(true).fadeTo("normal",1);
    }, 
    function () {
      $(this).fadeTo("normal",0);
    }
  );
  
  $('.btnnext > img').hover ( 
    function () {
      $(this).stop(true).fadeTo("normal",1);
    }, 
    function () {
      $(this).fadeTo("normal",0);
    }
  );
	
	$('#menu ul > li').click(function () {
	
      window.location = "./" + this.id + ".html";
	});
	
	$('#menu ul > li').hover(
	  function () {
		$(this).animate({"opacity":"0.99"},{ queue:false, duration:250 });
	  },
	  function () {
		$(this).animate({"opacity":"0.5"},{ queue:false, duration:500 });
	  }
	);
	
	$('.license_item').hover(
	  function () {
		$(this).animate({"opacity":"0.99"},{ queue:false, duration:250 });
	  },
	  function () {
		$(this).animate({"opacity":"0.25"},{ queue:false, duration:500 });
	  }
	);

	$('ul#links_holder li').hover(
	  function () {
		$(this).animate({"opacity":"0.99"},{ queue:false, duration:250 });
	  },
	  function () {
		$(this).animate({"opacity":"0.5"},{ queue:false, duration:500 });
	  }
	);
	
	$('#languages ul > li').hover(
	  function () {
  	  $(this).animate({"opacity":"1.0"},{ queue:false, duration:100 });
	  },
    function () {
    	$(this).animate({"opacity":"0.5"},{ queue:false, duration:500 });
    }
	);
	
	
	$('#captcha_img').click(function() {
		$(this).attr("src", "http://playmedusa.com/test/captcha.php?" + Math.random());
	})
	
	
		$('.gallery_item_content > img').click ( 
		function () {
		  var path = $(this).attr("src");
		  var file = path.substring(path.lastIndexOf("/") + 1, path.length);
		  file = './images_content/media/big_' + file;

		  $("#veil").remove();		  		  
		  $("#zoom").remove();
		  
		  $('<img />')
		    .attr('src', file)
		    .load(function () {
		      var veil = $("<div id='veil'></div>");
		      var div = $("<div id='zoom' ></div>").append($(this));						   

    		  $("body").prepend(div);		
     		  $("body").prepend(veil);				      
    		  

    		  var zoom_width = $("#zoom").width() + 20;
    		  var zoom_height = $("#zoom").height();
			  var doc_width = Math.max($(window).width(), zoom_width);
     		  var doc_height = $(window).height();
			  var position = $("#zoom").position();  
              var left = 0;  		
			  if (position.left - zoom_width*0.5 > 0)     		 
                left = position.left - zoom_width*0.5;
             
    		  $('#zoom').css('left', left);
     		  $('#zoom').css('top', doc_height * 0.5 - zoom_height*0.5);
    		  $('#veil').css('width', doc_width);
     		  $('#veil').css('height', doc_height);
    		  
    		  $('#zoom > img').bind('click',function(){
    		    $('#veil').animate({"opacity":"0.0"}, 100, function () {
     		      $(this).remove();
    		    });
  		      $('#zoom').animate({"opacity":"0.0"}, 100, function () {
	    			  $(this).remove();
  		      });
 				  
		      });  
		      
		      $('#veil').animate({"opacity":"0.75"},{ queue:false, duration:100 });
		      $('#zoom').animate({"opacity":"0.99"},{ queue:false, duration:100 });
		     });  
		}
	);
});
  
} catch (e) {
 
}

