
/* f$ = jQuery
 *
 * will be set automatically by f$load in compatible mode with other libraries
 */

var f$ = 0;

/* jQuery fixes
 *
 */

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[@src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});

		//fix input with png-source
		jQuery(this).find("input[@src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});

	}

	return jQuery;

};

/* fixes Cleartype bug of IE with jQuery opacity:"show" */

jQuery.fn.f$_animate = jQuery.fn.animate;

jQuery.fn.animate = function() {

  if (arguments.length)
    if (jQuery.browser.msie) {

      callback = arguments[arguments.length - 1];

      var opac = false;
      var prop = arguments[0];
	  for ( p in prop )
		if (( p == "opacity") &&
		    ((prop[p] == "show") || (prop[p] == "toggle") )) {
		  opac = true;
		  break;
		};

      // if IE and opacity:"show", add remove filter to callback

      if (opac) {

        var newcallback = function() {
          this.style.removeAttribute('filter');
          if (jQuery.isFunction(callback))
            callback();
        };

        return this.f$_animate(
          arguments[0],
          arguments.length > 1 ? arguments[1] : 0,
          arguments.length > 2 ? arguments[2] : "swing",
          newcallback
        );

      };
  };

  // nothing to do, call original function
  return this.f$_animate.apply( this, arguments );

};

/* f$...
 *
 * additional scripts
 */

var f$animatedCollapse = 0; // fganimatedcollapse.js

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};

/* f$scrollTo
 *
 * scrolls whatE (default window) to scrollE in animation queue of queueE
 */

var f$scrollTo = function (scrollE, queueE, whatE) {

  if (!whatE)
    whatE = 'html,body';
  if (!queueE)
    queueE = scrollE;

  f$(queueE).queue(function () {
    f$(whatE).animate({scrollTop: f$(scrollE).offset().top }, 1000);
    f$(this).dequeue();
  });

};

/* f$load = Library loader with core event registration
 *
 * will bind f$ to jQuery and load other libraries
 * will call your event funtions for DOM and WINDOW loaded (after all libraries are in)
 *
 * USE: (watch sequence of with and register!)
 *  f$load.withScriptaculous();
 *  f$load.withScript('/javascript/coolnavigation.js');
 *  f$load.withScript('/javascript/specialeffect.js');
 *  f$load.registerDOMloaded( function () { // prepare the real cool stuff // });
 *  f$load.registerWINDOWloaded( function () { // excecute the real cool stuff // });
 */
var f$load = {

  _init: function() {
    // the very,very first thing to do is to register the event handlers
    // in case we do this too late, we will loose those events (critical on small pages)
    jQuery(document).ready(f$load._triggerDOMloaded);
    jQuery(window).bind('load', f$load._triggerWINDOWloaded);
    // now bind f$ to jQuery, so the other libraries may be loaded
    f$ = jQuery.noConflict();
    // set browserIE5
    f$load.browserIE5 = f$.browser.msie && (f$.browser.version < 6);
    f$load.browserIE6 = f$.browser.msie && (f$.browser.version < 7);
  },
  _location: "/frescogatejs",
  setPath: function(path) {
    f$load._location = path;
  },

  // onDOMloaded will be called, if
  // - all libraries and additional plugins are loaded
  // - jQuery.ready fired
  // it will fire on registerDOMloaded if this state it reached
  _onDOMloaded: function(){},
  registerDOMloaded: function(onDOMloaded) {
    f$load._onDOMloaded = onDOMloaded;
    f$load._testDOMloaded(true);
  },
  // utilities for DOM loaded
  _firedDOMloaded: false,
  _testDOMloaded: function(fire) {
  	if (f$load._triggerLIB)
  	if (f$load._triggerSCRIPT)
  	if (f$load._triggerDOM) {
  	  if (fire && !f$load._firedDOMloaded) {
  	    f$load._PNGFixLoaded.apply();
        f$load._AnimatedCollapseLoaded.apply();
  		f$load._onDOMloaded.apply();
  		f$load._firedDOMloaded = true;
  		f$load._testWINDOWloaded();
  	  };
  	  return true;
  	};
  	return false;
  },
  _triggerDOM: false,
  _triggerDOMloaded: function() {
    f$load._triggerDOM = true;
    f$load._testDOMloaded(true);
  },

  // onWINDOWloaded will be called, if
  // - onDOMloaded has been called (all libraries are loaded)
  // - window.load fired
  // it will fire on registerWINDOWloaded if this state it reached
  _onWINDOWloaded: function(){},
  registerWINDOWloaded: function(onWINDOWloaded) {
    f$load._onWINDOWloaded = onWINDOWloaded;
    f$load._testWINDOWloaded();
  },
  // utilities for DOM loaded
  _testWINDOWloaded: function() {
  	if (f$load._firedDOMloaded) // libraries loaded? &&
  	if (f$load._triggerWINDOW) { // window.load fired
  	  f$load._onWINDOWloaded.apply();
  	};
  },
  _triggerWINDOW: false,
  _triggerWINDOWloaded: function() {
    f$load._triggerWINDOW = true;
    f$load._testWINDOWloaded();
  },

  // load Javascript Extensions Libraries
  _triggerLIB: false,
  _triggerLIBloaded: function() {
    f$load._triggerLIB = true;
    f$load._testDOMloaded(true);
  },
  withJQuery: function() {
    // nothing to do except trigger load event
    f$load._triggerLIBloaded.apply();
  },
  withScriptaculous: function() {
    google.load("prototype", "1.6");
    google.load("scriptaculous", "1.8");
    google.setOnLoadCallback(f$load._triggerLIBloaded);
  },
  withMootools: function() {
    // not tested
    google.load("mootools", "1.11");
    google.setOnLoadCallback(f$load._triggerLIBloaded);
  },
  withDojo: function() {
    // not tested
    google.load("dojo", "1.1");
    google.setOnLoadCallback(f$load._triggerLIBloaded);
  },

  // load javascript extensions
  _SCRIPTqueue: new Array(),
  _triggerSCRIPT: true,
  _triggerSCRIPTloaded: function() {
    var url = f$load._SCRIPTqueue.shift();
    if (url) {
      jQuery.getScript(url, f$load._triggerSCRIPTloaded);
    } else {
      // all scripts loaded, document ready?
      f$load._triggerSCRIPT = true;
      f$load._testDOMloaded(true);
    };
  },
  withScript: function(url) {
    f$load._triggerSCRIPT = false;
    f$load._SCRIPTqueue.push(url);
    f$load._triggerSCRIPTloaded.apply();
  },

  // load special effects (that need special inits/loader)

  // animated collapse
  _AnimatedCollapseAddDiv: function() {},
  _AnimatedCollapseLoaded: function() {
    // this is called after DOM load
    if (f$animatedCollapse) {
      f$load._AnimatedCollapseAddDiv.apply();
      f$animatedCollapse.init();
    };
  },
  withScriptAnimatedCollapse: function(addDIV) {
    f$load._AnimatedCollapseAddDiv = addDIV;
    f$load.withScript(f$load._location+"/fganimatedcollapse.js");
  },
  // png fix
  _PNGFixLoaded: function() {}, // called after DOM loaded
  withPNGFix: function () {
  /* doesnt work?
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (jQuery.browser.msie && (ie55 || ie6))
      f$load._PNGFixLoaded = function() { jQuery(document).pngFix(); };
  */
  },
  // jQuery UI
  _withUIcore: false,
  withUI: function() {
    if (!f$load._withUIcore)
      f$load.withScript(f$load._location+"/ui/ui.core.js");
    f$load._withUIcore = true;
  },
  // jQuery Easing
  _withEasing: false,
  withEasing: function() {
    if (!f$load._withEasing)
      f$load.withScript(f$load._location+"/jquery.easing.1.3.js");
    f$load._withEasing = true;
  },
  // jQuery scroll follow
  withScrollFollow: function() {
    f$load.withEasing();
    f$load.withUI();
    f$load.withScript(f$load._location+"/jquery.scrollfollow.js");
  },

  // jQuery browser
  _withBrowser: false,
  withBrowser: function() {
/*
    if (!f$load._withBrowser)
      f$load.withScript(f$load._location+"/jquery.browser.min.js");
*/
    f$load._withBrowser = true;
  },
  // jQuery flash
  _withFlash: false,
  withFlash: function() {
    if (!f$load._withFlash)
      f$load.withScript(f$load._location+"/jquery.flash.min.js");
    f$load._withFlash = true;
  },
  // jQuery Sifr
  _withSifr: false,
  withSifr: function() {
    if (!f$load._withSifr) {
      f$load.withBrowser();
      f$load.withFlash();
      f$load.withScript(f$load._location+"/jquery.sifr.min.js");
      f$load._withSifr = true;
    };
  }

};
f$load._init();
