
// auto clear for text fields class .autoclear

$(document).unbind().ready(function(){
        
        $('label.info, label.error').click(function() {
                $('label.info, label.error').hide();
                
        });
        
        
        $('input.autoclear').each(function(index) {
		   $(this)
			   .attr('default',$(this).val())
			   .click(function() {
				   if($(this).val() == $(this).attr('default')) {
					   $(this).val('');
				   }
			   })
			   .focus(function() {
				   if($(this).val() == $(this).attr('default')) {
					   $(this).val('');
				   }
			   })
			   .blur(function() {
				   if($(this).val() == "") {
					   $(this).val($(this).attr('default'));
				   }
			   });
	   });


        $('#form_newsletter').validate({event:"submit",
                                   rules: {
				newsletter_email: {
					required: true,
					email: true
									}
								  },
								  messages: {
					newsletter_email: gettext('Please enter a valid email address')
								  },
								  submitHandler: function(form) {
					$(form).ajaxSubmit();
					alert(gettext('Your address has been added. Thank you!'))
								  }
							   });


        $('#form_sendfriend').validate({event:"submit",
                rules: {
						sendfriend_name: {
							required: true,
							minLength: 2
										  },
						sendfriend_email: {
							required: true,
							email: true
										}
				},
				submitHandler: function(form) {
						$(form).ajaxSubmit();
											alert(gettext('Message sent. Thank you!'))
						}
				});

		$('#form_contact').validate({event:"submit",
				rules: {
						contact_email: {
							required: true,
							email: true
						},
						contact_name: {
							required: true
						},
						contact_msg: {
							required: true
						}
						},
						messages: {
							newsletter_email: gettext('Please enter a valid email address')
						},
						submitHandler: function(form) {
							$(form).ajaxSubmit();
							alert(gettext('Your message has been sent. Thank you!'))
							$('#contact_email').val('');
							$('#contact_name').val('');
							$('#contact_msg').val('');
							$('#contact_phone').val('');
							
						}
				});

    $("#page_disco ul li a ").click(function(){
        disco = $(this);
        $(".list").css("display","none");
        $("#"+disco.attr('disc')).fadeIn('slow');
     });
    
    /** hide all cat's just .first not */
    /*$("#page_links a.linkscat ").each(function(){
     var cat = $(this);
     cat.click(function() {
         $(".linkitem").css("display","none");
         $("."+cat.attr('cat')).fadeIn('fast');
     })   
    });*/

    $("a.video_link").each(function(){
           var link = $(this);
           link.click(function() {
                $("label.info").show();
                if($('#radio').html())
                        $("label.info").html('<b>your radio has been disabled</b><br>after watch the movie, go top to enable it again');
               $('#radio').empty();
               $('span#remote_control a.onair').css('background','url("../img/radio/stoped.gif") no-repeat top left')
               $("#video_player").html('<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/'+link.attr('video_id')+'" width="342" height="286"><param name="movie" value="http://www.youtube.com/v/'+link.attr('video_id')+'" /><img src="banner.gif" width="342" height="286" alt="banner" /></object>');
               
           })
       });

	/**
	 * ajax pages
	 */
	
	$('a.ajax').click(function() {
		$("#content").load($(this).attr('href')+'/1');
		return false;
	});
        
        
        $('.tags_reviews span small a').attr('target','#blank');
        
	
});
