/* Cufon replacements */
Cufon.replace('h2,h3,#promo h4');

/* bumper for secondary nav */

$('#secondary-nav li').hover(
     function () {
		$(this).find("a").animate({
			marginLeft: "1em"
		}, 100 );        
	 }, 
     
     function () {
		$(this).find("a").animate({
			marginLeft: "0"
		}, 200 );        

});

/* faders for lists */

$("ul.fader li a.trigger").click( function(e) {
	
	var target = $(this).attr("href");
	
	// set other triggers to default state
	$("ul.fader li").removeClass('selected');
	$(this).parent().addClass('selected');
	
	// hide any visible siblings
	$(target).siblings(".visible").fadeOut(200, function() { $(this).addClass('hidden'); $(this).removeClass('visible'); $(target).fadeIn(200);  });

	$(target).addClass('visible');
	
	e.preventDefault();		
});

/* Scrollables */

$("#promo-scroller div.scrollable").scrollable({ 
	size: 1, 
	items: '.items',   
	hoverClass: 'hover',
	interval: 8000,
	clickable: true, 
	loop: true,  
	speed: 800,
	prev: "#promo-scroller-prev",
	next: "#promo-scroller-next",
	easing: 'swing',
	navi:"#promo-auto-navigation",
	disabledClass: "hidden"
	
});   
//	easing: 'easeOutExpo',
	
/* Portfolio navigation */
/* Make it visible for JS users */
$(".select-navigation").show();
/* do the redir */
$(".select-navigation").change( function() {
	window.location = $(this).find(":selected").val();	
});

// fix for where only one item
if ($("#promo-scroller div.scrollable ul li").length < 2) {
	$("#promo-auto-navigation,#promo-scroller-next").addClass("hidden");
}
/* Portfolio full-screen viewer */

$("#maybe-portfolio-full-screen").css("display","none");

/* convert contact form anchor navigation into inline show-hide for JS users */
/* hide anchor titles for JS users */

/*
$('#secondary-nav.contact a').click(function(event){
	var thisForm = $(this).attr('href');
	resetForm('index.php' + thisForm);
	$('.contact-form:not(thisForm)').css('display','none');
	$(thisForm).css('display','block');
	var thisParent = $(this).parent();
	$('#secondary-nav.contact li:not(thisParent)').removeClass('selected');
	$(thisParent).addClass('selected');
	event.preventDefault();										 
});

$('h3.form-anchor').css('display','none');
$('#form-sales, #form-careers, #form-press').css('display','none');
*/






/* contact forms */

// ------------------ General Form validation functions ------------------------------
function validateNotEmpty(pInput){
	$(pInput).css({'background-color': '#ffffff'});
	if($(pInput).attr('value')==""){
		$(pInput).css({'background-color':'#ffffca'});
		return false;
	}else{
		return true;	
	}
}

function validateEmail(pInput){
	$(pInput).css({'background-color': '#ffffff'});
	var the_at=$(pInput).attr('value').indexOf("@");
	var the_dot=$(pInput).attr('value').indexOf(".");
	var a_space=$(pInput).attr('value').indexOf(" ");
	if(($(pInput).attr('value')=="") || (the_at==-1) || (the_at==0) || (the_dot==-1) || (the_dot>=$(pInput).attr('value').length-1) || (a_space!=-1)){
		$(pInput).css({'background-color':'#ffffca'});
		return false;
	}else{
		return true;	
	}
}

function validateAtLeast(pInput,pLength){
	$(pInput).css({'background-color': '#ffffff'});
	if($(pInput).attr('value').length<pLength){
		$(pInput).css({'background-color':'#ffffca'});
		return false;
	}else{
		return true;	
	}
}

function isUrl(url) {
	return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/);
}


function validateWebsite(pInput){
	$(pInput).css({'background-color': '#ffffff'});
	if(($(pInput).attr('value')=="") || ($(pInput).attr('value').length<12) || (!isUrl($(pInput).attr('value')))){
		$(pInput).css({'background-color':'#ffffca'});
		return false;
	}else{
		return true;	
	}
}

function validateGeneral(){
	// hide error message
	$('#error-message-general').hide();
	
	// reset label colors
	$('#general-name, #general-email, #general-subject, #general-message').css({'background-color': '#ffffff'});
	
	var errorCheck = 0;
	
	if(!validateNotEmpty('#general-name')){
		errorCheck++;		
	}
	
	if(!validateEmail('#general-email')){
		errorCheck++;
	}
	
	if(!validateAtLeast('#general-subject',2)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#general-message',5)){
		errorCheck++;
	}
	
	if(errorCheck>0){
		$('#error-message-general').show();
		
		var success=false;
		return success;
	}else{
		var success=true;
		return success;
	}	
}





function validateSales()
{
	// hide error message
	$('#error-message-sales').hide();
	
	// reset label colors
	$('#sales-name, #sales-email, #sales-phone, #sales-company, #sales-website, #sales-message').css({'background-color': '#ffffff'});
	
	var errorCheck = 0;
	
	if(!validateNotEmpty('#sales-name')){
		errorCheck++;		
	}
	
	if(!validateEmail('#sales-email')){
		errorCheck++;
	}
	
	if(!validateAtLeast('#sales-phone',10)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#sales-company',2)){
		errorCheck++;
	}
	
	if(!validateWebsite('#sales-website')){
		errorCheck++;	
	}
	
	if(!validateAtLeast('#sales-message',5)){
		errorCheck++;
	}
	
	if(errorCheck>0){
		$('#error-message-sales').show();
		
		var success=false;
		return success;
	}else{
		var success=true;
		return success;
	}	
}




function validatePress(){
	// hide error message
	$('#error-message-press').hide();
	
	// reset label colors
	$('#press-name, #press-email, #press-phone, #press-company, #press-subject, #press-message').css({'background-color': '#ffffff'});
	
	var errorCheck = 0;
	
	if(!validateNotEmpty('#press-name')){
		errorCheck++;		
	}
	
	if(!validateEmail('#press-email')){
		errorCheck++;
	}
	
	if(!validateAtLeast('#press-phone',10)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#press-company',2)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#press-subject',2)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#press-message',5)){
		errorCheck++;
	}
	
	if(errorCheck>0){
		$('#error-message-press').show();
		
		var success=false;
		return success;
	}else{
		var success=true;
		return success;
	}	
}




function validateCareers(){
	// hide error message
	$('#error-message-careers').hide();
	
	// reset label colors
	$('#careers-name, #careers-email, #careers-phone, #careers-website, #careers-position, #careers-message').css({'background-color': '#ffffff'});
	
	var errorCheck = 0;
	
	if(!validateNotEmpty('#careers-name')){
		errorCheck++;		
	}
	
	if(!validateEmail('#careers-email')){
		errorCheck++;
	}
	
	if(!validateAtLeast('#careers-phone',10)){
		errorCheck++;
	}
	
	if(!validateWebsite('#careers-website')){
		errorCheck++;
	}
	
	if(!validateAtLeast('#careers-position',2)){
		errorCheck++;
	}
	
	if(!validateAtLeast('#careers-message',5)){
		errorCheck++;
	}
	
	if(errorCheck>0){
		$('#error-message-careers').show();
		
		var success=false;
		return success;
	}else{
		var success=true;
		return success;
	}	
}





/* ------------------------ Instant validators ---------------------------- */
function initName(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateNotEmpty(pInput);								
	});	
}

function initEmail(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateEmail(pInput);								
	});	
}

function initSubject(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateAtLeast(pInput,2);								
	});	
}

function initMessage(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateAtLeast(pInput,2);								
	});	
}


function initPhone(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateAtLeast(pInput,10);								
	});	
}

function initCompany(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateAtLeast(pInput,2);								
	});	
}

function initWebsite(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateWebsite(pInput);
		if($(this).attr('value') == ""){
			$(this).attr('value','http://');	
		}
	});	
}



function initPosition(pInput){
	$(pInput).unbind('blur');
	$(pInput).blur(function(){
		validateAtLeast(pInput,2);						   
	});
}


function initResets(){
	$('.reset-form').click(function(event){
		event.preventDefault();
		var theForm = $(this).attr('href');
		resetForm(theForm);
	});	
}


$('#general-name, #sales-name, #press-name, #careers-name').focus(function(event){
	initName('#' + $(this).attr('id'));								 
});

$('#general-email, #sales-email, #press-email, #careers-email').focus(function(event){
	initEmail('#' + $(this).attr('id'));								 
});

$('#general-subject, #press-subject').focus(function(event){
	initSubject('#' + $(this).attr('id'));								 
});

$('#general-message, #sales-message, #press-message, #careers-message').focus(function(event){
	initMessage('#' + $(this).attr('id'));								 
});

$('#sales-phone, #press-phone, #careers-phone').focus(function(event){
	initPhone('#' + $(this).attr('id'));								 
});

$('#sales-company, #press-company').focus(function(event){
	initCompany('#' + $(this).attr('id'));								 
});

$('#sales-website, #careers-website').focus(function(event){
	if($(this).attr('value') == "http://"){
		var a = $(this)[0];
		if(a.setSelectionRange){
			a.focus();
			a.setSelectionRange(7,7);
		}else{
			var range = a.createTextRange();
			range.collapse(true);
			range.moveEnd('character', 7);
			range.moveStart('character', 7);
			range.select();

		}
	}
	initWebsite('#' + $(this).attr('id'));								 
});


$('#careers-position').focus(function(event){
	initPosition('#' + $(this).attr('id'));								 
});









/* ------------------------ form resets --------------------------------- */
function resetForm(pForm){
	switch(pForm){
		case 'index.php#form-general':
			$('#general-name, #general-email, #general-subject, #general-message').css({'background-color': '#ffffff'});
			$('#general-name, #general-email, #general-subject').attr({'value': ''});
			$('#general-message').val('');
			$('.error-message').hide();
			$('.sending').hide();
			$('#general-send').show();
			break;
			
		case 'index.php#form-sales':
			$('#sales-name, #sales-email, #sales-phone, #sales-company, #sales-website, #sales-message').css({'background-color': '#ffffff'});
			$('#sales-name, #sales-email, #sales-phone, #sales-company').attr({'value': ''});
			$('#sales-message').val('');
			$('#sales-website').attr({'value': 'http://'});
			$('#sales-project-type, #sales-project-size, #sales-project-time').attr({'selectedIndex': '0'});
			$('.error-message').hide();
			$('.sending').hide();
			$('#sales-send').show();
			break;
			
		case 'index.php#form-press':
			$('#press-name, #press-email, #press-phone, #press-company, #press-subject, #press-message').css({'background-color': '#ffffff'});
			$('#press-name, #press-email, #press-phone, #press-company, #press-subject').attr({'value': ''});
			$('#press-message').val('');
			$('.error-message').hide();
			$('.sending').hide();
			$('#press-send').show();
			break;
			
		case 'index.php#form-careers':
			$('#careers-name, #careers-email, #careers-phone, #careers-website, #careers-position, #careers-message').css({'background-color': '#ffffff'});
			$('#careers-name, #careers-email, #careers-phone, #careers-position').attr({'value': ''});
			$('#careers-message').val('');
			$('#careers-website').attr({'value': 'http://'});
			$('.error-message').hide();
			$('.sending').hide();
			$('#careers-send').show();
			break;
			
		default:
			alert(pForm);
			break;
	}
}
	
	
	
	
	
	
	
	
// form submits

$('#form-general').submit(function(event){
	event.preventDefault();
	var success = validateGeneral();
	if(success){
		$('#general-sending').show();
		$('#general-send').hide();
		var postString = "contactType=general&name=" + $('#general-name').attr('value') + "&email=" + $('#general-email').attr('value') + "&subject=" + $('#general-subject').attr('value') + "&message=" + $('#general-message').val();
		
		$.ajax({
		   type: "POST",
		   url: "mail.php",
		   data: postString,
		   success: function(msg){
			 $('#general-sending').hide();
			 $('#confirm-message-general').html(msg).css('display','block');
			 initResets();
		   }
		});

	}
});

$('#form-sales').submit(function(event){
	event.preventDefault();
	var success = validateSales();
	if(success){
		$('#sales-sending').show();
		$('#sales-send').hide();
		var postString = "contactType=sales&name=" + $('#sales-name').attr('value') + "&email=" + $('#sales-email').attr('value') + "&phone=" + $('#sales-phone').attr('value') + "&company=" + $('#sales-company').attr('value') + "&website=" + $('#sales-website').attr('value') + "&projectType=" + $('#sales-project-type').attr('value') + "&projectSize=" + $('#sales-project-size').attr('value') + "&projectTime=" + $('#sales-project-timeframe').attr('value') + "&message=" + $('#sales-message').val();
		
		$.ajax({
		   type: "POST",
		   url: "mail.php",
		   data: postString,
		   success: function(msg){
			 $('#sales-sending').hide();
			 $('#confirm-message-sales').html(msg).css('display','block');
			 initResets();
		   }
		});

	}
});
	

$('#form-press').submit(function(event){
	event.preventDefault();
	var success = validatePress();
	if(success){
		$('#press-sending').show();
		$('#press-send').hide();
		var postString = "contactType=press&name=" + $('#press-name').attr('value') + "&email=" + $('#press-email').attr('value') + "&phone=" + $('#press-phone').attr('value') + "&company=" + $('#press-company').attr('value') + "&subject=" + $('#press-subject').attr('value') + "&message=" + $('#press-message').val();
		
		$.ajax({
		   type: "POST",
		   url: "mail.php",
		   data: postString,
		   success: function(msg){
			 $('#press-sending').hide();
			 $('#confirm-message-press').html(msg).css('display','block');
			 initResets();
		   }
		});
	}
});


$('#form-careers').submit(function(event){
	event.preventDefault();
	var success = validateCareers();
	if(success){
		$('#careers-sending').show();
		$('#careers-send').hide();
		var postString = "contactType=careers&name=" + $('#careers-name').attr('value') + "&email=" + $('#careers-email').attr('value') + "&phone=" + $('#careers-phone').attr('value') + "&website=" + $('#careers-website').attr('value') + "&position=" + $('#careers-position').attr('value') + "&experience=" + $('#careers-experience').attr('value') + "&message=" + $('#careers-message').val();
		
		$.ajax({
		   type: "POST",
		   url: "mail.php",
		   data: postString,
		   success: function(msg){
			 $('#careers-sending').hide();
			 $('#confirm-message-careers').html(msg).css('display','block');
			 initResets();
		   }
		});
	}
});

// ------------------ Twirlers ---------------------------------------------------------
$(".twirler").each( function() {
	$($(this).attr('href')).css('display','none');
	$($(this).attr('href')).slideUp();
});

$(".twirler").click( function(e) {
	e.preventDefault();			
	if (!$(this).hasClass("open")) {
		$($(this).attr('href')).removeClass("hidden");
		$($(this).attr('href')).slideDown();
		$(this).addClass("open");
	} else {
		$($(this).attr('href')).slideUp();
		$(this).removeClass("open");	
	}
});


// ------------------ Homepage Newsletter Form Submission ------------------------------
	
// $(" drfyh-drfyh").blur( validateEmail("drfyh-drfyh") );	


// $("asdsad").validateEmail();


$("#drfyh-drfyh").click( function() {
	if ($(this).attr('value') == $(this).attr('title')) {
		$(this).attr('value', '');
	}
});

$(".section-home #email-signup").submit( function(e) {
	e.preventDefault();			
	dataString = "name=" + $(this).find("#name").val() + "&email=" + $(this).find("#drfyh-drfyh").val();	
        
   $.ajax({  
     type: "POST",  
     url: "assets/support/newsletter.php",
     data: dataString,       
     success: function(msg) {  
        //display message back to user here  
        
		// create container for the update
    	if (!$(".section-home #email-signup-container .status").length) {
    		$(".section-home #email-signup-container").prepend("<div class='status'></div>");
    	}
		else {
	       	$(".section-home #email-signup-container .status").fadeOut();
    	}	

		// send message based on status		        
        if (msg == 1) { 
        	// hide the form
        	$(".section-home #email-signup").addClass("hidden");
        	
        	// set the status
			$(".section-home #email-signup-container .status").html(
				"<p class='success'>Thank you. You have been added to the maybe.for.you. mailing list.</p>"
			);
        	$(".section-home #email-signup-container .status").fadeIn();			
			
			$(".section-home #email-signup-container").fadeOut(4000, function() {         	
				$(".section-home #email-signup-link").removeClass("open"); 				
				$(".section-home #email-signup-container .status").empty(); 
	        	$(".section-home #email-signup").removeClass("hidden");
				
			}); // end fadeout

        } else {
			$(".section-home #email-signup-container .status").html(
				"<p class='error'>Sorry - we were not able to add your email address to our mailing list.  Please try again, or <a href='mailto:hello@maybeinc.com'>contact us</a>.</p>"
			);
        	$(".section-home #email-signup-container .status").fadeIn();			
        }  // end if      
        
     } // end success     
   }); // end ajax
});



/* ------------------------------- GRID --------------------------------*/
// toggle grid

$(".show-grid-link").click( function() {
	$("body").toggleClass("with-grid");
	createCookie("with-grid",$("body").hasClass("with-grid"));	
});

// turn on grid if cookie set

if(readCookie("with-grid") == "true") {
	$("body").addClass("with-grid");
}
$("#grid").height("100%");


/*
 * jqModal - Minimalist Modaling with jQuery
 *   (http://dev.iceburg.net/jquery/jqModal/)
 *
 * Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 * $Version: 03/01/2009 +r14
 */
(function($) {
$.fn.jqm=function(o){
var p={
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F
};
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
});};

$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});};
$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});};

$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
 if(c.modal) {if(!A[0])L('bind');A.push(s);}
 else if(c.overlay > 0)h.w.jqmAddClose(o);
 else o=F;

 h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
 if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}

 if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
  r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
 else if(cc)h.w.jqmAddClose($(cc,h.w));

 if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	
 (c.onShow)?c.onShow(h):h.w.show();e(h);return F;
},
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
 if(A[0]){A.pop();if(!A[0])L('unbind');}
 if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
 if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
},
params:{}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false,
i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
 if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
})(jQuery);


// modals

$(".modal").each( function() {
	$(this).jqm({modal: false, overlay:70});	
	$(this).addClass("jqmWindow");

	var me = $(this);
	$(this).find(".modalCloser").each( function() {
		me.jqmAddClose($(this));
		$(this).click( function() { 
					pngFix();					
		});
	});
	
});


// finish modals

$(".modalTrigger").each( function() {
	var targetel = $(this).attr("href");
	$(targetel).jqmAddTrigger($(this));		
});


// Terms and Conditions modal
$('#terms-and-conditions').jqm({modal: false, ajax: '/terms-and-conditions.php?ajax=1'});

$('#terms-and-conditions').jqmAddTrigger($("#terms-and-conditions-link"));


// line up heights / bottoms of elements, for borders

(function($) {
	$.fn.lineUpHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() + $(this).offset().top > tallest) {
				tallest = $(this).height() + $(this).offset().top;
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			if ($(this).height() + $(this).offset().top != tallest) {
				$(this).height(tallest - $(this).offset().top);
			}
		});
	}
})(jQuery);

$("#support,#main,.sidebar").addClass("same-height");
Cufon.CSS.ready(function() {
    // everything's been rendered now
	$(".same-height").lineUpHeights(10,3000);
}); 


// cookie support

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


if(!window.XMLHttpRequest) {
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.7a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2 E={J:\'E\',Z:{},1E:7(){4(x.1l&&!x.1l[6.J]){x.1l.23(6.J,\'24:25-26-27:3\')}4(1F.11){1F.11(\'28\',7(){E=29})}},1G:7(){2 a=x.1m(\'8\');x.1H.1b.1n(a,x.1H.1b.1b);2 b=a.1o;b.1c(6.J+\'\\\\:*\',\'{12:2a(#1I#2b)}\');b.1c(6.J+\'\\\\:9\',\'Q:1p;\');b.1c(\'1J.\'+6.J+\'1K\',\'12:y; 1q:y; Q:1p; z-2c:-1; 1d:-1r; 1L:1M;\');6.1o=b},1N:7(){2 a=13.2d;4(13.1e.K(\'2e\')!=-1||13.1e.K(\'1q\')!=-1){E.1f(a)}4(13.1e==\'8.1s\'){2 b=(a.F.1s==\'y\')?\'y\':\'2f\';G(2 v M a.3){a.3[v].9.8.1s=b}}4(13.1e.K(\'14\')!=-1){E.1t(a)}},1t:7(a){4(a.F.14.K(\'2g\')!=-1){2 b=a.F.14;b=1u(b.2h(b.1v(\'=\')+1,b.1v(\')\')),10)/2i;a.3.N.9.8.14=a.F.14;a.3.C.I.2j=b}},15:7(a){2k(7(){E.1f(a)},1)},2l:7(a){2 b=a.1O(\',\');G(2 i=0;i<b.2m;i++){6.1o.1c(b[i],\'12:2n(E.1P(6))\')}},1f:7(a){a.S.1Q=\'\';6.1R(a);6.16(a);6.1t(a);4(a.O){6.1S(a)}},1T:7(b){2 c=6;2 d={2o:\'16\',2p:\'16\'};4(b.17==\'A\'){2 e={2q:\'15\',2r:\'15\',2s:\'15\',2t:\'15\'};G(2 a M e){d[a]=e[a]}}G(2 h M d){b.11(\'1w\'+h,7(){c[d[h]](b)})}b.11(\'2u\',6.1N)},1x:7(a){a.8.2v=1;4(a.F.Q==\'2w\'){a.8.Q=\'2x\'}},1S:7(a){2 b={\'2y\':P,\'2z\':P,\'2A\':P};G(2 s M b){a.3.N.9.8[s]=a.F[s]}},1R:7(a){4(!a.F){1g}U{2 b=a.F}G(2 v M a.3){a.3[v].9.8.1U=b.1U}a.S.18=\'\';a.S.19=\'\';2 c=(b.18==\'1V\');2 d=P;4(b.19!=\'y\'||a.O){4(!a.O){a.D=b.19;a.D=a.D.2B(5,a.D.1v(\'")\')-5)}U{a.D=a.1h}2 e=6;4(!e.Z[a.D]){2 f=x.1m(\'1J\');e.Z[a.D]=f;f.2C=e.J+\'1K\';f.S.1Q=\'12:y; Q:1p; 1y:-1r; 1d:-1r; 1q:y;\';f.11(\'2D\',7(){6.1i=6.2E;6.1j=6.2F;e.16(a)});f.1h=a.D;f.1W(\'1i\');f.1W(\'1j\');x.1X.1n(f,x.1X.1b)}a.3.C.I.1h=a.D;d=V}a.3.C.I.1w=!d;a.3.C.I.N=\'y\';a.3.N.9.8.18=b.18;a.S.19=\'y\';a.S.18=\'1V\'},16:7(e){2 f=e.F;2 g={\'W\':e.2G+1,\'H\':e.2H+1,\'w\':6.Z[e.D].1i,\'h\':6.Z[e.D].1j,\'L\':e.2I,\'T\':e.2J,\'1k\':e.2K,\'1z\':e.2L};2 i=(g.L+g.1k==1)?1:0;2 j=7(a,l,t,w,h,o){a.2M=w+\',\'+h;a.2N=o+\',\'+o;a.2O=\'2P,1Y\'+w+\',1Y\'+w+\',\'+h+\'2Q,\'+h+\' 2R\';a.8.1i=w+\'u\';a.8.1j=h+\'u\';a.8.1y=l+\'u\';a.8.1d=t+\'u\'};j(e.3.N.9,(g.L+(e.O?0:g.1k)),(g.T+(e.O?0:g.1z)),(g.W-1),(g.H-1),0);j(e.3.C.9,(g.L+g.1k),(g.T+g.1z),(g.W),(g.H),1);2 k={\'X\':0,\'Y\':0};2 m=7(a,b){2 c=P;2S(b){1a\'1y\':1a\'1d\':k[a]=0;1A;1a\'2T\':k[a]=.5;1A;1a\'2U\':1a\'2V\':k[a]=1;1A;1I:4(b.K(\'%\')!=-1){k[a]=1u(b)*.2W}U{c=V}}2 d=(a==\'X\');k[a]=2X.2Y(c?((g[d?\'W\':\'H\']*k[a])-(g[d?\'w\':\'h\']*k[a])):1u(b));4(k[a]==0){k[a]++}};G(2 b M k){m(b,f[\'2Z\'+b])}e.3.C.I.Q=(k.X/g.W)+\',\'+(k.Y/g.H);2 n=f.30;2 p={\'T\':1,\'R\':g.W+i,\'B\':g.H,\'L\':1+i};2 q={\'X\':{\'1B\':\'L\',\'1C\':\'R\',\'d\':\'W\'},\'Y\':{\'1B\':\'T\',\'1C\':\'B\',\'d\':\'H\'}};4(n!=\'1D\'){2 c={\'T\':(k.Y),\'R\':(k.X+g.w),\'B\':(k.Y+g.h),\'L\':(k.X)};4(n.K(\'1D-\')!=-1){2 v=n.1O(\'1D-\')[1].31();c[q[v].1B]=1;c[q[v].1C]=g[q[v].d]}4(c.B>g.H){c.B=g.H}e.3.C.9.8.1Z=\'20(\'+c.T+\'u \'+(c.R+i)+\'u \'+c.B+\'u \'+(c.L+i)+\'u)\'}U{e.3.C.9.8.1Z=\'20(\'+p.T+\'u \'+p.R+\'u \'+p.B+\'u \'+p.L+\'u)\'}},1P:7(a){a.8.12=\'y\';4(a.17==\'32\'||a.17==\'33\'||a.17==\'34\'){1g}a.O=V;4(a.17==\'35\'){4(a.1h.21().K(/\\.22$/)!=-1){a.O=P;a.8.1L=\'1M\'}U{1g}}U 4(a.F.19.21().K(\'.22\')==-1){1g}2 b=E;a.3={N:{},C:{}};2 c={9:{},I:{}};G(2 r M a.3){G(2 e M c){2 d=b.J+\':\'+e;a.3[r][e]=x.1m(d)}a.3[r].9.36=V;a.3[r].9.37(a.3[r].I);a.38.1n(a.3[r].9,a)}a.3.C.9.39=\'y\';a.3.C.I.3a=\'3b\';a.3.N.I.1w=V;b.1T(a);b.1x(a);b.1x(a.3c);b.1f(a)}};3d{x.3e("3f",V,P)}3g(r){}E.1E();E.1G();',62,203,'||var|vml|if||this|function|style|shape|||||||||||||||||||||px|||document|none||||image|vmlBg|DD_belatedPNG|currentStyle|for||fill|ns|search||in|color|isImg|true|position||runtimeStyle||else|false||||imgSize||attachEvent|behavior|event|filter|handlePseudoHover|vmlOffsets|nodeName|backgroundColor|backgroundImage|case|firstChild|addRule|top|propertyName|applyVML|return|src|width|height|bLW|namespaces|createElement|insertBefore|styleSheet|absolute|border|10000px|display|vmlOpacity|parseInt|lastIndexOf|on|giveLayout|left|bTW|break|b1|b2|repeat|createVmlNameSpace|window|createVmlStyleSheet|documentElement|default|img|_sizeFinder|visibility|hidden|readPropertyChange|split|fixPng|cssText|vmlFill|copyImageBorders|attachHandlers|zIndex|transparent|removeAttribute|body|0l|clip|rect|toLowerCase|png|add|urn|schemas|microsoft|com|onbeforeunload|null|url|VML|index|srcElement|background|block|lpha|substring|100|opacity|setTimeout|fix|length|expression|resize|move|mouseleave|mouseenter|focus|blur|onpropertychange|zoom|static|relative|borderStyle|borderWidth|borderColor|substr|className|onload|offsetWidth|offsetHeight|clientWidth|clientHeight|offsetLeft|offsetTop|clientLeft|clientTop|coordsize|coordorigin|path|m0|l0|xe|switch|center|right|bottom|01|Math|ceil|backgroundPosition|backgroundRepeat|toUpperCase|BODY|TD|TR|IMG|stroked|appendChild|parentNode|fillcolor|type|tile|offsetParent|try|execCommand|BackgroundImageCache|catch'.split('|'),0,{}))

	// unfortunately currently need two different pngfix approaches since belatedPNG doesn't play well with the team (page).
  DD_belatedPNG.fix('div,img,a');
  $("span").pngfix();

}