//TOM habe dieses script deaktiviert 10.2010, wenns doch gebraucht wird: das @ in Zeile 63 rausnehmen, nicht JQuery 1.4 kompatibel	

var max = 400;
var expanded_height_profile_news;
$(document).ready(function(){

	/*$("#edit-artist").hide();*/
	
	/*Fehlerfeldkorrektur - Artist*/
	errorheightArtist = $("#error-msg").height()+17;
	if (errorheightArtist == 17) errorheightArtist = 0;
	topPositionArtist = errorheightArtist+535+"px";
	bottomPositionArtist = errorheightArtist+835+"px";
	
	/*Fehlerfeldkorrektur - News*/
	errorheightNews = $("#error-msg-news").height()+17;
	if (errorheightNews == 17) errorheightNews = 0;
	positionNews = errorheightNews+776+"px";
	$("#news-upload-form-wrapper").css({"top": positionNews});
	
	
	/*Fehlerfeldkorrektur - Profile*/
	errorheightProfile = $("#error-msg-profile").height()+17;
	if (errorheightProfile == 17) errorheightProfile = 0;
	topPositionProfile = errorheightProfile+557+$('#member-info-profile-news').height()+"px";
	bottomPositionProfile = errorheightProfile+857+$('#member-info-profile-news').height()+"px";
	
	
	// initially hide or display individual news input fields
	if ($("#news-configuration-individual").attr("checked")) {
		$("#news-individual").show();
		$("#profile-upload-form-wrapper").css({"top": bottomPositionProfile});
	} else {
		$("#news-individual").hide();
		$("#profile-upload-form-wrapper").css({"top": topPositionProfile});
	}
	
	
	
	
	//set the function to count the text elements of individual news
	
	try{
		if (max-document.form_account_profile &&
		    max-document.form_account_profile.profile_news_text)
			$("#news-text-count").text(max-document.form_account_profile.profile_news_text.value.length);	
		//document.form_account_profile.profile_news_text.focus();
	}catch(e){
		
	}
	
	
	
	
	
	
	// initialize form tabs
	// active tab can be changed through class="selected" on desired tab-link 
	if ($("#content #tabs-account-management").idTabs)
		$("#content #tabs-account-management").idTabs(); 

	// bind click function on news-config-selection
	$("input:radio[@name=profile_news_type]").click(function() {
		
		/*Fehlerfeldkorrektur - Profile*/
		errorheightProfile = $("#error-msg-profile").height()+17;
		if (errorheightProfile == 17) errorheightProfile = 0;
		topPositionProfile = errorheightProfile+557+$('#member-info-profile-news').height()+"px";
		bottomPositionProfile = errorheightProfile+857+$('#member-info-profile-news').height()+"px";
		
		if ( $(this).val() == '3' ) {
	    	$("#news-individual").slideDown();
	    	$("#profile-upload-form-wrapper").animate({"top": bottomPositionProfile});
		} else { 
	    	$("#news-individual").slideUp();
	    	$("#profile-upload-form-wrapper").animate({"top": topPositionProfile});
		}
	}); 
	
	$('.toggle-container').click(function() {
		if (!expanded_height_profile_news){
			expanded_height_profile_news	=	$('#news-list-container').height()+20;
		}
		
		if (!$('.toggle-container').hasClass("expanded")){
			$("#profile-upload-form-wrapper").animate({"top": $("#profile-upload-form-wrapper").offset().top-expanded_height_profile_news+"px"});
		}else{
			$("#profile-upload-form-wrapper").animate({"top": $("#profile-upload-form-wrapper").offset().top+expanded_height_profile_news+"px"});
		}
			
		
		
	});

});

function count(e) {

	if (!e.which) keyCode = event.keyCode; // ie5+ op5+
	else keyCode = e.which; // nn6+
	
	
	$("#news-text-count").text(max-document.form_account_profile.profile_news_text.value.length);
	
}


function popupWin(url, title, options, error){
	var neuesFenster = window.open( url, title, options );

	if(typeof neuesFenster == 'undefined')
	{
		
		neuesFenster = window.open('', title, options);
		
		try{
			neuesFenster.location.href = url;
		}catch(ex){
			alert(error);
		}finally{
			
		}

		
		
		
	}
	
	neuesFenster.focus();
}



