$(document).ready(function(){
	changeTextColor();
	initFancyBox();
	removeAsterix();
	initRegForm();
});


initRegForm = function(){
	
	if($('#title_Interestedparty').length > 0 && $('#ersserial').length){
		$('#title_Interestedparty').click(function(){
			$('#ersserial').hide("slow");				
			$("label[for='ersserial']").hide("slow");
			$('#ersserial').val("empty");				
		});	
	}
	
	if($('#title_Existingcustomer').length > 0 && $('#ersserial').length){
		$('#title_Existingcustomer').click(function(){
			$('#ersserial').show("slow");
			$("label[for='ersserial']").show("slow");	
			$('#ersserial').val("");					
		});	
	}	
}

removeAsterix = function(){
	if($('.errorMessages').length > 0){
		$('.wglErrorMessage').each(function(){
			var text = $(this).text();
			text = text.replace(/\*/,"");
			$(this).text("");
			$(this).append(text);
		});
	}
}

changeTextColor = function(){
	var form = $('.elementForm');
	if(form.length > 0){
		$('.elementForm label').each(function(){
			var text = $(this).text();
			text = text.replace(/\*/,"<span class='pflichfeld'>*</span>");
			$(this).text("");
			$(this).append(text);
		});
	}
}

initFancyBox = function(){
	
	$('.slideshow-link').fancybox({
		padding:		0,
		titleShow:		false,
		width:			730,
		height:			396,
		autoDimensions: false,
		scrolling:		'no',
		showCloseButton: true,
		onComplete		: function(){
			
		}
	});
}

closeFancyBox = function(){
	$.fancybox.close();
}


openUrlBlank = function(href){

  if(location.pathname.indexOf('/weblication/grid5/') != 0 && href != ""){
    window.open(href);
  }
}

