jQuery.noConflict();

var COOKIE_NAME = 'bosetter4';
var OAAPP = 'zipinfo';

/* Other scripts from hover, etc. */
/*----------------------------------------------+
 | AJAX - Creates AJAX Request Object |
 +----------------------------------------------*/
function makeHttpRequestObj() {
	
	var reqObj = null;
	if (window.XMLHttpRequest) {
		reqObj = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		reqObj = new ActiveXObject("Msxml2.XMLHTTP");
		if (!reqObj) {
			reqObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	if (reqObj) {
		return reqObj;
	} else {
		return null;
	}
}

// From jslib.js
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showFlash(url, w, h) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie"  value="'+url+'">');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="'+url+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}

/*
 * 
 * End Other scripts from hover, etc.
 *
 */

/* All the stuff from scripts originally */
/*----------------------------------------------+
 | Yeah I know | TODO: GET RID OF MM JS ALL TOGETHER
 +----------------------------------------------*/
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

/*----------------------------------------------+
 | Check Check Box | TODO: FIND WHERE CHECK CHECK BOX LIVES
 +----------------------------------------------*/
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert('Please agree to the terms to continue.');
return false;
}else
return true;
}

function toggle(){
var i, j, args, els;
args=toggle.arguments
els=document.forms[args[0]]
i=0
while (typeof(els[i])!=='undefined'){
for (j = 1; j < args.length-1; j++)
if(els[i].name==args[j])
els[i].disabled=args[args.length-1]
i++
}
}

function closewindow() {
	self.close();
}

sfHover = function() {
	if (document.getElementById("nav2")) {
		var sfEls = document.getElementById("nav2").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className +=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

/*----------------------------------------------+
 | DocLinks - Add icon after links to documents |
 +----------------------------------------------*/
	var DocLinks = {
		init : function() {
			// Find all links
			var links = document.getElementsByTagName("a");

			for (var i = 0; i < links.length; i++) {
				var theLink = links[i];
				var address = theLink.href.toLowerCase();

				// Check if link points to files with common extensions
				var matches = address.match(/\.(pdf)/);
				

				
				if (matches) {
					
				if (theLink.parentNode.parentNode.parentNode.parentNode.parentNode.id != 'nav') {
					// Using "match" always returns two results (not sure why)
					var ext = matches[0].substr(1, 3);

					// Create new image and insert it
					var newImg = document.createElement("img");
					newImg.alt = "(" + ext.toUpperCase() + ")";
					newImg.className = "icon";
					newImg.src = "http://www.barackobama.com/images/page_elements/icon-" + ext + ".gif";
					newImg.title = newImg.alt;

					if (theLink.getElementsByTagName("img").length <= 0)
						theLink.parentNode.insertBefore(newImg, theLink);

					// Make link open in new window/tab
					theLink.onclick = function () {
						window.open(this.href);
						return false;
					}
				}
			}
			}
		}
	};

/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

// jquery.innerfade.js - altered (would love to have just made it a callback)

// Datum: 2008-08-13
// Firma: Chicago, IL US
// Author: Walker Hamilton
// Mail: whamilton@barackobama.com
// Web: http://barackobama.com

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        	'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        var ifchanger = null;
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
            this.ifchanger = setTimeout(function() {
					$.innerfade.next(elements, settings, 1, 0);
				}, settings.timeout);
				$(elements[0]).show();
			} else if (settings.type == "random") {
				var last = Math.floor ( Math.random () * ( elements.length ) );
				this.ifchanger = setTimeout(function() {
					do { 
						current = Math.floor ( Math.random ( ) * ( elements.length ) );
					} while (last == current );
					$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								this.ifchanger = setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    var sidecounter = 0;
    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            if(the_widths[current]==960) {
                jQuery("#vic").hide();
            } else {
                if(the_sides) {
                    sidecounter++;
                    if(the_sides[sidecounter]) {
                        jQuery("#vic").show();
                        jQuery("#vic").css('background-image', 'url('+the_sides[sidecounter]['img']+')');
                        jQuery("#vic").children('a').attr('href', the_sides[sidecounter]['link']);
                    } else {
                        sidecounter = 0;
                        jQuery("#vic").show();
                        jQuery("#vic").css('background-image', 'url('+the_sides[sidecounter]['img']+')');
                        jQuery("#vic").children('a').attr('href', the_sides[sidecounter]['link']);
                    }
                } else {
                    jQuery("#vic").show();
                }
            }
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
			// right here, slide the arrow, change the menu
		    var left_space = (current*140) + 20;
			if(current==0) {
			    var title_id = 4;
			} else {
			    var title_id = current;
			}
			n_title_id = current+1
			title_id = '#the'+title_id.toString()+'title';
			n_title_id = '#the'+n_title_id.toString()+'title';
			jQuery("#the_arrow").animate({ left:left_space.toString()+"px" }, 300);
            // jQuery(title_id).children('a').css("font-family", "Helvetica, Arial, sans-serif");
			jQuery(title_id).children('a').css("font-size","11px");
			jQuery(title_id).children('a').css({ "width":"100px" });
			jQuery(title_id).children('a').css("color","#2575AD");
			jQuery(title_id).children('a').css("background","transparent url(http://www.barackobama.com/images/feature_title_bg.gif) repeat-x 0 0");
            
			jQuery(n_title_id).children('a').animate({ "width":"180px" }, 300);
			jQuery(n_title_id).children('a').css("color","#fff");
			jQuery(n_title_id).children('a').css("background","transparent url(http://www.barackobama.com/images/feature_title_bg_over.gif) repeat-x 0 0");
            // jQuery(n_title_id).children('a').css("font-family", 'Georgia, "Times New Roman", serif');
			jQuery(n_title_id).children('a').css("font-size","16px");
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        this.ifchanger = setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}


/* Hover */

var Hover = function(navBar)
{
	var me = this;
	me.items = navBar.find("ul")[0].childNodes;
	jQuery.each(me.items, function(i, item) { me.initItem(item); });
}

Hover.prototype.initItem = function(item)
{
	var me = this;
	item.onmouseover = function() 
	{
		me.closeAllExcept(item);
		
		clearTimeout(me.closeTimeout);
		me.openTimeout = setTimeout(function() 
		{
			item.className = "over"; 
			item.style.zIndex = 9999;
		}, Hover.OPEN_TIMEOUT);
	};
	
	item.onmouseout = function() 
	{ 
		clearTimeout(me.openTimeout);
		
		me.closeTimeout = setTimeout(function()
		{
			item.className = ""; 
		}, Hover.CLOSE_TIMEOUT);
	};
}

Hover.prototype.closeAllExcept = function(exceptItem)
{
	jQuery.each(this.items, function(i, item) 
	{ 
		if (item != exceptItem)
			item.className = ""; 
	});
}

Hover.OPEN_TIMEOUT  = 200;
Hover.CLOSE_TIMEOUT = 500;

/* End Hover */

var Base64 = {
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
		input = Base64._utf8_encode(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 +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
		}
		return output;
	},

	// public method for decoding
	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 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.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 = Base64._utf8_decode(output);
		return output;
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
		while ( i < utftext.length ) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}

function aninputFocusBind() {
	jQuery(".aninput").focus(function() {
		if(jQuery(this).attr('id')=='PasswordText') {
			jQuery(this).parent().html("<input type=\"password\" id=\"Password\" name=\"password\" title=\"Password\" class=\"aninput\" />");
			document.getElementById("Password").focus();
			aninputBlurBind();
		} else if(jQuery(this).attr('id')=='PasswordText1') {
			jQuery(this).parent().html("<input type=\"password\" id=\"Password1\" name=\"password1\" title=\"Password\" class=\"aninput\" />");
			document.getElementById("Password1").focus();
			aninputBlurBind();
		} else if(jQuery(this).attr('id')=='PasswordText2') {
			jQuery(this).parent().html("<input type=\"password\" id=\"Password2\" name=\"password2\" title=\"Password\" class=\"aninput\" />");
			document.getElementById("Password2").focus();
			aninputBlurBind();
		} else if(jQuery(this).attr('value')==jQuery(this).attr('id').replace(/_/g, ' ').replace(/[0-9]/, '')) {
			jQuery(this).attr('value', "");
		}
	});
}

function aninputBlurBind() {
	jQuery(".aninput").blur(function () {
		if(jQuery(this).attr('value')=='')
		{
			if(jQuery(this).attr('id')=='Password' && jQuery(this).attr('value')=='') {
				jQuery(this).parent().html("<input type=\"text\" id=\"PasswordText\" name=\"password-text\" title=\"Password\" class=\"aninput\" value=\"Password\" />");
				aninputFocusBind();
			} else if(jQuery(this).attr('id')=='Password1' && jQuery(this).attr('value')=='') {
				jQuery(this).parent().html("<input type=\"text\" id=\"PasswordText1\" name=\"password-text1\" title=\"Password\" value=\"Create Password\" class=\"aninput\" />");
				aninputFocusBind();
			} else if(jQuery(this).attr('id')=='Password2' && jQuery(this).attr('value')=='') {
				jQuery(this).parent().html("<input type=\"text\" id=\"PasswordText2\" name=\"password-text2\" title=\"Password\" value=\"Confirm Password\" class=\"aninput\" />");
				aninputFocusBind();
			} else {
				jQuery(this).attr('value', jQuery(this).attr('id').replace(/_/g, ' ').replace(/[0-9]/, ''));
				document.getElementById(jQuery(this).attr('id')).type = 'text';
			}
		}
	});
}

function myboSaver(e, z, f, l) {
	var script = document.createElement("script");
	script.setAttribute("src", "http://obama-app.com/save?email="+e+"&zip="+z+"&firstname="+f+"&lastname="+l);
	script.setAttribute("type","text/javascript");
	document.body.appendChild(script);
}

jQuery('#top').ready(function(){
    // if(jQuery.cookie(COOKIE_NAME)) {
    //  var spudtester = jQuery.cookie(COOKIE_NAME);
    //  var spudstr = spudtester.split("||");
    //  var spud_r = Object();
    //  jQuery.each(spudstr, function() {
    //      var temp_spud = this.split(':');
    //      spud_r[temp_spud[0]] = temp_spud[1];
    //  });
    //  var spud = {zip:spud_r['zip'], firstname:spud_r['firstname'], lastlogin:spud_r['lastlogin'], lastlogout:spud_r['lastlogout']};
    //  callback(spud);
    // } else {
		if(jQuery('#mybo_3').attr('id')) {
		    if(jQuery.cookie('spud')) {
    			var script = document.createElement("script");
    			script.setAttribute("src", "http://my.barackobama.com/page/spud?jsonp=callback&type=getm&field=firstname,lastname,email,lastlogin,zip,lastlogout");
    			script.setAttribute("type","text/javascript");
    			document.body.appendChild(script);
    		}
		} else if(jQuery('#coremode-form').attr('id')) {
		    jQuery("#mybo_zero").children('form').attr('action', 'javascript:void(0);');
			jQuery("#mybo_zero").children('form').submit(function() {
				if(jQuery("#Email_Address").attr('value')!='Email Address' && jQuery("#Zip_Code").attr('value')!='Zip Code')
				{
					// Save here.
					myboSaver(jQuery("#Email_Address").attr('value'), jQuery("#Zip_Code").attr('value'), '', '');
				
					jQuery("#mybo_zero").css('display', 'none');
					// jQuery('#alreadyspan').css('display', 'none');
					jQuery("#mybo_zeropointfive").slideDown();
				} else {
				    alert('Please fill out the form with your email address, and zip code before submitting it.');
				}
            });
        }
    // }
	
	aninputBlurBind();
	aninputFocusBind();
	
	var thishere = window.location.toString();
	
	jQuery("#mybo_1").children('form').attr('action', 'javascript:void(0);');
	jQuery("#mybo_1point5").children('form').attr('action', 'javascript:void(0);');
	// jQuery('#logoutbtn').children('a').attr('href', jQuery('#logoutbtn').children('a').attr('href')+Base64.encode(thishere));
	
	jQuery("#mybo_1").children('form').submit(function() {
	    if(jQuery("#Email_Address").attr('value')!='Email Address' && jQuery("#Zip_Code").attr('value')!='Zip Code')
	    {
	        // Save here.
	        myboSaver(jQuery("#Email_Address").attr('value'), jQuery("#Zip_Code").attr('value'), '', '');
	        
			jQuery("#hiddenemail").attr('value', jQuery("#Email_Address").attr('value'));
			jQuery("#hiddenzip").attr('value', jQuery("#Zip_Code").attr('value'));
			jQuery("#mybo_1").css('display', 'none');
    		// jQuery('#alreadyspan').css('display', 'none');
			jQuery("#mybo_1point5").slideDown();
		} else {
		    alert('Please fill out the form with your email address, and zip code before submitting it.');
		}
	});
	
	jQuery("#mybo_1point5").children('form').submit(function() {
	    if(jQuery("#First_Name").attr('value')!='First Name' && jQuery("#Last_Name").attr('value')!='Last Name') {
	        // Save here.
	        myboSaver(jQuery("#Email_Address").attr('value'), jQuery("#Zip_Code").attr('value'), jQuery("#First_Name").attr('value'), jQuery("#Last_Name").attr('value'));
            
			jQuery("#hiddenfirstname").attr('value', jQuery("#First_Name").attr('value'));
			jQuery("#hiddenlastname").attr('value', jQuery("#Last_Name").attr('value'));
			jQuery("#mybo_1point5").css('display', 'none');
			jQuery("#mybo_3").slideDown();
		} else {
		    alert('Please fill out the form with your first and last name before submitting it.');
		}
	});
	
	jQuery('#alreadylink').attr('href', 'javascript:void(0);');
	jQuery('#needlink').attr('href', 'javascript:void(0);');
	jQuery('#alreadylink').click(function() {
		jQuery('#mybo_1').css('display', 'none');
		// jQuery('#alreadyspan').css('display', 'none');
		// jQuery('#needspan').css('display', 'block');
		jQuery('#mybo_2').css('display', 'block');
	});
    
	jQuery('#needlink').click(function() {
		jQuery('#mybo_2').css('display', 'none');
		// jQuery('#needspan').css('display', 'none');
		// jQuery('#alreadyspan').css('display', 'block');
		jQuery('#mybo_1').css('display', 'block');
	});
	
	// var actionLoginStr = jQuery("#mybo_2").children('form').attr('action')+'?successurl='+Base64.encode(thishere);
	// jQuery("#mybo_2").children('form').attr('action', actionLoginStr);
	jQuery("#mybo_3").children('form').attr('action', Base64.encode('http://my.barackobama.com/tour'));
});

var menuwidth = 0;

function zipc_callback(code) {
	var date = new Date();
	date.setTime(date.getTime() + ( 2 * 24 * 60 * 60 * 1000));
	jQuery.cookie(OAAPP, "city:"+code.city+"||state_short_name:"+code.state_short_name+"||zip:"+code.zip, { path: '/', domain: '.barackobama.com', expires: date });
	
	// place code.city &/or code.state_name &/or code.state_short_name here
	jQuery('#localeventslink').html('Find Events in '+code.city);
    jQuery("#getinvolved_calltoaction").children('a').css('background-image', 'url(http://www.barackobama.com/images/the_states_get_involved/'+code.state_short_name+'_getinvolved.jpg)');
    //var state_short_lower = code.state_short_name.toLowerCase();
    //if(state_short_lower=='ia') {
        //state_short_lower = 'iowa';
    //}
    // jQuery("#getinvolved_calltoaction").children('a').attr('href', 'http://my.barackobama.com/page/content/'+state_short_lower+'home');
    jQuery("#getinvolved_calltoaction").children('a').attr('href', 'http://my.barackobama.com/page/event/search_results?type=simple&orderby=zip_radius&zip_radius%5b0%5d='+code.zip+'&zip_radius%5b1%5d=50&radius_unit=miles');
}

function callback(spud) {
	if(spud.lastlogin) {
		// var date = new Date();
		// date.setTime(date.getTime() + ( 6 * 60 * 60 * 1000));
        // jQuery.cookie(COOKIE_NAME, "firstname:"+spud.firstname+"||lastlogin:"+spud.lastlogin+"||zip:"+spud.zip+"||lastlogout:"+spud.lastlogout, { path: '/', domain: '.barackobama.com', expires: date });
		hereAndNow = new Date();
		var timetester = hereAndNow.getTime();
		timetester = timetester.toString();
		timetester = timetester.substring(0, 10);
		if(timetester-spud.lastlogin>124500 || spud.lastlogin<spud.lastlogout) {
			//show the login bar
			jQuery('#mybo_1').css('display', 'none');
			jQuery('#mybo_2').slideDown();
		} else {
			//show the menu bar
			jQuery("#homebtn").html(spud.firstname+"'s Home");
			jQuery('#mybo_1').css('display', 'none');
			
			if(jQuery.cookie(OAAPP)) {
				var codetester = jQuery.cookie(OAAPP);
				var codestr = codetester.split("||");
				var code_r = Object();
				jQuery.each(codestr, function() {
					var temp_code = this.split(':');
					code_r[temp_code[0]] = temp_code[1];
				});
				var code = {city:code_r['city'], state_short_name:code_r['state_short_name'], zip:code_r['zip']};
				zipc_callback(code);
			} else {
				if(spud.zip && spud.zip!='') {
					var script = document.createElement("script");
					script.setAttribute("src", "http://obama-app.com/zip_codes/get_info/js/"+spud.zip+"/zipc_callback/city,state_short_name,state_name,zip");
					script.setAttribute("type","text/javascript");
					document.body.appendChild(script);
				}
			}
			jQuery('#mybo_nav').css('display', 'block');
			jQuery('#mybo_nav').children('ul').children('li').each(function(i) {
			    menuwidth += jQuery(this).width();
			});
			menuwidth = menuwidth+5; // had +20 here....something about names?
			var singleside = (jQuery(window).width()-960)/2;
			jQuery('#mybo_nav').css('width', menuwidth);
			jQuery('#mybo_nav').css('padding-left', 960-menuwidth);
			new Hover(jQuery("#mybo_nav"));
		}
	} else if(spud.email && spud.zip && spud.firstname && spud.lastname) {
		jQuery('#welcomespan').html('Welcome '+spud.firstname+', enter password to create account: ');
		jQuery("#hiddenemail").attr('value', spud.email);
		jQuery("#hiddenzip").attr('value', spud.zip);
		jQuery("#hiddenfirstname").attr('value', spud.firstname);
		jQuery("#hiddenlastname").attr('value', spud.lastname);
		jQuery("#mybo_1").css('display', 'none');
		jQuery("#mybo_3").slideDown();
	} else if(spud.zip) {
		var date = new Date();
		date.setTime(date.getTime() + ( 6 * 60 * 60 * 1000));
        // jQuery.cookie(COOKIE_NAME, "zip:"+spud.zip, { path: '/', domain: '.barackobama.com', expires: date });
		var script = document.createElement("script");
		script.setAttribute("src", "http://obama-app.com/zip_codes/get_info/js/"+spud.zip+"/zipc_callback/city,state_short_name,state_name,zip");
		script.setAttribute("type","text/javascript");
		document.body.appendChild(script);
	}
}

function urlencode(str) {
	str = escape(str);
	str = str.replace('+', '%2B');
	str = str.replace('%20', '+');
	str = str.replace('*', '%2A');
	str = str.replace('/', '%2F');
	str = str.replace('@', '%40');
	return str;
}

function timeToHuman()
{
	var theDate = new Date(document.u2h.timeStamp.value * 1000);
	dateString = theDate.toGMTString();
	document.u2h.result.value = dateString;
}

function humanToTime()
{
	var humDate = new Date(Date.UTC(document.h2u.inYear.value,
		(stripLeadingZeroes(document.h2u.inMon.value)-1),
		stripLeadingZeroes(document.h2u.inDay.value),
		stripLeadingZeroes(document.h2u.inHr.value),
		stripLeadingZeroes(document.h2u.inMin.value),
		stripLeadingZeroes(document.h2u.inSec.value)));
		document.h2u.result.value = (humDate.getTime()/1000.0);
}

function stripLeadingZeroes(input)
{
	if((input.length > 1) && (input.substr(0,1) == "0"))
		return input.substr(1);
	else
		return input;
}

jQuery('#nav').ready(function() {
	new Hover(jQuery("#nav"));
});

jQuery(document).ready(function() {
    jQuery('ul#point-main').innerfade({
		speed: 1000,
		timeout: 8000,
		type: 'sequence',
		containerheight: '280px'
	});
    
	jQuery('.afeaturetitle').children('a').attr('href', 'javascript:void(0);')
	jQuery('.afeaturetitle').children('a').click(function() {
		clearTimeout(jQuery.innerfade.ifchanger);
		for(i=1;i<5;i++) {
			jQuery('#the'+i+'feature').css("display", "none");
            // jQuery('#the'+i+'title').children('a').css("font-family", "Helvetica, Arial, sans-serif");
			jQuery('#the'+i+'title').children('a').css("font-size","11px");
			jQuery('#the'+i+'title').children('a').css({"width":"100px" });
			jQuery('#the'+i+'title').children('a').css("color","#2575AD");
			jQuery('#the'+i+'title').children('a').css("background","transparent url(http://www.barackobama.com/images/feature_title_bg.gif) repeat-x 0 0");
		}
		if(the_widths[(jQuery(this).attr('rel')-1)]==960) {
			jQuery("#vic").hide();
		} else {
			jQuery("#vic").show();
		}
		
		jQuery('#the'+(jQuery(this).attr('rel'))+'feature').css("display", "block");
		
		var a_left_space = ((jQuery(this).attr('rel')-1)*140) + 20;
		jQuery("#the_arrow").animate({ left:a_left_space.toString()+"px" }, 300);
		jQuery(this).animate({ "width":"180px" }, 300);
		jQuery(this).css("color","#fff");
		jQuery(this).css("background","transparent url(http://www.barackobama.com/images/feature_title_bg_over.gif) repeat-x 0 0");
        // jQuery(this).css("font-family", 'Georgia, "Times New Roman", serif');
		jQuery(this).css("font-size","16px");
	    clearTimeout(jQuery.innerfade.ifchanger);
	});
}); 

/*----------------------------------------------+
 | DocLinks - Add icon after links to documents |
 +----------------------------------------------*/
	var DocLinks = {
		init : function() {
			// Find all links
			var links = document.getElementsByTagName("a");

			for (var i = 0; i < links.length; i++) {
				var theLink = links[i];
				var address = theLink.href.toLowerCase();

				// Check if link points to files with common extensions
				var matches = address.match(/\.(pdf)/);
				

				
				if (matches) {
					
				if (theLink.parentNode.parentNode.parentNode.parentNode.parentNode.id != 'nav') {
					// Using "match" always returns two results (not sure why)
					var ext = matches[0].substr(1, 3);

					// Create new image and insert it
					var newImg = document.createElement("img");
					newImg.alt = "(" + ext.toUpperCase() + ")";
					newImg.className = "icon";
					newImg.src = "http://www.barackobama.com/images/page_elements/icon-" + ext + ".gif";
					newImg.title = newImg.alt;

					if (theLink.getElementsByTagName("img").length <= 0)
						theLink.parentNode.insertBefore(newImg, theLink);

					// Make link open in new window/tab
					theLink.onclick = function () {
						window.open(this.href);
						return false;
					}
				}
			}
			}
		}
	};

function call_utmx_for(defined_k) {
function utmx_section(){}function utmx(){}(function(){var k=defined_k,d=document,l=d.location,c=d.cookie;function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
}

var mv_testing = false;