function refresh_list(obj,url,data){
	$(obj).load(url,data);
	$("#container").css({'height':'100%','background': 'url(/images/bg.jpg) repeat-y'});
}
function detail_news(id){
	$("#news_details").load("/modules/news_curr.inc.php","id="+id, function(){
		$('#news_headline').dropShadow({left:5,top:5,blur:2,opacity :.4})
		$("#container").css({'height':'100%','background': 'url(/images/bg.jpg) repeat-y'});
	});
}

function change_img(id){
	$("#albumimg").load("../elements/albumimg.inc.php","id_prd="+id );
}

var tooltip = "";
$(function(){
	$(".addcart").click(function(){
		id = $(this).attr("id");
		$("#addcart #id").val( id.substr(2) );
		$("#addcart").submit();
	});
	$("#btn_viewcart").click(function(){
		$("#viewcart").submit();
	})
	$("#pageimge").reflect();	   
	$("#go").css({'opacity':.75})	  
	$(".admin_chapter").css({'opacity':.75})
		.hover(
			function () {
				$(this).css({'opacity':1});	
			}, 
			function () {
				$(this).css({'opacity':.75});	
			})
		.click(function(){
		$(this).parent("form").submit();
		});
	$("#join_form #email").focus(function(){
		if($(this).val() == "Please enter your email"){
			$(this).val("");
		}
	})

	$(".button").css({'opacity':.75});	
	$(".track img").css({'opacity':.75});	
	
	$(".button").hover(
      function () {
		$(this).css({'opacity':1});	
      }, 
      function () {
		$(this).css({'opacity':.75});	
      }
    );
	
	$(".track").hover(
      function () {
		$(this).children(".itm").children("a").css({'color':'#FFFFFF'});
		$(this).children("a").children("img").css({'opacity':1});
      }, 
      function () {
        $(this).children("a").children("img").css({'opacity':.75});
		$(this).children(".itm").children("a").css({'color':'#F3BAFF'});
      }
    );
		   
	$(".tt").hover(
        function () {
			tooltip = $(this).attr("title");
			//alert(tooltip);
			$("#tooltip").text(tooltip);
			$(this).removeAttr("title");
			$("#tooltip").css({ 
				'width': 'auto'
			  });	
		  	$(this).mousemove(function(e){
			  var Xpos = e.pageX;
			  var Ypos = e.pageY;
			  var w = $("#tooltip").width();
			  $("#tooltip").css({
				'left' : Xpos-Math.floor(w/2) + 'px', 
				'top' : (Ypos-40) + 'px', 
				'width': w +'px'
			  });		 
			});
			$("#tooltip").show();
        },function(){
			$(this).attr("title",tooltip)
			$("#tooltip").hide();
	});//hover	   		   
	
	
	
		
	$("#info_button").click(
		 function () {
			$("#tooltip").hide();
			if(review){
				tooltip = "Release Notes";
				image = "/images/i_info.gif";
				param = "review=1";
			}else{
				tooltip = "Review";
				image = "/images/i_chat.gif";
				param = null;
			}
			$(this).attr({src:image,  title:tooltip })
			$("#cd_details").load("/modules/reviews.inc.php",param,function(){
					$("#cd_details h2").dropShadow({left:5,top:5,blur:2,opacity:.4}); });
			review = !review;
		});
	   
		   
	$("#albums_list_tb tr:has(td), #table_list tr:has(td)").hover(
      function () {
        $(this).addClass("table_over")
      }, 
      function () {
        $(this).removeClass("table_over")
      }
    );

	refresh_list('#new_list','/modules/news_list.inc.php','');
	
	$(".this_image a").each(function(index,el){
		$(el).parent(".this_image").addClass('loader');	
		$(el).children("img").cacheImage({
			load : function (e) { 
				$(el).parent(".this_image").removeClass('loader');	
				$(el).parent(".this_image").dropShadow({left:5,top:5,blur:2,opacity:.4});
				$(el).children("img").show();
			}
		});
	});
	
	$("#menu .menu:first").css({'border-left':'none'})
	$("#menu .menu:first").addClass('firstnav');
	$("#menu .menu:first a").css({'width':'110px'})
	$("#menu .menu:last").css({'border-right':'none'});
	$("#menu .menu:last").addClass('lastnav');
	$("#menu .menu:first .curr").css({'width':'110px'})	 
		   
	$("#topic_headline").animate( { top:"40px" }, 1500);
	$("#top_flash").load("/elements/topflash.php")
	$("#tooltip").hide();

	var m_offset = ( navigator.userAgent.indexOf('MSIE') != -1) ? -17 : -16;
	$("h1").FontEffect({
			mirror:true,
			mirrorHeight :100, 
			mirrorTLength :30, 
			mirrorColor: "#FFFFFF",
			mirrorOffset : m_offset
	})
	$('.shadow').dropShadow({left:5,top:5,blur:2,opacity:.4 });
	
	$(".input1").focus(function () {
		$(this).addClass("input_focus");
	});
	$(".input1").blur(function () {
		 $(this).removeClass("input_focus");
	});
	
// טופס ===============================
	var sending = "sending...";
	var resend = "Send";
	var formData;

	$("#contactform").submit(function(){
		formData = $(this).serialize();
		sendform('/contact.common.php')
	});		
	
	$("#bookingform").submit(function(){
		formData = $(this).serialize();
		sendform('/booking.common.php')
	});		
	
	function sendform(sever_page){								  
		$.ajax({
			type: "POST",
			url: sever_page,
			data: formData,
			beforeSend: function(){
				$("#Send").val(sending);
				$("#Send").attr('disabled', true);
			},
			success: function(msg){
					result = msg;
					if(result.substr(0,2) == 'OK'){
						$("#contact").html(result.substr(2));
					}else{
						$("#error").html(result);
					} 
			},
			complete: function(){
    			if(result.substr(0,2) != 'OK'){
					$("#Send").val(resend);
					$("#Send").attr('disabled', false);
				}
				$("#container").css({'height':'100%','background': 'url(/images/bg.jpg) repeat-y'});
   			},
			error: function(xhr) {
        		alert('Error!  Status = ' + xhr.status);
    		}	
		});
		return false;
	}
	
	$("#pommo_signup").click(function(){	
			$.ajax({
			type: "POST",
			url: "/email.common.php",
			data: $("#join_form").serialize(),
			beforeSend: function(){
				 $("#pommo_signup").val(sending).attr('disabled', true);
			},
			success: function(msg){
					result = msg;
					if(result == ''){
						 $("#join_form").submit();
					}else{
						$("#error").html(result);
					} 
			},
			complete: function(){
    			if(result != ''){
 					 $("#pommo_signup").val('Subscribe').attr('disabled', false);
				}
				$("#container").css({'height':'100%','background': 'url(/images/bg.jpg) repeat-y'});
   			},
			error: function(xhr) {
        		alert('Error!  Status = ' + xhr.status);
    		}	
		});
		return false;
	});


})
