﻿var _gaiDebug = false; (function (a) { a.fn.debug = function (b) { if (_gaiDebug) { nowtime = (new Date()).getTime(); if (a(this).data("gai." + b) == "1") { a(this).data("gai." + b, "0"); oldtime = a(this).data("gai.time." + b); difftime = (nowtime - oldtime); try { console.timeEnd(b) } catch (c) { try { console.log("end:[ " + b + " ]: " + difftime + "ms") } catch (c) { } } } else { a(this).data("gai." + b, "1"); a(this).data("gai.time." + b, nowtime); try { console.time(b) } catch (c) { } } } }; a.fn.log = function (b) { if (_gaiDebug) { try { console.debug("log:[ " + b + " ]"); debug("log:[ " + b + " ]"); } catch (c) { } } } })(jQuery); function $debug(a) { if (_gaiDebug) { a = "[GAI(Debug Mode)] : " + a; jQuery.log(a) } };

/************************************************
* getUrlVar(), ScrollTo, Cookie()
*************************************************/
/*
* URL QueryString Plugin
* Copyright (c) 2010
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
jQuery.extend({getUrlVars:function(){var d=[],c;var a=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var b=0;b<a.length;b++){c=a[b].split("=");d.push(c[0]);d[c[0]]=c[1]}return d},getUrlVar:function(a){return jQuery.getUrlVars()[a]}});
/*
* jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
*
* Uses the built In easIng capabilities added In jQuery 1.1
* to offer multiple easIng options
*
* Copyright (c) 2007 George Smith
* Licensed under the MIT License:
*   http://www.opensource.org/licenses/mit-license.php
*/

// t: current time, b: begInnIng value, c: change In value, d: duration

jQuery.easing['jswing'] = jQuery.easing['swing']; jQuery.extend(jQuery.easing, { def: 'easeOutQuad', swing: function (x, t, b, c, d) { return jQuery.easing[jQuery.easing.def](x, t, b, c, d) }, easeInQuad: function (x, t, b, c, d) { return c * (t /= d) * t + b }, easeOutQuad: function (x, t, b, c, d) { return -c * (t /= d) * (t - 2) + b }, easeInOutQuad: function (x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t + b; return -c / 2 * ((--t) * (t - 2) - 1) + b }, easeInCubic: function (x, t, b, c, d) { return c * (t /= d) * t * t + b }, easeOutCubic: function (x, t, b, c, d) { return c * ((t = t / d - 1) * t * t + 1) + b }, easeInOutCubic: function (x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; return c / 2 * ((t -= 2) * t * t + 2) + b }, easeInQuart: function (x, t, b, c, d) { return c * (t /= d) * t * t * t + b }, easeOutQuart: function (x, t, b, c, d) { return -c * ((t = t / d - 1) * t * t * t - 1) + b }, easeInOutQuart: function (x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b; return -c / 2 * ((t -= 2) * t * t * t - 2) + b }, easeInQuint: function (x, t, b, c, d) { return c * (t /= d) * t * t * t * t + b }, easeOutQuint: function (x, t, b, c, d) { return c * ((t = t / d - 1) * t * t * t * t + 1) + b }, easeInOutQuint: function (x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b; return c / 2 * ((t -= 2) * t * t * t * t + 2) + b }, easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t / d * (Math.PI / 2)) + c + b }, easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t / d * (Math.PI / 2)) + b }, easeInOutSine: function (x, t, b, c, d) { return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b }, easeInExpo: function (x, t, b, c, d) { return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b }, easeOutExpo: function (x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b }, easeInOutExpo: function (x, t, b, c, d) { if (t == 0) return b; if (t == d) return b + c; if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b; return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b }, easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b }, easeOutCirc: function (x, t, b, c, d) { return c * Math.sqrt(1 - (t = t / d - 1) * t) + b }, easeInOutCirc: function (x, t, b, c, d) { if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b }, easeInElastic: function (x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3; if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b }, easeOutElastic: function (x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3; if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b }, easeInOutElastic: function (x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5); if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b }, easeInBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c * (t /= d) * t * ((s + 1) * t - s) + b }, easeOutBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b }, easeInOutBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b }, easeInBounce: function (x, t, b, c, d) { return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b }, easeOutBounce: function (x, t, b, c, d) { if ((t /= d) < (1 / 2.75)) { return c * (7.5625 * t * t) + b } else if (t < (2 / 2.75)) { return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b } else if (t < (2.5 / 2.75)) { return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b } else { return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b } }, easeInOutBounce: function (x, t, b, c, d) { if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b; return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b } });

/*
* jQuery Color Animations
* Copyright 2007 John Resig
* Released under the MIT and GPL licenses.
*/

(function (jQuery) { jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function (i, attr) { jQuery.fx.step[attr] = function (fx) { if (fx.state == 0) { fx.start = getColor(fx.elem, attr); fx.end = getRGB(fx.end) } fx.elem.style[attr] = "rgb(" + [Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)].join(",") + ")" } }); function getRGB(color) { var result; if (color && color.constructor == Array && color.length == 3) return color; if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])]; if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55]; if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]; if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)]; return colors[jQuery.trim(color).toLowerCase()] } function getColor(elem, attr) { var color; do { color = jQuery.curCSS(elem, attr); if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body")) break; attr = "backgroundColor" } while (elem = elem.parentNode); return getRGB(color) }; var colors = { aqua: [0, 255, 255], azure: [240, 255, 255], beige: [245, 245, 220], black: [0, 0, 0], blue: [0, 0, 255], brown: [165, 42, 42], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgrey: [169, 169, 169], darkgreen: [0, 100, 0], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkviolet: [148, 0, 211], fuchsia: [255, 0, 255], gold: [255, 215, 0], green: [0, 128, 0], indigo: [75, 0, 130], khaki: [240, 230, 140], lightblue: [173, 216, 230], lightcyan: [224, 255, 255], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightyellow: [255, 255, 224], lime: [0, 255, 0], magenta: [255, 0, 255], maroon: [128, 0, 0], navy: [0, 0, 128], olive: [128, 128, 0], orange: [255, 165, 0], pink: [255, 192, 203], purple: [128, 0, 128], violet: [128, 0, 128], red: [255, 0, 0], silver: [192, 192, 192], white: [255, 255, 255], yellow: [255, 255, 0]} })(jQuery);
/**
 * --------------------------------------------------------------------
 * jQuery tree plugin
 * Author: Scott Jehl, scott@filamentgroup.com
 * Copyright (c) 2009 Filament Group 
 * licensed under MIT (filamentgroup.com/examples/mit-license.txt)
 * --------------------------------------------------------------------
 */
//jQuery.fn.tooltip=function(){if(!jQuery("body").is("[role]")){jQuery("body").attr("role","application")}return jQuery(this).each(function(){if(jQuery(this).is("[data-hrefpreview],[title],[href^=#]")){var a="tooltip-"+Math.round(Math.random()*10000);var b=jQuery('<div class="tooltip" role="tooltip" id="'+a+'"></div>');if(jQuery(this).is("[data-hrefpreview]")){b.load(jQuery(this).attr("data-hrefpreview"))}else{if(jQuery(this).is("[href^=#]")){b.append(jQuery(jQuery(this).attr("href")))}else{if(jQuery(this).is("[title]")){b.text(jQuery(this).attr("title"))}}}jQuery(this).removeAttr("title").attr("aria-describedby",a).mouseover(function(c){b.appendTo("body").removeClass("tooltip-hidden").attr("aria-hidden",false).css({top:c.pageY-b.outerHeight(),left:c.pageX+20})}).mouseout(function(){b.addClass("tooltip-hidden").attr("aria-hidden",true)});jQuery("#"+jQuery(this).attr("for")).attr("aria-describedby",a);b.addClass("tooltip-hidden").attr("aria-hidden",true).appendTo("body")}})};
jQuery.fn.tooltip = function ()
{
	//add body role
	if (!jQuery('body').is('[role]')) { jQuery('body').attr('role', 'application'); }
	return jQuery(this).each(function ()
	{
		if (jQuery(this).is('[data-hrefpreview],[title],[href^=#]')) {

			//generate a unique ID for the tooltip
			var ttID = 'tooltip-' + Math.round(Math.random() * 10000);
			//create tooltip container
			var tooltip = jQuery('<div class="tooltip" role="tooltip" id="' + ttID + '"></div>');

			//populate tooltip with content, depending on source
			if (jQuery(this).is('[data-hrefpreview]')) { //use ajax to retrieve data if data-hrefpreview attr is present
				tooltip.load(jQuery(this).attr('data-hrefpreview'));
			}
			else if (jQuery(this).is('[href^=#]')) { //if local anchor, grab referenced content
				//tooltip.append(jQuery(jQuery(this).attr('href')));
				jQuery(jQuery(this).attr('href')).clone().appendTo(tooltip);
				jQuery(this).attr('href', 'javascript:void(0);');
			}
			else if (jQuery(this).is('[title]')) { //if title attr is present, use that
				tooltip.html(jQuery(this).attr('title'));
			}
			//apply attrs and events to tooltipped element			
			jQuery(this)
				.removeAttr('title') //remove redundant title attr
				.attr('aria-describedby', ttID) //associate tooltip with element for screenreaders
				.mousemove(function (e)
				{
					var vy = 0; var vx = 0;
					if (tooltip.hasClass('tooltip-hidden')) {
						tooltip
						    .appendTo('body')
						    .removeClass('tooltip-hidden')
						    .attr('aria-hidden', false)
						    .css({
						    	top: e.pageY - tooltip.outerHeight() + vy,
						    	left: e.pageX - vx
						    }); $debug("mousemove");
					}
					else {
						tooltip
						    .css({
						    	top: e.pageY - tooltip.outerHeight() + vy,
						    	left: e.pageX - vx
						    });
					}
				})
                .mouseout(function ()
                {
                	tooltip.addClass('tooltip-hidden').attr('aria-hidden', true); $debug("mouseleave");
                });

			//find an associated form field and set its describedby attr as well for a11y
			jQuery('#' + jQuery(this).attr('for')).attr('aria-describedby', ttID);

			//append the tooltip to the page with hidden class applied
			tooltip
				.addClass('tooltip-hidden')
				.attr('aria-hidden', true)
				.appendTo('body');
		}
	});
};

/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
* @author Ariel Flesler
* @version 1.4.2
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
; (function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { try { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } catch (e) { } } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

// jQuery SWFObject v1.1.1 MIT/GPL @jon_neal
// http://jquery.thewikies.com/swfobject
(function (f, h, i) { function k(a, c) { var b = (a[0] || 0) - (c[0] || 0); return b > 0 || !b && a.length > 0 && k(a.slice(1), c.slice(1)) } function l(a) { if (typeof a != g) return a; var c = [], b = ""; for (var d in a) { b = typeof a[d] == g ? l(a[d]) : [d, m ? encodeURI(a[d]) : a[d]].join("="); c.push(b) } return c.join("&") } function n(a) { var c = []; for (var b in a) a[b] && c.push([b, '="', a[b], '"'].join("")); return c.join(" ") } function o(a) { var c = []; for (var b in a) c.push(['<param name="', b, '" value="', l(a[b]), '" />'].join("")); return c.join("") } var g = "object", m = true; try { var j = i.description || function () { return (new i("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version") } () } catch (p) { j = "Unavailable" } var e = j.match(/\d+/g) || [0]; f[h] = { available: e[0] > 0, activeX: i && !i.name, version: { original: j, array: e, string: e.join("."), major: parseInt(e[0], 10) || 0, minor: parseInt(e[1], 10) || 0, release: parseInt(e[2], 10) || 0 }, hasVersion: function (a) { a = /string|number/.test(typeof a) ? a.toString().split(".") : /object/.test(typeof a) ? [a.major, a.minor] : a || [0, 0]; return k(e, a) }, encodeParams: true, expressInstall: "expressInstall.swf", expressInstallIsActive: false, create: function (a) { if (!a.swf || this.expressInstallIsActive || !this.available && !a.hasVersionFail) return false; if (!this.hasVersion(a.hasVersion || 1)) { this.expressInstallIsActive = true; if (typeof a.hasVersionFail == "function") if (!a.hasVersionFail.apply(a)) return false; a = { swf: a.expressInstall || this.expressInstall, height: 137, width: 214, flashvars: { MMredirectURL: location.href, MMplayerType: this.activeX ? "ActiveX" : "PlugIn", MMdoctitle: document.title.slice(0, 47) + " - Flash Player Installation"}} } attrs = { data: a.swf, type: "application/x-shockwave-flash", id: a.id || "flash_" + Math.floor(Math.random() * 999999999), width: a.width || 320, height: a.height || 180, style: a.style || "" }; m = typeof a.useEncode !== "undefined" ? a.useEncode : this.encodeParams; a.movie = a.swf; a.wmode = a.wmode || "opaque"; delete a.fallback; delete a.hasVersion; delete a.hasVersionFail; delete a.height; delete a.id; delete a.swf; delete a.useEncode; delete a.width; var c = document.createElement("div"); c.innerHTML = ["<object ", n(attrs), ">", o(a), "</object>"].join(""); return c.firstChild } }; f.fn[h] = function (a) { var c = this.find(g).andSelf().filter(g); /string|object/.test(typeof a) && this.each(function () { var b = f(this), d; a = typeof a == g ? a : { swf: a }; a.fallback = this; if (d = f[h].create(a)) { b.children().remove(); b.html(d) } }); typeof a == "function" && c.each(function () { var b = this; b.jsInteractionTimeoutMs = b.jsInteractionTimeoutMs || 0; if (b.jsInteractionTimeoutMs < 660) b.clientWidth || b.clientHeight ? a.call(b) : setTimeout(function () { f(b)[h](a) }, b.jsInteractionTimeoutMs + 66) }); return c } })(jQuery, "flash", navigator.plugins["Shockwave Flash"] || window.ActiveXObject);

//<![CDATA[
/**
* 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}};

// Stop IE6 re-loading background images continuously
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch (err) { }


//~INIT
var $j = jQuery.noConflict();

var gai = {};

function initGAIButton(cid) {
    $j(function () {
        if (typeof (cid) == "undefined") { cid = ""; }
        if (typeof (defxpos) == "undefined") { defxpos = "left"; }

        var gid = 1;
        var type = "3";
        var defbg = "1";
        var defxpos = "left";
        var hoverposition = "center";
        var downposition = "right";
        var upposition = "left";
        var buttontext = "";
        var staticMove = false;

        if ($j.browser.safari && document.readyState != "complete") {
            setTimeout(arguments.callee, 100);
            return;
        }
        $j(cid + ".gai-button").each(function () {
            if (!$j(this).hasClass("gai-loading")) {
                var $this = this;
                var randomkey = ($j("body").hasClass("IE")) ? ("?" + new Date().getTime()) : "";

                if (($j($this).parent().css("display") != "none") && ($j("img", $this).width() > 2)) {
                    $j($this).addClass("gai-loading");
                    $j("<img />").attr("src", ($j("img", $this).attr("src") + randomkey)).load(function () {
                        handlerGAIButton($this, gid);
                        if ($j("body").hasClass("IE") || $j($this).hasClass("gai-switch")) { $j($this).css("background-position", "-99999px"); }
                    });
                }
            }
        });
        $j(".gai-hide").removeClass("gai-hide");
    });
}

function handlerGAIButton($this, gid) {
    try { type = ($j("img", $this).attr("alt").indexOf("type:2") != -1 ? "2" : "3"); } catch (e) { type = "3"; }
    try { defbg = ($j("img", $this).attr("alt").indexOf("defbg:2") != -1 ? "2" : "1"); } catch (e) { defbg = "1"; }
    var defxpos = ($j($this).hasClass('gai-hover-side') ? (type == "2" ? "right" : "center") : "left");
    var hoverposition = (type == "2" ? "right" : "center");
    var downposition = (type == "2" ? "left" : "right");
    var upposition = (type == "2" ? "left" : "left");
    var buttontext = ($j($this).attr("rel") == "textbutton" ? $j($this).attr("title") : "");
    var staticMove = $j($this).hasClass("gai-static");

    if (parseInt($j($this).css("width").replace("px", "")) == 0) {
    	$j($this).css("width", ($j("img", $this).width() / type) + (($j("body").hasClass("IE7")) ? 2 : 0) + (($j("body").hasClass("IE8")) ? 1 : 0) + (($j("body").hasClass("IE9")) ? 1 : 0) + "px");
    }
    if (parseInt($j($this).css("height").replace("px", "")) == 0) {
    	$j($this).css("height", ($j("img", $this).height()) + (($j("body").hasClass("IE7")) ? 4 : 0) + "px");
    }
    $j($this).css("display", "inline-block")
    .css("line-height", ($j("img", $this).height()) + "px")
    .css("background", "url(" + ($j("img", $this).attr("src")) + ") no-repeat left top")
    .css("text-align", "center")
    .css("cursor", "pointer")
    .html("<span class='gai-abs gai-layer2' style='" + $j($this).attr("style") + ";left:0; top:0;' gaiDataType='" + type + "'>" + buttontext + "</span>")
    .append("<span class='gai-abs gai-layer1' style='" + $j($this).attr("style") + ";left:0; top:0;' gaiDataType='" + type + "'>" + buttontext + "</span>")
    .css("background-position", defxpos + " top")/**/
    .mouseenter(function () {
        var xpos = ($j("span.gai-layer1", $this).attr('gaiDataType') == "2" ? "right" : "center");
        $j("span.gai-layer1", $this).css("background-position", xpos + " top");
        ($j("body").hasClass("IE") || staticMove) ? $j("span.gai-layer2", $this).css("visibility", "hidden") : $j("span.gai-layer1", $this).animate({ "opacity": "1" }, { queue: false, duration: 300 });
        ($j("body").hasClass("IE") || staticMove) ? $j("span.gai-layer1", $this).css("visibility", "visible") : $j("span.gai-layer2", $this).animate({ "opacity": "0" }, { queue: false, duration: 300 });
    })
    .mouseleave(function () {
        //var xpos = ($j('span', this).attr('gaiDataType') == "2" ? "left" : "left");
        var xpos = ($j($this).hasClass('gai-hover-side') ? (type == "2" ? "right" : "center") : "left");
        ($j("body").hasClass("IE") || staticMove) ? $j("span.gai-layer2", $this).css("visibility", "visible") : $j("span.gai-layer1", $this).animate({ "opacity": "0" }, { queue: false, duration: 300 });
        ($j("body").hasClass("IE") || staticMove) ? $j("span.gai-layer1", $this).css("visibility", "hidden") : $j("span.gai-layer2", $this).animate({ "opacity": "1" }, { queue: false, duration: 300 });
        //($j("body").hasClass("IE")) ? $j("span", this).css("visibility", "visible").parent().css("background-position", xpos + " top") : $j("span", this).animate({ "opacity": "1" }, { queue: false, duration: 300, complete: function () { $j(this).parent().css("background-position", xpos + " top"); } });
    })
    .mousedown(function () {
        $j("span.gai-layer1", $this).css("background-position", "right top");
    })
    .mouseup(function () {
        var xpos = ($j('span.gai-layer1', $this).attr('gaiDataType') == "2" ? "right" : "center");
        $j("span.gai-layer1", $this).css("background-position", xpos + " top");
    });


    //Check whether is it absolute or relative
    if (($j($this).css("position") != "absolute") && (!$j($this).hasClass("gai-abs"))) { $j($this).css("position", "relative"); }


    //Final to clear button and reset
    $j($this).removeClass("gai-button")
    .removeClass("gai-loading")
    .addClass("gai-button-" + (Math.floor(Math.random() * 99) + 10) + "" + gid + "" + (Math.floor(Math.random() * 99) + 10));
}

/*[Post Script]*/
function postScriptInit() {
    initGAIButton();
    initAutoTextBox('#footer');
}

function setValue(field) {
    if ('' != field.defaultValue) {
        if (field.value == field.defaultValue) { field.value = ''; }
        else if ('' == field.value) { field.value = field.defaultValue; }
    }
}

/**
* OBJECT - AUTO CLEAR TEXTBOX
*/

function initAutoTextBox(area)
{
	var $this;
	var tempValue;
	$j(area + " .autoclear").each(function ()
	{
		$this = $j(this);
		tempValue = $this.val();
		$this.attr("data-defaultValue", tempValue);
		$this.focus(function (tempValue) { changeAutoTextBox("#" + $this.attr("id"), "focus", $this.attr("data-defaultValue")); });
		$this.blur(function (tempValue) { changeAutoTextBox("#" + $this.attr("id"), "blur", $this.attr("data-defaultValue")); });
		//$j(this).log("gai.autotextbox.init(" + area + ")" + $this.attr("id") + " " + tempValue);
	});
};
function changeAutoTextBox(id, actionType, defaultValue)
{
	//$j(id).debug("gai.autotextbox.change(" + id + "," + actionType + "," + defaultValue + ")");

	var $this = $j(id);
	var tempValue = $j.trim($this.val());

	switch (actionType) {
		case "focus":
			if (tempValue == defaultValue) { $this.val(""); } //$debug("checkTextbox() : focus");
			break;
		case "blur":
			if (tempValue == "") { $this.val(defaultValue); } //$debug("checkTextbox() : blur");
			break;
		default:
			return false;
	}
	//$j(id).debug("gai.autotextbox.change(" + id + "," + actionType + "," + defaultValue + ")");
};
	
//]]>
