/*FUNCTIONS*/

// Global Proerties
var shadermode_op_opacity = 0.7;
var shadermode_op_bg = '#040404';

// alternative color for MacFF2
var shadermode_neutral = 'gray';

$(document).ready(function(){

	$('#menu-1').bgiframe();
	$('#menu-2').bgiframe();
	$('#menu-3').bgiframe();

	// PNG Fix
   	if($.browser.msie && (parseInt($.browser.version) == 6)){
		$(document).pngFix(); 
	}

// Stilfinder
$('div.swf-search-btn a span:contains("Weiter")').click(function(){
	var phyItems = $("#0,#1,#2,#3");
	var phyChecked = 0;
		phyItems.each(function (i) {        
    			if($(this).is(':checked')){
     				phyChecked = 1;
     			}
		});
		if(phyChecked == 0){
			return false;	
		}
});





//SCROLL ITEMS....
$('#scroll').jScrollPane({showArrows:true,wheelSpeed:5} );

//FAQ Finder...
$('#swf-search-form2').click(function(){
        $('#swf-search-form2').val('');
})


$('#swf-shader-close').click(function(){
    $.unblockUI();
})


// Contentbox open/close...
$("#egde-middle-contentbox-open *").bind("mouseenter",function(){
    $('#egde-middle-contentbox').show();
    $('#swf-teaser-arrow').removeClass("swf-teaser-arrow-up");
    $('#swf-teaser-arrow').addClass("swf-teaser-arrow-down");
    $("#egde-middle-contentbox").mouseover(function(){
        $('#egde-middle-contentbox').show();
        });
         }).mouseout(function(){
             $('#egde-middle-contentbox').hide();
             $('#swf-teaser-arrow').removeClass("swf-teaser-arrow-down");
             $('#swf-teaser-arrow').addClass("swf-teaser-arrow-up");
});

	// Textboxes / Areas empty on Click
	$('#swf-search-form').emptyonclick();
	
  	 // Portal Navigation
	// New Navi
		var fu;

		    $('#item1_2, #menu-1').mouseover(function(){
		        clearTimeout(fu);
		        show1_2();
		    });

		    $('#item1_2, #menu-1').mouseout(function(){
		        fu = setTimeout("hide()",200);
		    });

		    $('#item1_3, #menu-2').mouseover(function(){
		        clearTimeout(fu);
		        show1_3();
		    });

		    $('#item1_3, #menu-2').mouseout(function(){
		        fu = setTimeout("hide()",200);
		    });

		    $('#item1_4, #menu-3').mouseover(function(){
		        clearTimeout(fu);
		        show1_4();
		    });

		    $('#item1_4, #menu-3').mouseout(function(){
		        fu = setTimeout("hide()",200);
		    });
 
 	$(".hotspot").bind("mouseover",function(){
		$(".hotspot_content").hide();
		$(this).next(".hotspot_content").show();
	});
	$(".hotspot_content").bind("mouseleave",function(){ $(this).hide(); });
	
 	$(".swf-rightmenu").bind("mouseover",function(){
		$(".matrix-teaser-content").hide();
		$(this).next(".matrix-teaser-content").show();
	});
	$(".matrix-teaser-content").bind("mouseleave",function(){ $(this).hide(); });
	
 
});

function hide(){
	$("#menu-1").hide();
	$("#menu-2").hide();
	$("#menu-3").hide();
}

function show1_2(){
	$("#menu-1").show();
	$("#menu-2").hide();
	$("#menu-3").hide();
}

function show1_3(){
	$("#menu-1").hide();
	$("#menu-2").show();
	$("#menu-3").hide();
}

function show1_4(){
	$("#menu-1").hide();
	$("#menu-2").hide();
	$("#menu-3").show();
}

function hideSelect() {
    var f = document.forms;
    for(var i=0;i<f.length;i++) {
        for (var j=0; j<f[i].elements.length; j++) {
            if (f[i].elements[j].type == 'select-one' && f[i].elements[j].hide == 'true') {
                f[i].elements[j].style.visibility = 'hidden';
            }
        }
    }
}

function showSelect() {
    var f = document.forms;
    for(var i=0;i<f.length;i++) {
        for (var j=0; j<f[i].elements.length; j++) {
            if (f[i].elements[j].type == 'select-one') {
                f[i].elements[j].style.visibility = 'visible';
            }
        }
    }
}

/*PRODUCTSEARCH*/

$(document).ready(function() {
    setEvents();
      
    //$('div.egde-middle-content-teaser').slideUp("fast"); 
    //edit sb4910 added filter, begin
    $('div.egde-middle-content-teaser').filter(function (index) {return index != 0}).slideUp("fast");    
    //edit sb4910 end     
    $('div.egde-middle-content-teaser-headline').click(function(){
            $('div.egde-middle-content-teaser').slideUp('fast');

            $('[name="swf-teaser-arrow"]').removeClass("swf-teaser-arrow-down");
            $('[name="swf-teaser-arrow"]').removeClass("swf-teaser-arrow-up");
            $('[name="swf-teaser-arrow"]').addClass("swf-teaser-arrow-down");

            $(this).next().slideDown("fast");
    
            if ($(this).find(":last").hasClass("swf-teaser-arrow-down")) {
                    $(this).find(":last").removeClass("swf-teaser-arrow-down");
                    $(this).find(":last").addClass("swf-teaser-arrow-up");
            }	
    });
    
});

function setEvents() {
    $('#tx_swfproductfinder_step1').change(function(){
        getContentAjax('search',true, false);
    });

    $('#tx_swfproductfinder_step2').change(function(){
        getContentAjax('search',true, false);
    });

    $('#tx_swfproductfinder_step3').change(function(){
        getContentAjax('search',true, false);
    });
    $('#tx_swfproductfinder_step4').change(function(){
        getContentAjax('search',true, false);
    });
    $('#tx_swfproductfinder_step5').change(function(){
        getContentAjax('search',true, false);
    });

    // Form submit abfangen...
    $("#product_search").submit(function(){
      return false;
    });
}

// Item/Element blockieren wenn Ajax aufgerufen wird...
function blockItemAjax(block){

    if(block == true){
            $('#swf-master').block({  
                    message: '<p class"bodytext"><img src="fileadmin/templates/img/ajax-loader.gif">&nbsp;&nbsp;Produkte laden</p>',  
                    css: { border: '0px solid #a00', padding: '10px' },
                    applyPlatformOpacityRules: false,
                    overlayCSS:  {  
                    backgroundColor:'#fff',  
                    opacity:        '0.3'} 
            });     
    }
}


// Ajax aufrufe... 
function getContentAjax(cmd,block,reset){
    // Bei Ajax Elemente blocken...
    switch (cmd)
        {
            case "search":
                blockItemAjax(block);
                break;
            default:
                
            break;
        } 
    //blockItemAjax();
    // Form vorbereiten...
    if (!reset)  {
        var postdata = $("#product_search").serialize();
    } else {
        var postdata = '';
    }
    // Ajax...
    $.get("index.php?id=75&no_cache=1&cmd="+cmd +"&"+ postdata, function(data){
        switch (cmd)
        {
            case "search":
                    $("#swf-stage").empty();
                    $("#swf-stage").append(data);
                    setEvents();    
                    $('#swf-master').unblock();
                break;
            default:
                break;
        } 
    });
}

/*FOO*/

function fold_flash(node) {
  $('#'+node).flashZoom('fold');
  }

function unfold_flash(node) {
  $('#'+node).flashZoom('unfold');
  }

function show_flash(node) {
  $('#'+node).flashZoom('show');
  }


//function destroy_flash() {}

/*FLASHZOOM*/

jQuery.fn.flashZoom = function(action) {

  var defaults = {
      version : 8
      }

  var element = $(this) //.attr('id')
  var node = $(this).attr('id')
  options = eval(node+'_opts')
  var opts = $.extend(defaults, options);
  var flash = $('#' + opts.flash_id);
  
  if (action == 'show') show_flash()
  else if (action == 'fold') open_flash()
  else if (action == 'unfold') close_flash()

  //alert(action);
  function show_flash() {
    if($.browser.msie){
        var so = new SWFObject(opts.flash_url, opts.flash_id, opts.width, opts.height, opts.version, "#ffffff");
        so.addParam("allowScriptAccess", "always");
        so.addParam("scale", "noscale");
        so.addParam("salign", "lt");
        //so.addParam("wmode","opaque");
        so.addParam("align", "middle");
        so.write($(element).attr('id'));
        $(element).addClass('funfolded');
    }else{
        var so = new SWFObject(opts.flash_url, opts.flash_id, opts.width, opts.height, opts.version, "#ffffff");
        so.addParam("allowScriptAccess", "always");
        so.addParam("scale", "noscale");
        so.addParam("salign", "lt");
        so.addParam("wmode","opaque");
        so.addParam("align", "middle");
        so.write($(element).attr('id'));
        $(element).addClass('funfolded');
    }
    
    }

    function close_flash(){
        if ($.browser.msie) {
            closeMsie();
        }

        if ($.browser.safari) {
            closeSafari();
        }

        if ($.browser.mozilla) {
            closeMozilla();
        }
    }


    function closeMsie(){
        $(flash).attr('wmode','opaque');
        $('#splash').remove();
        $(flash).attr('width', opts.width);
        $(flash).attr('height', opts.height);
        $(element).css('top', '0');
        $(element).css('left', '0');
        $(element).css('width', opts.width);
        $(element).css('height', opts.height);
        $(element).removeClass('ffolded');
        $(element).addClass('funfolded');
        $('html').css('overflow', 'auto');

        return false;
    }

    function closeSafari(){
        $('#splash').remove();
        $(flash).attr('width', opts.width);
        $(flash).attr('height', opts.height);
        $(element).css('top', '0');
        $(element).css('left', '0');
        $(element).css('width', opts.width);
        $(element).css('height', opts.height);
        $(element).removeClass('ffolded');
        $(element).addClass('funfolded');
        //$('html').css('overflow', 'auto');

        return false;
    }

    function closeMozilla(){
        $('#splash').remove();
        $(flash).attr('width', opts.width);
        $(flash).attr('height', opts.height);
        $(element).css('top', '0');
        $(element).css('left', '0');
        $(element).css('width', opts.width);
        $(element).css('height', opts.height);
        $(element).removeClass('ffolded');
        $(element).addClass('funfolded');
       // $('html').css('overflow', 'auto');
        
        return false;
    }

    function open_flash(){
        if ($.browser.msie) {
            if($.browser.version == '6.0'){
                openMsie6();
            }else{
                openMsie();
            }
        }

        if ($.browser.safari) {
            openSafari();
        }

        if ($.browser.mozilla) {
            openMozilla();
        }
    }

function openMsie6(){
      //  $(flash).attr("wmode","");
        $('body').prepend('<div id="splash"></div>');
        var temp = $('div.tx-lxsces-pi6 #'+opts.parent_id).parent();
        var temp2 = $(temp).parent();
        //$(temp2).prependTo('#splash');
        $('html').css('overflow', 'hidden');
        $('#splash').css('top', '0px');
        $('#splash').css('left', '0px');
        $('#splash').css('position', 'absolute');
        $('#splash').css('zIndex', '1');
        $('#splash').css('width', '100%');
        $('#splash').css('height', '100%');

        var d = detectBadOpacity();
        if (d) {
            $('#splash').css('background', shadermode_neutral);
        } else {
            $('#splash').css('opacity', shadermode_op_opacity);
            $('#splash').css('background', shadermode_op_bg);
        }

 //       $('#splash').css('opacity', shadermode_op_opacity);

        $(element).css('width', opts.widthZoom);
        $(element).css('height', opts.heightZoom);
        $(flash).attr('width', opts.widthZoom);
        $(flash).attr('height', opts.heightZoom);

        var offsets = getPosition($(element).attr('id'));
        var vanillaLeft = (($(window).width() - (opts.widthZoom)) / 2),
            vanillaTop = (($(window).height() - (opts.heightZoom)) / 2);

        var resultLeft = vanillaLeft + $(window).scrollLeft() - offsets[0],
            resultTop = vanillaTop + $(window).scrollTop() - offsets[1];

        $(element).css('top', resultTop);
        $(element).css('left', resultLeft);
        $(element).removeClass('funfolded');
        $(element).addClass('ffolded');



    return false;
    }
 
    function openMsie(){
//        $(flash).flash({ params: {wmode : "window"} });
        $('body').append('<div id="splash"></div>');
        var temp = $('div.tx-lxsces-pi6 #'+opts.parent_id).parent();
        var temp2 = $(temp).parent();
        //$(temp2).prependTo('#splash');
        $('html').css('overflow', 'hidden');
        $('#splash').css('top', '0px');
        $('#splash').css('left', '0px');
        $('#splash').css('position', 'absolute');
        $('#splash').css('zIndex', '1');
        $('#splash').css('width', '100%');
        $('#splash').css('height', '100%');

        var d = detectBadOpacity();
        if (d) {
            $('#splash').css('background', shadermode_neutral);
        } else {
            $('#splash').css('opacity', shadermode_op_opacity);
            $('#splash').css('background', shadermode_op_bg);
        }

        $(element).css('width', opts.widthZoom);
        $(element).css('height', opts.heightZoom);
        $(flash).attr('width', opts.widthZoom);
        $(flash).attr('height', opts.heightZoom);

        var offsets = getPosition($(element).attr('id'));
        var vanillaLeft = (($(window).width() - (opts.widthZoom)) / 2),
            vanillaTop = (($(window).height() - (opts.heightZoom)) / 2);

        var resultLeft = vanillaLeft + $(window).scrollLeft() - offsets[0],
            resultTop = vanillaTop + $(window).scrollTop() - offsets[1];

        $(element).css('top', resultTop);
        $(element).css('left', resultLeft);
        $(element).removeClass('funfolded');
        $(element).addClass('ffolded');

        

    return false;
    }

    function openSafari(){
        $('body').append('<div id="splash"></div>');
        $('#splash').css('width', '100%');
        $('#splash').css('height', '100%');
        $('html').css('overflow', 'hidden');

        var d = detectBadOpacity();
        if (d) {
            $('#splash').css('background', shadermode_neutral);
        } else {
            $('#splash').css('opacity', shadermode_op_opacity);
            $('#splash').css('background', shadermode_op_bg);
        }

        $(element).css('width', opts.widthZoom);
        $(element).css('height', opts.heightZoom);
        $(flash).attr('width', opts.widthZoom);
        $(flash).attr('height', opts.heightZoom);

        var offsets = getPosition($(element).attr('id'));
        var vanillaLeft = (($(window).width() - (opts.widthZoom)) / 2),
            vanillaTop = (($(window).height() - (opts.heightZoom)) / 2);
        var resultLeft = vanillaLeft + $(window).scrollLeft() - offsets[0],
            resultTop = vanillaTop + $(window).scrollTop() - offsets[1];

        $(element).css('top', resultTop);
        $(element).css('left', resultLeft);

        $(element).removeClass('funfolded');
        $(element).addClass('ffolded');

        return false;
    }

    function openMozilla(){
        $('body').append('<div id="splash"></div>');
        $('#splash').css('width', '100%');
        $('#splash').css('height', '100%');
        
        var d = detectBadOpacity();
        if (d) {
            $('#splash').css('background', shadermode_neutral);
        } else {
            $('#splash').css('opacity', shadermode_op_opacity);
            $('#splash').css('background', shadermode_op_bg);
        }

        $(element).css('width', opts.widthZoom);
        $(element).css('height', opts.heightZoom);
        $(flash).attr('width', opts.widthZoom);
        $(flash).attr('height', opts.heightZoom);

        var offsets = getPosition($(element).attr('id'));
        var vanillaLeft = (($(window).width() - (opts.widthZoom)) / 2),
            vanillaTop = (($(window).height() - (opts.heightZoom)) / 2);
        var resultLeft = vanillaLeft + $(window).scrollLeft() - offsets[0],
            resultTop = vanillaTop + $(window).scrollTop() - offsets[1];

        $(element).css('top', resultTop);
        $(element).css('left', resultLeft);

        $(element).removeClass('funfolded');
        $(element).addClass('ffolded');

        return false;
    }

    function getPosition(id){
        ele = document.getElementById(id)
        var topValue= 0,leftValue= 0;
        while(ele){
            leftValue += ele.offsetLeft;
            topValue += ele.offsetTop;
            ele = ele.offsetParent;
        }
        result = new Array(leftValue, topValue);
        return result;
    }

    // this will catch MacFF2
    // special to raise no-opacity case
    function detectBadOpacity() {
        var userAgent = navigator.userAgent.toLowerCase();
        if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
            var ffversion = new Number(RegExp.$1);
            if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
                return true;
            }
        }
    }

}

/*SHOPFINDER*/

$(document).ready(function(){
    $('#tx_swfshopfinder_pi1_form *').keypress(function (e) {
        if(e.which == 13){
                 $('#tx_swfshopfinder_pi1_cmd').val('true');
                $('#tx_swfshopfinder_pi1_form').submit();
        }
    })
});

/*ROUTENPLANER*/

$(document).ready(function(){
   var routeMainParams;
//   $('#scroll').jScrollPane();

});
 

function startRoute(routeParams){
    routeMainParams = routeParams;
    var routeFormValues = $('#tx_swfshopfinder_pi1_formroute').serialize();
    
    var paramsSplit = routeMainParams.split('&');
    var pi1_routeX = paramsSplit[1].split('=');
    var pi1_routeY = paramsSplit[2].split('=');
    var pi1_routeStreet = paramsSplit[3].split('=');
    var pi1_routeNr = paramsSplit[4].split('=');
    var pi1_routeKdnr = paramsSplit[5].split('=');

    routeShaderDefault('shader_route');
    $.blockUI({ message: $('#shader_route')});


    //$.get('http://www.schoenerwohnenfarbe.de/haendler/route.php?x_pos='+pi1_routeX[1]+'&y_pos='+pi1_routeY[1]+'&str='+pi1_routeStreet[1]+'&kdnr='+pi1_routeKdnr[1]+'&s1=1&s2=1&s3=1&s4=1&s5=1&s6=1&s7=1&s8=1&s9=1');
    $('#ajaxWait').css("visibility","visible");
    $.get('index.php?id=121&no_cache=1&x_pos='+pi1_routeX[1]+'&y_pos='+pi1_routeY[1]+'&str='+escape(pi1_routeStreet[1]+' '+pi1_routeNr[1])+'&kdnr='+pi1_routeKdnr[1]+'&s1=1&s2=1&s3=1&s4=1&s5=1&s6=1&s7=1&s8=1&s9=1', function(data){
        
     
        $('#map').html(data);

        $('#ajaxWait').css("visibility","hidden");
    });

}
function routeSubmit(routeParams){
    routeMainParams = routeParams;
    var paramsSplit = routeParams.split('&');
    var pi1_routeName = paramsSplit[7].split('=');
    var pi1_routeStreet = paramsSplit[3].split('=');
    $('#tx_swfshopfinder_pi2_routeto h4').html(pi1_routeName[1]);
    routeShaderDefault('shader_route');
    $.blockUI({ message: $('#shader_route')});


}

function setContainerSize(divItem){
    var formWidthPX = $('#'+divItem).css("width");
    var formHeightPX = $('#'+divItem).css("height");
    var formWidth = formWidthPX.split('p');
    var formHeight = formHeightPX.split('p');
    var element = $(divItem) //.attr('id')
    var fhoehe = ((Fensterhoehe()/2)-(formHeight[0]/2));
    var fweite = ((Fensterweite()/2)-(formWidth[0]/2));
    var containerSize;

    return containerSize = new Array(fhoehe,fweite);
}

function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function routeShaderDefault(divItem){

    var containerSize = setContainerSize(divItem);

    // override these in your code to change the default behavior and style
    $.blockUI.defaults = {
        // message displayed when blocking (use null for no message)
        message:  '<h1>Please wait...</h1>',

        // styles for the message when blocking; if you wish to disable
        // these and use an external stylesheet then do this in your code:
        // $.blockUI.defaults.css = {};
        css: {
            padding:        0,
            margin:         0,
            top:            containerSize[0],
            left:           containerSize[1],
            textAlign:      'center',
            color:          '#000',
            border:         '0px solid #aaa',
            backgroundColor:'#fff',
            cursor:         'default'
        },

        // styles for the overlay
        overlayCSS:  {
            backgroundColor:'#000',
            opacity:        '0.3'
        },

        // z-index for the blocking overlay
        baseZ: 1000,

        // set these to true to have the message automatically centered
        centerX: true, // <-- only effects element blocking (page block controlled via css above)
        centerY: true,

        // allow body element to be stetched in ie6; this makes blocking look better
        // on "short" pages.  disable if you wish to prevent changes to the body height
        allowBodyStretch: true,

        // be default blockUI will supress tab navigation from leaving blocking content;
        constrainTabKey: true,

        // fadeIn time in millis; set to 0 to disable fadeIn on block
        fadeIn:  200,

        // fadeOut time in millis; set to 0 to disable fadeOut on unblock
        fadeOut:  400,

        // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
        timeout: 0,

        // disable if you don't want to show the overlay
        showOverlay: true,

        // if true, focus will be placed in the first available input field when
        // page blocking
        focusInput: true,

        // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
        applyPlatformOpacityRules: true,

        // callback method invoked when unblocking has completed; the callback is
        // passed the element that has been unblocked (which is the window object for page
        // blocks) and the options that were passed to the unblock call:
        //     onUnblock(element, options)
        onUnblock: null,

        // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
        quirksmodeOffsetHack: 4
    };



}

/*CONTACTFORM*/

$(document).ready(function() {
    $("input").keypress(function (e) {
                            var inputId = $(this).attr("id");
                            if(inputId == 'contactform_plz' || inputId == 'contactform_city'){
                                                         var inputId = 'contactform_plz_city';                   
                            }
                            var inputId_ext = '_lbl';
                            var newInputId = inputId+inputId_ext;
                            $('#'+newInputId).css({color: '#000'});
    });
    
    $("textarea").keypress(function (e) {
                            var inputId = $(this).attr("id");
                            var inputId_ext = '_lbl';
                            var newInputId = inputId+inputId_ext;
                            $('#'+newInputId).css({color: '#000'});
    });
    
    
    $("#submitbtn").click(function() {
        //if($("#contactform").valid() != true){
          //  listErrContact();
        //}
    });
    $("#submitbtn2").click(function() {
        //if($("#contactform").valid() != true){
          //  listErrContact();
        //}
    });

   
    $.validator.setDefaults({submitHandler: function() {
        setBlockUiDefaults('#000')
        jQuery.fn.showshader_485('swf-shader-contact-wait');
		    
	//$('#contactform').submit(function() {
	var postData = $('#contactform').serialize();
	$.get("index.php?id="+pageContactId+"&no_cache=1&"+postData, function(data){
	   jQuery.fn.showshader_485('swf-contactformbig');
        });
        }
    });
    
    $('#submitbtnsuccess').click(function(){
      $.unblockUI();
      window.location.reload();
    })
    
    $('#swfCon-shader-bigclose').click(function(){
       $.unblockUI();
      // window.location.reload()
    })
    
    $('#swfCon-shader-close').click(function(){
	$.unblockUI();
      // window.location.reload()
    })
    
    $('#errorMsgBtn').click(function(fn){
        $('#swfCon-shader-contact').unblock();
    });
    
    $().ready(function() {
            // validate signup form on keyup and submit
            $("#contactform").validate(
				       {
                    rules: {
                            'tx_editcontactform_pi1[contactform_gender]': {
                                    required: true
                            },
                            
                            'tx_editcontactform_pi1[contactform_name]': {
                                    required: true
                            },
                            
                            'tx_editcontactform_pi1[contactform_comments]': {
                                    required: true
                            },
                            
                            'uword': {
                                    required: true
                            },
                            
                            'tx_editcontactform_pi1[contactform_plz]': {
                                    required: false
                            },
                            
                            'tx_editcontactform_pi1[contactform_city]': {
                                    required: false
                            },
                            
                            'tx_editcontactform_pi1[contactform_concerns]': {
                                    required: true
                            },
			    'tx_editcontactform_pi1[contactform_fon]': {
                                    required: true
                            },
                            'tx_editcontactform_pi1[contactform_email]': {
                                    required: true,
                                    email: true
                            }
           },
            errorPlacement: function(error, element) {
                   },
                    messages: {
            
                            'tx_editcontactform_pi1[contactform_gender]': {
                                    required: function errorcss(){
                                                                            $('#contactform_gender_lbl').css({color: '#f00'});
                                                                            $("#errValueGender").val(document.getElementById('contactform_gender_lbl').innerHTML);
                                                    }//contactform_err_gender
                            },
                            
                            'tx_editcontactform_pi1[contactform_name]': {
                                    required: function errorcss(){
                                                                            $('#contactform_name_lbl').css({color: '#f00'});
                                                                            $("#errValueName").val(document.getElementById('contactform_name_lbl').innerHTML);
                                                    }
                            },
                            
                            'tx_editcontactform_pi1[contactform_comments]': {
                                    required: function errorcss(){
                                                          $('#contactform_comments_lbl').css({color: '#f00'});
                                                    }//contactform_err_prename
                            },
                          
                            'uword': {
                                    required: function errorcss(){
                                                          $('#uword').css({bordercolor: '#f00'});
                                                    }//contactform_err_country
                            },
                            
                            'tx_editcontactform_pi1[contactform_plz]': {
                                    required: function errorcss(){
                                                          $('#contactform_plz_city_lbl').css({color: '#f00'});
                                                    }//contactform_err_plz
                            },
                            
                            'tx_editcontactform_pi1[contactform_city]': {
                                    required: function errorcss(){
                                                          $('#contactform_plz_city_lbl').css({color: '#f00'});
                                                    }//contactform_err_city
                            },
                            
                            'tx_editcontactform_pi1[contactform_concerns]': {
                                    required: function errorcss(){
                                                          $('#contactform_conserns_lbl').css({color: '#f00'});
                                                    }//contactform_err_street
                            },
                            'tx_editcontactform_pi1[contactform_fon]': {
                                    required: function errorcss(){
                                                          $('#contactform_fon_lbl').css({color: '#f00'});
                                                    }//added by sb4910
                            },                           
                            'tx_editcontactform_pi1[contactform_email]': {
                                    required: function errorcss(){
                                                          $('#contactform_email_lbl').css({color: '#f00'});
                                                          $("#errValueEmail").val(document.getElementById('contactform_email_lbl').innerHTML);
                                                    },//contactform_err_email_reg
                                    email: function errorcss(){
                                                          $('#contactform_email_lbl').css({color: '#f00'});
                                                    }//contactform_err_email_wrong
                            }
                    
		    }
		    
              });
	    
    }); 

});

function debug(msg) {
    if ($('#debug').length == 0)
        $('body').prepend('<div id="debug"></div>');
        $('#debug').append("<br />" + msg);
}

function startContactform(emailTo){
    $("#swf-shader-btn-right-form").empty();
    document.getElementById('tx_editcontactform_pi1[contactform_emailfromJS]').value = emailTo;
    sjcap("altTextField");
    
    jQuery.fn.showshader('swfCon-shader-contact');
}

function listErrContact(){
   var err = '';
    if($('#errValueGender').val() != ''){
        $('#errValueGender').val($('#errValueGender').val());
      //  $("#errValueGender").val('');
    };
      
    if($('#errValueName').val() != ''){
        $('#errValueName').val($('#errValueName').val());
        //$("#errValueName").val('');
    };

    if($('#errValueEmail').val() != ''){
        $('#errValueEmail').val($('#errValueEmail').val());
        //$("#errValueEmail").val('');
    };
        setBlockUiDefaults('#fff');
        $('#swf-shader-contact').block({ message: $('#swf-shader-contact-mini')}); 
}

function setBlockUiDefaults(blockcolor){
    var resultTopBlock = $("#resultTopBlock").val();
    var resultLeftBlock = $("#resultLeftBlock").val();
    
    $.blockUI.defaults = { 
        // message displayed when blocking (use null for no message) 
        message:  '<h1>Please wait...</h1>', 
         
        // styles for the message when blocking; if you wish to disable 
        // these and use an external stylesheet then do this in your code: 
        // $.blockUI.defaults.css = {}; 
        css: {  
            padding:        0, 
            margin:         0,
            top:            resultTopBlock,  
            left:           resultLeftBlock,  
            color:          '#000',  
            border:         '0px solid #aaa', 
            backgroundColor:'#fff', 
            cursor:         'default' 
        }, 
         
        // styles for the overlay 
        overlayCSS:  {   
            backgroundColor: blockcolor,  
            opacity:        '0.6',
            cursor:         'default'
        }, 
         
        // z-index for the blocking overlay 
        baseZ: 1000, 
         
        // set these to true to have the message automatically centered 
        centerX: true, // <-- only effects element blocking (page block controlled via css above) 
        centerY: true, 
         
        // allow body element to be stetched in ie6; this makes blocking look better 
        // on "short" pages.  disable if you wish to prevent changes to the body height 
        allowBodyStretch: false, 
         
        // be default blockUI will supress tab navigation from leaving blocking content; 
        constrainTabKey: true, 
         
        // fadeOut time in millis; set to 0 to disable fadeout on unblock 
        fadeOut:  400, 
         
        // suppresses the use of overlay styles on FF/Linux (due to significant performance issues with opacity) 
        applyPlatformOpacityRules: true 
    }; 
}

/*TRENDLETTER*/

function startTrendLetter(){
   jQuery.fn.showshader_485('swf-trendletter');
}
$(document).ready(function() {

    $().ready(function() {
        $("#trendletter_shader").validate(
                   {
  submitHandler: function(form) {
        setBlockUiDefaults('#000')
        jQuery.fn.showshader_485('swf-shader-contact-wait');

	var postData = $('#trendletter_shader').serialize();
	$.get("index.php?id="+ pageTrendletterId+"&no_cache=1&"+postData, function(data){
	   jQuery.fn.showshader_485('swf-contactformbig');
        });
  },

rules: {
                        'tx_swftrends_pi3[gender]': {
                                required: true
                        },

                        'tx_swftrends_pi3[name]': {
                                required: true
                        },
                        'tx_swftrends_pi3[email]': {
                                required: true,
                                email: true
                        }
                },
                messages: {

                        'tx_swftrends_pi3[gender]': {
                                required: function errorcss(){
                                            $('#trendletter_gender_lbl').css({color: '#f00'});
                                            $("#errValueGender").val(document.getElementById('trendletter_gender_lbl').innerHTML);
                                          }
                        },

                        'tx_swftrends_pi3[name]': {
                                required: function errorcss(){
                                            $('#trendletter_name_lbl').css({color: '#f00'});
                                            $("#errValueName").val(document.getElementById('trendletter_name_lbl').innerHTML);
                                        }
                        },
                        'tx_swftrends_pi3[email]': {
                                required: function errorcss(){
                                                      $('#trendletter_email_lbl').css({color: '#f00'});
                                                      $("#errValueEmail").val(document.getElementById('trendletter_email_lbl').innerHTML);
                                                },//contactform_err_email_reg
                                email: function errorcss(){
                                                      $('#trendletter_email_lbl').css({color: '#f00'});
                                                }//contactform_err_email_wrong
                        }

                }

          });
    });



});
