jQuery.fn.traveline = function(formName, config) {
    /*
    if (this.length == 0) return this;
    
    var self = this, defaults = {
        serverPath: "http://www.travelinescotland.com",
        skinPath: "skins/clean"
    };
    
    function init() {
        var form = new PageLanderTemplate();
        if (typeof config == 'function') {
            config(form);
        } else {
            jQuery.extend(form, defaults, config || {});
        }
        self.html(form.getReplacedSource());
        PageLanderSetupDateTimeInputs(formName);
    }
    
    if (typeof PageLanderTemplate == 'undefined') {
        var script = document.createElement('script');
        script.onload = init;
        script.setAttribute('type', 'text/javascript');
        script.setAttribute('src', 'http://www.travelinescotland.com/servlet/pageLanderScripts');
        document.body.appendChild(script);
    } else {
        init();
    }
    
    return this;
	*/
    
};

jQuery.pngfix = function() {
    
    if (jQuery.IE6 && (document.body.filters)) 
    {
       for(var i=0; i<document.images.length; i++)
       {
          var img = document.images[i]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
          {
             var imgID = (img.id) ? "id='" + img.id + "' " : ""
             var imgClass = (img.className) ? "class='" + img.className + "' " : ""
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle
             if (img.align == "right") imgStyle = "float:right;" + imgStyle
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
             var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
             img.outerHTML = strNewHTML
             i = i-1
          }
       }
    }
    
}

$(function() {
    
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    $.IE  = version > 0;
    $.IE6 = version >= 5.5 && version < 7;
    
    $.pngfix();
    
	$('input').each(function() { $(this).addClass(this.type); });
	$('.rollover').simpleImageRollover();
	
	$('#prison-directions').traveline('journeyPlannerForm:6', {
	    type: 6, locationName: 'null', locationEasting: null,
	    locationNorthing: null, isLocality: false
	});
	
	
	/*
	if (!$.IE6) {
	    var $quote = $('#banner-text .quote:first');
    	if ($quote.length > 1) {
    	    setInterval(function() {
    	        if ($.IE) {
    	            $quote.hide().remove().appendTo('#banner-text');
    	            $quote = $('#banner-text .quote:first').show();
    	        } else {
    	            $quote.fadeOut(function() {
                        $(this).remove().appendTo('#banner-text');
                        $quote = $('#banner-text .quote:first').fadeIn();
                    });
    	        }
    	    }, 5000);
        }
	}
	*/

	$(window).scroll(function() {
	
		var $left = $('#left'),
				lHeight = $left.height(),
				mHeight = $('#main').height(),
				maxScroll = mHeight - lHeight;	
	    var scrollTop = $(document).scrollTop();
	    var padding = Math.max(0, Math.min(scrollTop - 490, maxScroll));
	    $left.stop().animate({paddingTop: padding});
    });
	
	
	
	// Overlabel forms
	$('label.overlabel').overlabel();
	
	
    
});
