/* DefaultText-Plugin für jQuery  defaultText(className, text) */
(function($){  
	$.fn.defaultText = function(arguments) {  
	  var defaults = {  
			className: "",
			text:"",
			allowDefaultText:false
		};  

	  var args = $.extend(defaults, arguments);

		return this.each(function() {  
			var obj = $(this);
			var textEntered = true;
		
			if(obj.val().length == 0 ||
				 obj.val() == args.text)
			{				
				if(obj.val().length == 0)
					textEntered = false;
				obj.val(args.text);
				obj.addClass(args.className);
				
			}
			
			obj.bind("focus", function(){				
				if (obj.val() == args.text)
				{
					if (args.allowDefaultText === true && 
							textEntered)
						return;
					obj.val("");
					obj.removeClass(args.className);
				}
			});

			obj.bind("blur", function(){				
				if (obj.val() == args.text)
				{
					textEntered = true;
					if (!args.allowDefaultText)
						obj.addClass(args.className);					
				}
				else
				  textEntered = false;
				if(obj.val().length == 0)
				{
					obj.val(args.text);
					obj.addClass(args.className);					
				}
			});			
		});  
	};  
})(jQuery);  

Function.prototype.bind = function(obj) {
    var method = this,
    temp = function() {
        return method.apply(obj, arguments);
    }; 
    return temp;
}

/*###########################################*/

$(document).ready(function () {

/*##########PNG Transparency for IE6##########*/
			$('img[src$=.png], div#loginbox, a.btn_contest, a#captcha_reload img').ifixpng();

/*##########abbr styling for IE##########*/
			if ($.browser.msie) {
                                var abbrTitle = $("abbr").attr("title");
                                $("abbr").wrap("<span class='abbrIE'></span>");
                                $("abbr").parent().attr("title", abbrTitle);
				}
                                
/*##########styles for safari##########*/
			if ($.browser.safari) {
                                $("head").append('<link href="${pathPrefix}css/safari.css" rel="stylesheet" type="text/css" />');
				}
                                
/*##########styles for safari##########*/
                        if ($.browser.opera) {
                                $("head").append('<link href="${pathPrefix}css/opera.css" rel="stylesheet" type="text/css" />');
                        }
                                

/*##########Small Foto Box Highlighting##########*/
			$(".fotobox").bind("mouseenter", function(){$(this).css({backgroundColor: "#f1f1f1"});});
			$(".fotobox").bind("mouseleave", function(){$(this).css({backgroundColor: "#ffffff"});});
			

/*##########Firefox2 css##########*/
			 jQuery.each(jQuery.browser, function(i, val) {				 
					if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.8")
						$("head").append('<link href="${pathPrefix}css/ff2.css" rel="stylesheet" type="text/css" />');
					});



/*##########Show and hide Loginbox##########*/
			var expandedLogin = false;
			$("#lnk_login").click(function(){
					if (!expandedLogin) {
						$("#loginbox").show();expandedLogin = true;
                  $("#login").focus();
					}
					else {
						$("#loginbox").hide();expandedLogin = false;
					}
			});
			
			$("#loginbox_in a.login_close").click(function(){
				$("#loginbox").hide(); expandedLogin = false;
			});



/*##########Show and hide Updates-Column##########*/
			$("#lnk_updates_fotos").click(function(){
					$("#updates_fotos").show(); $(this).addClass("on");
					$("#updates_comments, #updates_topten").hide(); $("#lnk_updates_comments, #lnk_updates_topten").removeClass("on");});
			
			$("#lnk_updates_comments").click(function(){
					$("#updates_comments").show(); $(this).addClass("on");
					$("#updates_fotos, #updates_topten").hide(); $("#lnk_updates_fotos, #lnk_updates_topten").removeClass("on");});
			
			$("#lnk_updates_topten").click(function(){
					$("#updates_topten").show(); $(this).addClass("on");
					$("#updates_fotos, #updates_comments").hide(); $("#lnk_updates_fotos, #lnk_updates_comments").removeClass("on");});



/*##########Hide Dummy Picture##########*/
			$(".upload_cropbox").click(function(){
					$("#preview_pic").removeClass("gone");
					$("#replace_pic").addClass("gone");});


/*##########Input Default Values##########*/
			$("#location").defaultText({text: "", className: "empty_value_postcode_town"});
                        $("#login").defaultText({text: "", className: "empty_value_username"});
			$("#email_register").defaultText({text: "", className: "empty_value_email"});
			$("#email").defaultText({text: "", className: "empty_value_email"});
			$("#email_register_publisherregister").defaultText({text: "", className: "empty_value_email_publisher"});
			$("#password, #password_register, #password_old").defaultText({text: "", className: "empty_value_pwd"});
			$("#pwd_repeat").defaultText({text: "", className: "empty_value_pwd_repeat"});
			$("#search_item").defaultText({text: "", className: "empty_value_searchterm_photograph"});
			$("#choose_town").defaultText({text: "", className: "empty_value_postcode_town"});
			$("#username").defaultText({text: "", className: "empty_value_username"});
			$("#publisher_nr").defaultText({text: "", className: "empty_value_publishernr"});
			$("#publisher_email").defaultText({text: "", className: "empty_value_publishermail"});


/*##########CONTENT FÜR 'MEINE FOTOS' UND 'MEIN PROFIL' ANZEIGEN##########
			$(".my_gallery .topbar a.lnk_myprofile").click(function(){
						$("#my_profile").show();
						$("#my_pictures").hide();
						$(".my_gallery .topbar a.lnk_mypictures").removeClass("on");
						$(this).addClass("on");
						$("#sort_mypictures").addClass("hidden");
			});
			
			$(".my_gallery .topbar a.lnk_mypictures").click(function(){
								$("#my_profile").hide();
								$("#my_pictures").show();
								$(".my_gallery .topbar a.lnk_myprofile").removeClass("on");
								$(this).addClass("on");
								$("#sort_mypictures").removeClass("hidden");
			});*/
			
			
/*########## Show and hide Features-Column ##########*/
			$("#lnk_features_fotos").click(function(){
					$("#features_fotos").show(); $(this).addClass("on");
					$("#features_comments, #updates_topten").hide(); $("#lnk_features_comments, #lnk_features_topten").removeClass("on");});
			
			$("#lnk_features_comments").click(function(){
					$("#features_comments").show(); $(this).addClass("on");
					$("#features_fotos, #updates_topten").hide(); $("#lnk_features_fotos, #lnk_features_topten").removeClass("on");});
			
/*########## Show info layer in "Mein Profil" ##########*/
					$("#show_info_user").bind("mouseenter", function(){$("#info_user").removeClass("hidden");});
					$("#show_info_user").bind("mouseleave", function(){$("#info_user").addClass("hidden");});
					$("#show_info_camera").bind("mouseenter", function(){$("#info_camera").removeClass("hidden");});
					$("#show_info_camera").bind("mouseleave", function(){$("#info_camera").addClass("hidden");});
					$("#show_info_email").bind("mouseenter", function(){$("#info_email").removeClass("hidden");});
					$("#show_info_email").bind("mouseleave", function(){$("#info_email").addClass("hidden");});
					$("#show_info_cloudTags").bind("mouseenter", function(){$("#info_cloudTags").removeClass("hidden");});
					$("#show_info_cloudTags").bind("mouseleave", function(){$("#info_cloudTags").addClass("hidden");});
					//$("#info_user").bind("mouseleave", function(){$(this).css({backgroundColor: "#ffffff"});});
					
/*########## Show info layer in "Detail" ##########*/
					$("#show_info_criteria").bind("mouseenter", function(){$("#info_criteria").removeClass("hidden");});
					$("#show_info_criteria").bind("mouseleave", function(){$("#info_criteria").addClass("hidden");});
					$("#show_info_votes").bind("mouseenter", function(){$("#info_votes").removeClass("hidden");});
					$("#show_info_votes").bind("mouseleave", function(){$("#info_votes").addClass("hidden");});
					$("#show_info_comment").bind("mouseenter", function(){$("#info_comment").removeClass("hidden");});
					$("#show_info_comment").bind("mouseleave", function(){$("#info_comment").addClass("hidden");});
					$("#show_info_vote_state").bind("mouseenter", function(){$("#info_vote_state").removeClass("hidden");});
					$("#show_info_vote_state").bind("mouseleave", function(){$("#info_vote_state").addClass("hidden");});
				
/*########## Show info layer for "Tipps zur Bewertung" ##########*/
					$("a.related_show").click(function(){$(this).hide();$("a.related_hide").show();$("#tipps").show();});
                                        $("a.related_hide").click(function(){$(this).hide();$("a.related_show").show();$("#tipps").hide();});
							 

/*########## Show info layer for publisher_register ##########*/
							$("#show_info_publisher_mail").bind("mouseenter", function(){$("#info_publisher_mail").removeClass("hidden");});
							$("#show_info_publisher_mail").bind("mouseleave", function(){$("#info_publisher_mail").addClass("hidden");});
																																																												 

/*########## Show info layer in "Foto hochladen" ##########*/
		$("#show_info_imgDescr").bind("mouseenter", function(){$("#info_imgDescr").removeClass("hidden");});
		$("#show_info_imgDescr").bind("mouseleave", function(){$("#info_imgDescr").addClass("hidden");});
		$("#show_info_imgKey").bind("mouseenter", function(){$("#info_imgKey").removeClass("hidden");});
		$("#show_info_imgKey").bind("mouseleave", function(){$("#info_imgKey").addClass("hidden");});


/*########## Show info layer in "Gehe auf Entdeckungsreise" ##########*/
		$("#show_info_discover").bind("mouseenter", function(){$("#info_discover").removeClass("hidden");});
		$("#show_info_discover").bind("mouseleave", function(){$("#info_discover").addClass("hidden");});
                
                $("#show_info_alreadydiscovered").bind("mouseenter", function(){$("#info_alreadydiscovered").removeClass("hidden");});
		$("#show_info_alreadydiscovered").bind("mouseleave", function(){$("#info_alreadydiscovered").addClass("hidden");});
                
/*########## Show info layer in "Exif veroeffentlciehnn" ##########*/
		$("#show_info_publishExif").bind("mouseenter", function(){$("#info_publishExif").removeClass("hidden");});
		$("#show_info_publishExif").bind("mouseleave", function(){$("#info_publishExif").addClass("hidden");})
                
/*##########uploadCaptcha##########*/
                $("input#newPicture").bind("change", function(){
                    $("#uploadCaptcha").removeClass("hidden");
                });

                
                /*uploadCaptcha for IE*/
                if ($.browser.msie) {
                     $("input#newPicture").bind("keyup", function(){
                         if ($(this).val())
                             $("#uploadCaptcha").removeClass("hidden");
                    });
                }
                
                
/*##########uploadCaptcha##########*/
                $("a#new_upload").click(function(){
                    $("#close_foto_upload").removeClass("hidden");
                });
                
/*##########Sort Fotos Styling with JS##########*/
              $("input.btn_greybar").css({visibility:"hidden"});
              $("select#sortOrder").css({width:"110px"});
              $("select#sortValue").css({width:"150px"});



/*##########Target blank##########*/
                $("a.externlnk").attr("target", "_blank");


}); // end $(document).ready(function () { 










