/*
 * Jaba common library for jQuery 0.5.2
 *
 * Copyright (c) 2007 Jaba Multimedia (www.jaba.com.au)
 * Built upon jQuery 1.1.3.1 (http://jquery.com)
 * 
 * [Expected HTML structure for this control]
    <script type="text/javascript">
        $(function(){
            $('div.section').JabaToolTip({});
        });
    </script>
    
    
 *
 */
jQuery(document).ready(function() {
  $("img[swapimage], input[swapimage]").JabaSwapImage({});
});

(function($){

    // main initializer
    $.fn.JabaSwapImage = function(settings) {  
//        var m_config = {
//                suffix : "Over"
//            };
//            
//        m_config = $.extend(m_config, settings); 
        
        function swapimage(obj)
        {
//            var options = {};
//            eval('options = ' + $(obj).attr("jconfig")); 
//            options = $.extend($.extend({}, m_config), options); 
//            
            if($(obj).attr("src") == obj.$src)
                $(obj).attr("src", $(obj).attr("swapimage"));
            else
                $(obj).attr("src", obj.$src);
        }
           
	    return this.each(function(){
            // main logic
            
            this.$src = $(this).attr("src");

            $(this).hover(
                function(e) {
                    swapimage(this);
                }, 
                function(e) {
                    swapimage(this);
                });
	    });

    }
   
    $.msgBox = function(message, buttons, options) {
        var options = $.extend({}, options); 
        var html = "<div id='";
        html += "TB_window";
        html += "'>";
        html += message;
        html += "</div>";
        alert(html);
        
    }   
    
})(jQuery);

/*
 * jQuery Impromptu
 * By: Trent Richardson [http://trentrichardson.com]
 * Version 1.0
 * Last Modified: 9/6/2007
 * 
 * Copyright 2007 Trent Richardson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
jQuery.extend({	
	ImpromptuDefaults: { prefix:'jqi', buttons:{ Ok:true }, submit:function(){return true;}, callback:function(){}, container:'body', opacity:0.6, overlayspeed:'slow', promptspeed:'fast', show:'show'},
	SetImpromptuDefaults: function(o){ 
		jQuery.ImpromptuDefaults = jQuery.extend({},jQuery.ImpromptuDefaults,o);
	},
	prompt: function(m,o){
		o = jQuery.extend({},jQuery.ImpromptuDefaults,o);
		
		var ie6 = (jQuery.browser.msie && jQuery.browser.version < 7);	
		var b = jQuery(o.container);		
		var fade = '<div class="'+ o.prefix +'fade" id="'+ o.prefix +'fade"></div>';
		var msgbox = '<div class="'+ o.prefix +'" id="'+ o.prefix +'"><div class="'+ o.prefix +'container"><div class="'+ o.prefix +'message">'+ m +'</div><div class="'+ o.prefix +'buttons" id="'+ o.prefix +'buttons">';
		jQuery.each(o.buttons,function(k,v){ msgbox += '<button name="'+ o.prefix +'button'+ k +'" id="'+ o.prefix +'button'+ k +'" value="'+ v +'">'+ k +'</button>'}) ;
		msgbox += '</div></div></div>';
		
		var jqi = b.prepend(msgbox).children('#'+ o.prefix);
		var jqif = b.prepend(fade).children('#'+ o.prefix +'fade');
				
		if(ie6) b.css({ overflow: "hidden" }).find("select").css({ visibility: "hidden" });//ie6
		jqif.css({ height: b.height(), width: b.width(), position: "absolute", top: 0, left: 0, right: 0, bottom: 0, zIndex: 998, display: "none", opacity: o.opacity });
		jqi.css({ position: (ie6)? "absolute" : "fixed", top: "30%", left: "50%", display: "none", zIndex: 999, marginLeft: ((((jqi.css("paddingLeft").split("px")[0]*1) + jqi.width())/2)*-1) });
		
		jQuery('#'+ o.prefix +'buttons').children('button').click(function(){ 
			var msg = jqi.children('.'+ o.prefix +'container').children('.'+ o.prefix +'message');
			var clicked = o.buttons[jQuery(this).text()];	
			if(o.submit(clicked,msg)){		
				jqi.remove(); 
				jqif.fadeOut(o.overlayspeed,function(){
					jqif.remove();
					if(ie6) b.css({ overflow: "auto" }).find("select").css({ visibility: "visible" });//ie6
					o.callback(clicked,msg);
				});
			}
		});
		
		jqif.fadeIn(o.overlayspeed);
		jqi[o.show](o.promptspeed);
		return jqi;	
	}	
});


/**
 * 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') { // name and value given, set cookie
        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(); // use expires attribute, max-age is not supported by IE
        }
        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 { // only name given, get cookie
        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]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


(function($){
    $.flashWrite = function(url, w, h, settings)
    {
		var protocol = (window.location.protocol == "https:" ? "https:" : "http:");
        if (typeof(settings) == "undefined" || settings == null) settings = {};
        settings = $.extend({
                vmode : 'opaque'
            }, settings);
        var flashStr = 
        "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " +      
        "    codebase='" + protocol + "//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' " +
        "    width='" + w + "' height='" + h + "'> " +
        "    <param name='movie' value='" + url + "'>  " +
        "    <param name='quality' value='high'> " +
        "    <param name='wmode' value='" + settings.vmode + "'> " +
        "    <param name='menu' value='false'> " +
        "    <!--[if !IE]> <--> " +
        "    <object data='" + url + "' " +
        "        width='" + w + "' height='" + h + "' type='application/x-shockwave-flash'> " +
        "        <param name='quality' value='high'> " +
        "        <param name='wmode' value='" + settings.vmode + "'> " +
        "        <param name='menu' value='false'> " +
        "        <param name='pluginurl' value='" + protocol + "//www.macromedia.com/go/getflashplayer'> " +
        "        FAIL (the browser should render some flash content, not this). " +
        "    </object> " +
        "    <!--> <![endif]--> " +
        "</object> ";
        //document.getElementById("flashObj").innerHTML = flashStr;
        document.write(flashStr);
    }
})(jQuery);