/* jquery.iframe-post.form.js */
"use strict";(function($){$.fn.iframePostForm=function(options){var contents,elements,element,iframe;elements=$(this);options=$.extend({},$.fn.iframePostForm.defaults,options);if(!$("#"+options.iframeID).length){$("body").append('<iframe name="'+options.iframeID+'" id="'+options.iframeID+'" style="display:none"></iframe>')}return elements.each(function(){element=$(this);element.attr("target",options.iframeID);element.submit(function(){var result=options.post.apply(this);if(result!==true){return false}iframe=$("#"+options.iframeID);iframe.one("load",function(){contents=iframe.contents().find("body");options.complete.apply(this,[contents.html()]);setTimeout(function(){contents.html("")},1)})})})};$.fn.iframePostForm.defaults={iframeID:"iframe-post-form",post:function(){},complete:function(response){}}})(jQuery);

/* jquery.base64.js */
/**
 * jQuery : Encodes and decodes data with MIME base64
 * 
 * Manual :
 * 		This method used for encoding string to base64 and decoding theme and fully supported UTF-8 encoding.
 * 		WARNING : For great supporting in UTF-8 encoding in your page you must put
 * 			<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
 * 		in your head of html tag.
 * 
 * Recommend :
 * 		I'm Iranian programmer. I do not like that the Google code prevent us to access for download jquery in my county ip.
 * 		Please forget the Google code and use Source Forge for coding hosting.
 * 		Thank and good luck. :)
 * 
 * Example :
 * 		<script language="javascript" type="text/javascript">
 *			var mystring = "do me as base64 string\nand new line";
 *			alert(mystring);
 *			alert("base64 of 'mystring' is : " + $.base64_encode(mystring));
 *		</script>
 * 
 * @alias base64
 * @version 1.0
 * @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
 * @author Muhammad Hussein Fattahizadeh <muhammad [AT] semnanweb [DOT] com>
 * 
 * @param {jQuery} {base64_utf8decode:function(input))
 * @param {jQuery} {base64_utf8encode:function(input))
 * @param {jQuery} {base64_encode:function(input))
 * @param {jQuery} {base64_decode:function(input))
 */
(function($){
	var base64_keystring = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	$.extend({
		base64_utf8decode: function(input) {
			var string = "";
			var i = 0;
			var c = 0;
			var c1 = 0;
			var c2 = 0;
			while ( i < input.length ) {
				c = input.charCodeAt(i);
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				} else if ((c > 191) && (c < 224)) {
					c2 = input.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				} else {
					c2 = input.charCodeAt(i+1);
					c3 = input.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
			}
			return string;
		},
		base64_utf8encode: function(input) {
			input = input.replace(/\r\n/g,"\n");
			var output = "";
			for (var n = 0; n < input.length; n++) {
				var c = input.charCodeAt(n);
				if (c < 128) {
					output += String.fromCharCode(c);
				} else if ((c > 127) && (c < 2048)) {
					output += String.fromCharCode((c >> 6) | 192);
					output += String.fromCharCode((c & 63) | 128);
				} else {
					output += String.fromCharCode((c >> 12) | 224);
					output += String.fromCharCode(((c >> 6) & 63) | 128);
					output += String.fromCharCode((c & 63) | 128);
				}
			}
			return output;
		},
		base64_encode: function(input) {
			var output = "";
			var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
			var i = 0;
			input = this.base64_utf8encode(input);
			while (i < input.length) {
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);
				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;
				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}
				output = output + base64_keystring.charAt(enc1) + base64_keystring.charAt(enc2) + base64_keystring.charAt(enc3) + base64_keystring.charAt(enc4);
			}
			return output;
		},
		base64_decode: function(input) {
			var output = "";
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;
			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
			while (i < input.length) {
				enc1 = base64_keystring.indexOf(input.charAt(i++));
				enc2 = base64_keystring.indexOf(input.charAt(i++));
				enc3 = base64_keystring.indexOf(input.charAt(i++));
				enc4 = base64_keystring.indexOf(input.charAt(i++));
				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;
				output = output + String.fromCharCode(chr1);
				if (enc3 != 64) {
					output = output + String.fromCharCode(chr2);
				}
				if (enc4 != 64) {
					output = output + String.fromCharCode(chr3);
				}
			}
			output = this.base64_utf8decode(output);
			return output;
		}
	});
})(jQuery);


/**
* Get CSS
* http://drstonyhills.com/2009/07/06/jquery-getcss/
*/
(function($){
	$.getCSS = function( url, media ){
		$(document.createElement('link') ).attr({
			href: url,
			media: media || 'screen',
			type: 'text/css',
			rel: 'stylesheet'
		}).appendTo('head');
	}
})(jQuery);

// To Use:
// jQuery.getCSS("/my/style/file.css") or
// jQuery.getCSS("/my/style/file.css", "screen");

/**
 * 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
 *
 * URL: http://plugins.jquery.com/files/issues/jjquery.cookie-modified.js_.txt 
*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined'  ||  (name  &&  typeof name != 'string')) { // name and value given, set cookie
        if (typeof name == 'string') {
            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
            }
            // CAUTION: Needed to parenthesize options.path and options.domain
            // in the following expressions, otherwise they evaluate to undefined
            // in the packed version for some reason...
            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;
        } else { // `name` is really an object of multiple cookies to be set.
          for (var n in name) { jQuery.cookie(n, name[n], value||options); }
        }
    } else { // get cookie (or all cookies if name is not provided)
        var returnValue = {};
        if (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 (!name) {
                    var nameLength = cookie.indexOf('=');
                    returnValue[ cookie.substr(0, nameLength)] = decodeURIComponent(cookie.substr(nameLength+1));
                } else if (cookie.substr(0, name.length + 1) == (name + '=')) {
                    returnValue = decodeURIComponent(cookie.substr(name.length + 1));
                    break;
                }
            }
        }
        return returnValue;
    }
};

// http://stackoverflow.com/questions/244758/jquery-animation-smooth-size-transition
// Animates the dimensional changes resulting from altering element contents
// Usage examples: 
//    $("#myElement").showHtml("new HTML contents");
//    $("div").showHtml("new HTML contents", 400);
//    $(".className").showHtml("new HTML contents", 400, 
//                    function() {/* on completion */});
(function($)
{
   $.fn.showHtml = function(html, speed, callback)
   {
      return this.each(function()
      {
         // The element to be modified
         var el = $(this);

         // Preserve the original values of width and height - they'll need 
         // to be modified during the animation, but can be restored once
         // the animation has completed.
         var finish = {width: this.style.width, height: this.style.height};

         // The original width and height represented as pixel values.
         // These will only be the same as `finish` if this element had its
         // dimensions specified explicitly and in pixels. Of course, if that 
         // was done then this entire routine is pointless, as the dimensions 
         // won't change when the content is changed.
         var cur = {width: el.width()+'px', height: el.height()+'px'};

         // Modify the element's contents. Element will resize.
         el.html(html);

         // Capture the final dimensions of the element 
         // (with initial style settings still in effect)
         var next = {width: el.width()+'px', height: el.height()+'px'};

         el .css(cur) // restore initial dimensions
            .animate(next, speed, function()  // animate to final dimensions
            {
               el.css(finish); // restore initial style settings
               if ( $.isFunction(callback) ) callback();
            });
      });
   };


})(jQuery);

