$(document).ready(function(){
		
		$("input[type=text]").focus(function () {
         $(this).next("#tip").show();
    	});
		
		$("input[type=text]").blur(function () {
         $(this).next("#tip").hide();
    	});
		
		$("div.box").corner("10px");
		$("div.warning").corner("10px");
		$("div.widebox").corner("10px");

		$("div.quickshoppingcart").corner("10px").fadeIn();
		
    $("#footerform").submit(function(){
			 $.ajax({
			   type: "POST",
			   url: "contactrespajax.asp",
			   data: $("#footerform").serialize(),
			   success: function(){
				   					$("#footerform").hide("slow"); 
								    $("#resultcontact").show("fast");
								  }
			 });
		});

	
		$(".warning").show("fast"); 
		
		$("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
				'titlePosition'	: 'inside',
				'showNavArrows' : 'True',
				'cyclic' : 'True',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}

			});
		
				$("a[href$=.pdf]").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'				

			});

		
		$("a.managelang").click(function(){
				$(this).next().css({'width': '100%', 'height': '100%', 'position': 'absolute', 'right': '0%',	'top': '0%', 'background': 'black', 'padding-top': '20%', 'z-index': '1'}).show("fast");
		});
		
			$("form[id^=lang]").submit(function(){		
			$.ajax({
			   type: "POST",
			   url: "/manage/managelanguage_addrecord.asp",
			   data: $(this).serialize(),
			   success: function(){
										$("form[id^=lang]").hide("fast");
								  }
			 });
		});

		
		$('.input, .searchtext').each(function() {
				var default_value = this.value;
				$(this).focus(function() {
						if(this.value == default_value) {
								this.value = '';
						}
				});
				$(this).blur(function() {
						if(this.value == '') {
								this.value = default_value;
						}
				});
		});
		
		$("a.pmbutton").click(function(){
				$(".pmbutton").hide();
		});
	
		$("#usernamelookup").autocomplete("/manage/usernamelookup.asp", {
			width: 235,
			selectFirst: false
		});

		$("#Participantlookup").autocomplete("/youth/Participantlookup.asp", {
			width: 235,
			selectFirst: false
		});
		
		$("#Participantlookup").result(function(event, data, formatted) {
		if (data)
			$(this).parent().find("input#idNumber").val(data[1]);
		});
		
		$("img.waitlistX").click(function(){
			$(this).hide().attr( "src", "interfaceimages/error.png" ).show()
		});

		$("img.removeuser").click(function(){
			$(this).hide().next("a").show()
		});
		
		$("img.removeuserx").mouseout(function(){
			$(this).hide()
		});

		$('.edit_area').editable('http://www.kerenahvah.org/manage/manageNews_editnews.asp', { 
         type      : 'textarea',
         cancel    : 'Cancel',
         submit    : 'OK',
         indicator : '<img src="interfaceimages/bigok.png">',
         tooltip   : 'Click to edit...'
     });

		$('.edit_stock').editable('http://www.kerenahvah.org/manage/manageBooks_editStock.asp', { 
         tooltip   : 'Click to edit...'
     });

			$(".showform").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

			$(".addbookproperties").bind("submit", function() {
			var idname = $(this).attr("id");
				$.fancybox.showActivity();
			
				$.ajax({
					type		: "POST",
					cache	: false,
					url		: "/manage/"+idname+".asp",
					data		: $(this).serializeArray(),
					success: function(data) {
						$.fancybox(data);
					}
				});
			
				return false;
			});
			
			
			$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

});


