/*
  JS Grundfunktionen | � 2009 by www.ssr.co.at
____________________________________________ */

$(document).ready(function(){

	$.fn.SSRScripts = function(settings) {
		settings = jQuery.extend( {

      setupAnimationsZeit: '500' // Durschnittliche Zeit aller Animationen

  	},settings);

// ------------------ HEADER BACKGROUND FADER ---------------------
  	
		$("#imagefader").innerfade({
			speed: 1000,
			timeout: 3000,
			type: 'sequence',
			containerheight: '210px'
		});

// ----------------------- NAV HOVER-EFFECT -----------------------

    $(".nav_pri").hover( function() {

      $(this).find(".pri_a").css('color', '#1a699d');

    }, function() {

      $(this).find(".pri_a").css('color', '#fff');

    });

// --------------------- NAV ACTIVE POSITION ----------------------

    if ( $(".pri_active").length > 0 ) {

      var activePxFromTop = (177-($(".nav_sec", ".pri_active").size()*26))+'px';
      $(".pri_active").css('top', activePxFromTop);
      $(".pri_active").hover( function() {
        return false;
      }, function() {
        return false;
      });

    };

// --------------------- NAV SLIDING-EFFECT -----------------------

    $(".nav_pri").hover( function() {

      var pxFromTop = 178-($(".nav_sec", this).size()*26);
  		$(this).stop().animate({
  			top: pxFromTop
      }, settings.setupAnimationsZeit);

    }, function() {

  		$(this).stop().animate({
  			top: '178px'
      }, settings.setupAnimationsZeit);

    });
    
// --------------------- KONTAKTFORMULAR --------------------------

    // contactform | INPUT, TEXTAREA - Toggle Value on click and check content on blur
    jQuery.fn.DefaultValue = function(text){
      return this.each(function(){
      	// Make sure we're dealing with text-based form fields
      	if(this.type != 'text' && this.type != 'password' && this.type != 'textarea') {
      		return;
        }

      	// Store field reference
      	var fld_current=this;

      	// Set value initially if none are specified
            if(this.value=='') {
      		this.value=text;
      	} else {
      		// Other value exists - ignore
      		return;
      	}

      	// Remove values on focus
      	$(this).focus(function() {
      		if(this.value==text || this.value=='')
      			this.value='';
      	});

      	// Place values back on blur
      	$(this).blur(function() {
      		if(this.value==text || this.value=='')
      			this.value=text;
      	});

      	// Capture parent form submission
      	// Remove field values that are still default
      	$(this).parents("form").each(function() {
      		// Bind parent form submit
      		$(this).submit(function() {
      			if(fld_current.value==text) {
      				fld_current.value='';
      			}
      		});
      	});
      });
    };

    // contactform | VALUE - Set Text
  	$("#name, #vorname, #mail, #firm, #tel").DefaultValue("(Pflichtfeld)");
  	$(".city").DefaultValue("(Beides Pflichtfelder)");
  	$("#nachricht").DefaultValue("Ihre Nachricht ...");
  	
  	$("#last-name, #first-name, #email, #company, #telephone").DefaultValue("(Required)");
  	$("#city").DefaultValue("(Both required)");
  	$("#message").DefaultValue("Your message ...");

// --------------------------- CHECKBOX ---------------------------

    $("#con_right label").click().toggle( function() {
      $(this).css('background', 'url(user/pix/bg_checkbox_h.gif) no-repeat 0 4px #1a699d');
      $(this).prev().attr('checked', 'checked');
    }, function() {
      $(this).css('background', 'url(user/pix/bg_checkbox_n.gif) no-repeat 0 4px #1a699d');
      $(this).prev().attr('checked', '');
    });
    
// ------------------------ REST OF PEACE -------------------------

    $(".contact_box:nth-child(3n)").css('marginRight', '0');

	};

  // Activate SSRScripts if HTML is ready
  $("html").SSRScripts();

});


//
