var $=jQuery.noConflict();var g_sUrl=window.location.href.toLowerCase();var iPathLen=g_sUrl.length;var g_IsHome;if (g_sUrl.indexOf("default.aspx")>0||g_sUrl.substring(iPathLen-1,iPathLen)==="/"){g_IsHome=true}else{g_IsHome=false}
/*                                                              */try{/* doTimeout v0.4 - 7/15/2009 * http://benalman.com/projects/jquery-dotimeout-plugin/ *  * Copyright (c) 2009 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(k){var l=this,g,i={},m=arguments,h=4,f=m[1],j=m[2],o=m[3];if(typeof f!=="string"){h--;f=k=0;j=m[1];o=m[2]}if(k){g=l.eq(0);g.data(k,i=g.data(k)||{})}else{if(f){i=a[f]||(a[f]={})}}i.id&&clearTimeout(i.id);delete i.id;function e(){if(k){g.removeData(k)}else{if(f){delete a[f]}}}function n(){i.id=setTimeout(function(){i.fn()},j)}if(o){i.fn=function(p){o.apply(l,d.call(m,h))&&!p?n():e()};n()}else{if(i.fn){j===undefined?e():i.fn(j===false);return true}else{e()}}}})(jQuery);}catch(e){}
/*                                                              */try{/* Cornerz 0.6 - Bullet Proof Corners * Jonah Fox (jonah@parkerfox.co.uk) 20010 */ (function($){if($.browser.msie && document.namespaces["v"] == null) {document.namespaces.add("v","urn:schemas-microsoft-com:vml");var ss = document.createStyleSheet().owningElement;ss.styleSheet.cssText = "v\\:*{behavior:url(#default#VML);}"};$.fn.cornerz = function(options){function canvasCorner(t,l,r,bw,bc,bg){var sa,ea,cw,sx,sy,x,y,p = 1.57,css="position:absolute;";if(t) {sa=-p; sy=r; y=0; css+="top:-"+bw+"px;";  }else {sa=p; sy=0; y=r; css+="bottom:-"+bw+"px;"; }if(l) {ea=p*2; sx=r; x=0;	css+="left:-"+bw+"px;"}else {ea=0; sx=0; x=r; css+="right:-"+bw+"px;";	}var canvas=$("<canvas width="+r+"px height="+ r +"px style='" + css+"' ></canvas>");var ctx=canvas[0].getContext('2d');ctx.beginPath();ctx.lineWidth=bw*2;	ctx.arc(sx,sy,r,sa,ea,!(t^l));ctx.strokeStyle=bc;ctx.stroke();ctx.lineWidth = 0;ctx.lineTo(x,y);ctx.fillStyle=bg;ctx.fill();return canvas;};function canvasCorners(corners,r,bw,bc,bg) {var hh = $("<div style='display:inherit' />");$.each(corners.split(" "),function() {hh.append(canvasCorner(this[0]=="t",this[1]=="l",r,bw,bc,bg));});return hh;};function vmlCurve(r,b,c,m,ml,mt,right_fix) {var l = m-ml-right_fix;var t = m-mt;return "<v:arc filled='False' strokeweight='"+b+"px' strokecolor='"+c+"' startangle='0' endangle='361' style=' top:" + t +"px;left:"+ l + ";width:" + r+ "px; height:" + r+ "px' />";}function vmlCorners(corners,r,bw,bc,bg,w) {var h ="<div style='text-align:left; '>";$.each($.trim(corners).split(" "),function() {var css,ml=1,mt=1,right_fix=0;if(this.charAt(0)=="t") {css="top:-"+bw+"px;";}else {css= "bottom:-"+bw+"px;";mt=r+1;}if(this.charAt(1)=="l")css+="left:-"+bw+"px;";else {css +="right:-"+(bw)+"px; ";ml=r;right_fix = 1;}h+="<div style='"+css+"; position:absolute; overflow:hidden; width:"+ r +"px; height:" + r + "px;'>";h+= "<v:group  style='width:1000px;height:1000px;position:absolute;' coordsize='1000,1000' >";h+= vmlCurve(r*3,r+bw,bg,-r/2,ml,mt,right_fix); if(bw>0){h+= vmlCurve(r*2-bw,bw,bc,Math.floor(bw/2+0.5),ml,mt,right_fix);}h+="</v:group>";h+= "</div>"; });h += "</div>";return h;};var settings = {corners :"tl tr bl br",radius :10,background:"white",borderWidth:0,fixIE:true };$.extend(settings,options || {});var incrementProperty = function(elem,prop,x) {var y = parseInt(elem.css(prop)) || 0 ;elem.css(prop,x+y);};return this.each(function() {var $$ = $(this);var r = settings.radius*1.0;var bw = (settings.borderWidth || parseInt($$.css("borderTopWidth")) || 0)*1.0;var bg = settings.background;var bc = settings.borderColor;bc = bc || ( bw > 0 ? $$.css("borderTopColor") :bg);var cs = settings.corners;if($.browser.msie) {h = vmlCorners(cs,r,bw,bc,bg,$(this).width() );this.innerHTML += h;}else  {$$.append(canvasCorners(cs,r,bw,bc,bg));}if(this.style.position != "absolute"){this.style.position = "relative"}this.style.zoom = 1;if($.browser.msie && settings.fixIE) {var ow = $$.outerWidth();var oh = $$.outerHeight();if(ow%2 == 1) {incrementProperty($$,"padding-right",1);incrementProperty($$,"margin-right",1);}if(oh%2 == 1) { incrementProperty($$,"padding-bottom",1);incrementProperty($$,"margin-bottom",1);}}});};})(jQuery);}catch(e){}
/*                                                              */function IsNumeric(sText){if(sText=='' || sText==null){return false;}else{var ValidChars='0123456789.'; var IsNumber=true; var Char; for(i=0; i<sText.length && IsNumber==true; i++){Char=sText.charAt(i); if(ValidChars.indexOf(Char)==-1){IsNumber=false;}}return IsNumber;}}
/*                                                              */try{function replace(argvalue, x, y){if((x==y) || (Number(y.indexOf(x))>-1)){return '';} while (argvalue.indexOf(x)!=-1){var leading=argvalue.substring(0, argvalue.indexOf(x)); var trailing=argvalue.substring(argvalue.indexOf(x) + x.length, argvalue.length); argvalue=leading + y + trailing;} return argvalue;}}catch(e){}
/*                                                              */try{/* 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{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}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);}catch(e){}
var bES=false;
var g_pathPrefix="";
if(location.pathname.substring(0, 14)=="/ACAFoundation"){g_pathPrefix="/ACAFoundation/";}else{g_pathPrefix="/";}
var sURL=window.document.location.href;
if (sURL.indexOf(".es.")>0){bES=true}else{bES=false};

/*
var mrseaves = {src: g_pathPrefix+'/assets/swf/mrseaves.swf', ratios: [8, 1.3, 11, 1.22, 12, 1.2, 18, 1.19, 23, 1.15, 25, 1.14, 28, 1.13, 39, 1.12, 61, 1.11, 94, 1.1, 95, 1.09, 103, 1.1, 107, 1.09, 110, 1.1, 119, 1.09, 120, 1.1, 1.09]};
sIFR.activate(mrseaves);
sIFR.replace(mrseaves,{selector: 'h3.callout',css: ['.sIFR-root {color:#659cd3; leading: 7; text-indent: 4; font-size: 26px;}'],wmode: 'transparent'});
*/
var images = new Array();
if (bES == false){
images.push(g_pathPrefix+'assets/pics/banner1.gif');
images.push(g_pathPrefix+'assets/pics/banner2.gif');
images.push(g_pathPrefix+'assets/pics/banner3.gif');
images.push(g_pathPrefix+'assets/pics/banner4.gif');
images.push(g_pathPrefix+'assets/pics/banner5.gif');
images.push(g_pathPrefix+'assets/pics/banner6.gif');
images.push(g_pathPrefix+'assets/pics/banner7.gif');
images.push(g_pathPrefix+'assets/pics/banner8.gif');
images.push(g_pathPrefix+'assets/pics/banner9.gif');
}
else{
images.push(g_pathPrefix+'assets/pics/banner1es.gif');
images.push(g_pathPrefix+'assets/pics/banner2es.gif');
images.push(g_pathPrefix+'assets/pics/banner3es.gif');
images.push(g_pathPrefix+'assets/pics/banner4es.gif');
images.push(g_pathPrefix+'assets/pics/banner5es.gif');
images.push(g_pathPrefix+'assets/pics/banner6es.gif');
images.push(g_pathPrefix+'assets/pics/banner7es.gif');
images.push(g_pathPrefix+'assets/pics/banner8es.gif');
images.push(g_pathPrefix+'assets/pics/banner9es.gif');
}
function stripTags(e){
	e = e.replace(/<title>.*<\/title>/,'')
	return  e.replace(/<\S[^>]*>/g, '');
}


function mailFriend(){
	window.open('friend.aspx?p='+cid,'sendwindow','status=0,toolbar=0,menubar=0,scrollbars=1,resizeable=0,width=570,height=400,location=0');
}

function limitChars(textid, limit, infodiv)
{
	var text = $('.'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
	    if (bES==true){$('#' + infodiv).html('No puede escribir m·s de '+limit+' caracteres.')}
	    else{$('#' + infodiv).html('You cannot write more then '+limit+' characters.');}
		
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
	    if (bES==true){$('#' + infodiv).html(''+ (limit - textlength) +' caracteres sobrantes.')}
	    else{$('#' + infodiv).html(''+ (limit - textlength) +' Characters Remaining.')}
		return true;
	}
}
function printPage(){
	//play some peek-a-boo with ajax content
	if ($('#accordion').length){			
		var i=0;
		//peek!
		$('dt').each(function(){
			var theHref = $(this).find('a').attr('href');
			var theId = theHref.substring(theHref.indexOf('=')+1, theHref.indexOf(','));
			$(this).next('dd').load(g_pathPrefix + 'controls/controls/content.aspx?cid='+theId+',12', function(){
				i++;
				if (i>=$('#accordion dt').length){
					/*$('dd').show();
					$('dd').css({
								'height':'0',
								'overflow':'hidden'
					});*/
					window.print();
					//a-boo!
					$(document).bind("focus mouseover", function(){
						$('dd').hide();
						$(this).unbind();
					});
				}
			});
			
		
		});
		
	}else{
		window.print();
	}
	
}
function boxit(target){
	var theText = $(target).text();
	var theHref = $(target).attr('href');
	$.facebox(function() {
		$.get(theHref, function(data) {
			data = stripTags(data);
			$('#facebox br').replaceWith('<span class="br"></span>');
			$.facebox('<h3>'+theText+'</h3>'+$.trim(data));
		})
		if($.browser.msie==true){$(target).removeAttr('filter');}
	});
	
}
$(document).ready(function(){
    
    if (g_IsHome===true){recentlyAnswered();}
    
    if ($("#ccCalc").length>0){
        $("#ccCalc").css("display","inline-block");
        /*
        $('.ccCalc-link').click(function(){
            var ctrl = $("#ccCalc");
            $.facebox(ctrl);
            $('#ccCalc *').each(function(){
                if(this.tagName.toLowerCase()!="input"){
                    $(this).show(1, function() {if($.browser.msie==true){this.style.removeAttribute('filter');} });
                }
            });
            ctrl.css("display","block");
            ctrl.focus();
            return false;
        });
        */
    }
    
    if ($("#cmCalc").length>0){
        $("#cmCalc").css("display","inline-block");
        /*
        $('.cmCalc-link').click(function(){
            var ctrl = $("#cmCalc");
            $.facebox(ctrl);
            $('#cmCalc *').each(function(){
                if(this.tagName.toLowerCase()!="input"){
                    $(this).show(10, function() {if($.browser.msie==true){this.style.removeAttribute('filter');} });
                }
            });
            ctrl.css("display","block");
            ctrl.focus();
            return false;
        });
        */
    }

    $.sitesearch();
	$('#ctl00_ContentPlaceHolder1_txtsender').css({'margin-top':'15px','margin-bottom':'0'});
	$('#ctl00_ContentPlaceHolder1_txtsender').keyup(function(event){
		if ($(this).attr('value') != ''){
			$('.your-name').html($(this).attr('value'));
		}else{
			$('.your-name').html('[your first name and last initial]');
		}
	});
	$('.def-link').click(function(){
		boxit($(this));
		return false;
	});
	//$('.def-link').mouseover(function(){//var current = $(this); //var t = setTimeout(function(){boxit(current);}, 800); });
	
	$('#ctl00_ContentPlaceHolder1_txtreceiver').keyup(function(event){
		if ($(this).attr('value') != ''){
			$('.friends-name').html($(this).attr('value'));
		}else{
			$('.friends-name').html('[friend\'s name]');
		}
	});
	$('#mailer a').click(function(){
		opener.location.href = $(this).attr('href');
		return false;
	});
	var qs = window.location.search.substr(1);
	if($.browser['msie'] && $.browser['version'] < 7.0){
        $('#nav li:has(ul)').hover(
			function(){
			this.getElementsByTagName('ul')[0].style.display = 'block';
			},
			function(){
			    this.getElementsByTagName('ul')[0].style.display = 'none';
			}
		);
	}
	i=0;
	$('.tanbox').next('hr').css('display','none');
	$('#accordion.qa dt').each(function(){
        i++;
        $(this).replaceWith('<dt><span class="num">'+i+'. </span>' + $(this).html());
	});

	if (qs.indexOf('rvl=')>=0){
		var theHref;
		var theId;
        var scid=window.location.href;
        var spcid=window.location.href;
        var ddToLoad;

	    if (qs.indexOf('rvl=1')>=0){
	        window.location='#qod';
		    theHref = $('#accordion dt:first-child a').attr('href');
		    theId = theHref.substring(theHref.indexOf('=')+1, theHref.indexOf(','));
		    
		    if (bES==true){$('#accordion dt').append(' <span class="loader">[cargando]</span>').next().hide().wrapInner('<span class="pad"></span>')}
		    else{$('#accordion dt').append(' <span class="loader">[loading]</span>').next().hide().wrapInner('<span class="pad"></span>')}
		    ddToLoad=$('#accordion dd');    
	    }
	    else if (qs.indexOf('rvl=!')>=0 && qs.indexOf('p=')>=0){
	        
            scid=scid.split("p=");
            if(scid[1].toString().length>0){
                scid=scid[1];
                scid=scid.split("&");
                if (IsNumeric(scid[0])===true){
                    theId=scid[0];
                }
            }
            ddToLoad=($('#dd_' + theId));
            $.scrollTo(ddToLoad, 300, {axis: 'y'})
            ddToLoad=ddToLoad.parent().next("dd");
	    }
        
        
		$(ddToLoad).load(g_pathPrefix + 'controls/content.aspx?cid='+theId+',12', 
		    function(){
			    $('.def-link').click(function(){
				    boxit($(this));
				    return false;
			    });
			    if ($('#accordion.qa').length || $('.tanbox').length){
				    //alert ($('#accordion.qa'));
				    if (!bES){$(this).prepend('<span class="title">Answer:</span>');}
				    else{$(this).prepend('<span class="title">Respuesta:</span>');}
			    }
			    $('.loader').fadeOut('fast', function(){$(this).remove();});
			    $('#accordion br').replaceWith('<span class="br"></span>');
			    $('.open').removeClass('open').slideToggle('normal', function(){checking = false;});	
			    
			    $(this).addClass('open');
			    $(this).slideToggle(1000,function(){checking = false;});
		    }
		);		
	}
	checking = false;
	$('#accordion dt').children('a').click(function(){
	
			if(!checking){
			
				checking = true;
				var theHref = $(this).attr('href');
				var theId = theHref.substring(theHref.indexOf('=')+1, theHref.indexOf(','));
				
				if($(this).parent('dt').next('dd').attr('class')!= 'open'){
				    
				    if (bES==true){$(this).parent('dt').append(' <span class="loader">[cargando]</span>')}
				    else{$(this).parent('dt').append(' <span class="loader">[loading]</span>')}
					$(this).parent('dt').next('dd').load(g_pathPrefix + 'controls/content.aspx?cid='+theId+',12', function(){
						$('.def-link').click(function(){
							boxit($(this));
							return false;
						});
						if ($('#accordion.qa').length || $('.tanbox').length){
							if (!bES){$(this).prepend('<span class="title">Answer:</span>');}
							else{$(this).prepend('<span class="title">Respuesta:</span>');}
						}
						$('.loader').fadeOut('fast', function(){$(this).remove();});
						$('#accordion br').replaceWith('<span class="br"></span>');
						$('.open').removeClass('open').slideToggle('normal', function(){checking = false;});	
						$(this).addClass('open');
						$(this).slideToggle('normal', function(){checking = false;});
					});		
				}else{
					$(this).parent('dt').next('dd').removeClass('open').slideToggle('normal', function(){checking = false;});
				}
			}
			return false;
			
	}).parent('dt').next().hide().wrapInner('<span class="pad"></span>');
	$('#accordion dt span').hover(
		function(){
			$(this).css('text-decoration', 'underline');
		},
		function(){
			$(this).css('text-decoration', 'none');
		}
	);
	//$('#qa dd').prepend('<span class="title">Answer:</span>');
	var col = 3;
	if ($('ul[class^="collumns"][class!="one"]').length){
		$('ul[class^="collumns"]').each(function(){
			var classes = $(this).attr('class').split(' ');
			//collumns = classes[$.inArray(/^collumns/, classes)];
			//alert (Math.classes);				
			var links = new Array();
			$('li',this).each( function(i, val){
				links.push(val);					  
			});
			
			links.sort(function(a, b){
				var keyA = $.trim($(a).text().toUpperCase());
				var keyB = $.trim($(b).text().toUpperCase());
				if (keyA < keyB) return -1;				
				if (keyA > keyB) return 1;
				return 0; 
			});
			var list = new String();
			var rows = Math.ceil(links.length/col);
			var bracket = new Array(col);
			//var final = new Array();
			for (i=0; i<col; i++){
				bracket[i] = new Array();
			}
			$(links).each(function(i, val){
				   bNum = Math.floor(i/rows);
				   bracket[bNum][i%rows] = $(val);
			});
			$(this).empty();
			for (i=0; i<col*rows; i++){
				if(typeof(bracket[i%col][Math.floor(i/col)]) != "undefined"){
					$(this).append(bracket[i%col][Math.floor(i/col)]);
				}else{
					$(this).append('<li>&nbsp;&nbsp;</li>');
				}
			}
		});
	}
	$('ol li').wrapInner('<span></span>');

	$('#crumbs .tier1:last-child a').css('background-position', 'right -297px');
	$('#crumbs .tier2:last-child a').css('background-position', 'right -270px');
	$('#crumbs .tier3:last-child a').css('background-position', 'right -243px');
	$('#crumbs .tier4:last-child a').css('background-position', 'right -216px');
	$('#crumbs .tier5:last-child a').css('background-position', 'right -189px');
	
	
	
	$('ul.anchors li:last-child').css({'border-right':'none', 'padding-right':'0'});
	$('ul.anchors li:first-child').css({'border-left':'none', 'padding-left':'0'});
	$('.question').keyup(function(){
		limitChars('question', 500, 'charlimitinfo');
	})
	if (bES==true){$('.question').after('<span id="charlimitinfo">Limite su pregunta a 500 caracteres o menos.</span>')}
	else {$('.question').after('<span id="charlimitinfo">Please limit your question to 500 characters or fewer.</span>')}
	//$('#content').prepend('<p id="corner-links"><a href="/email?page=<?=\'http://\'.$_SERVER[\'HTTP_HOST\'].$_SERVER[\'PHP_SELF\'] ?>">Email to a friend</a></p>');
	$('#qa dd:last-child').css('border-bottom','none');
	$('img').filter('.banner').length?$('img').filter('.banner')[0].src = images[Math.floor(Math.random()*images.length)]:null;
	if (bES==true){
	    $('img').filter('.banner').length?$('img.banner').after('<p id="corner-links"><a href="#" onclick="printPage();return false;">Imprima esta p&aacute;gina</a>&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="mailFriend()">Env&iacute;e un correo electr&oacute;nico a un amigo</a></p>'):$('#content').prepend('<p id="corner-links"><a href="javascript:void(0)" onclick="printPage(); return false;">Imprima esta p&aacute;gina</a>&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="mailFriend()">Env&iacute;e un correo electr&oacute;nico a un amigo</a></p>');
	    $('p img.banner').css('margin-left','-70px');
	    $('p img.banner').css('visibility','visible');
	}
	else{
	    if ($('img.banner').length>0){
	        $('img.banner').after('<p id="corner-links"><a href="#" onclick="printPage(); return false;">Print this page</a>&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="mailFriend()">E-mail to a friend</a></p>');
	        $('img.banner').attr("alt","Ask Doctor Debt - Free Answers. Debt Solutions");
	    }
	    else{
	        $('#content').prepend('<p id="corner-links"><a href="javascript:void(0)" onclick="printPage(); return false;">Print this page</a>&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="mailFriend()">E-mail to a friend</a></p>');
	    }
	    $('p img.banner').css('margin-left','-70px');
	    $('p img.banner').css('visibility','visible');
	    
    }	    
	
	$.localScroll({duration:800});
	//}
});
$(window).load(function(){
	//alert ('loaded');
	
	for (var i=0; i<images.length; i++){
	$("<img>").attr("src", images[i]);}
});


/*
    $('.timer').countTo({
        from: -5000,
        to: 10000,
        time:1000,
        step:1,
        speed:100000,
        refreshInterval: 1,
        onComplete: function(value) {
        }
    });
*/
(function($) {
    $.fn.countTo = function(options) {
        // merge the default plugin settings with the custom options
        options = $.extend({}, $.fn.countTo.defaults, options || {});
        // how many times to update the value, and how much to increment the value on each update
        var loops = Math.ceil(options.speed / options.refreshInterval),
            increment = (options.to - options.from) / loops;
        return $(this).each(function() {
            var _this = this,loopCount = 0,value = options.from,interval = setInterval(updateTimer, options.refreshInterval);
            function updateTimer() {
                value += increment;
                loopCount++;
                $(_this).html(value.toFixed(options.decimals));
                if (typeof(options.onUpdate) == 'function') {options.onUpdate.call(_this, value);}
                if (loopCount >= loops) {
                    clearInterval(interval);
                    value = options.to;
                    if (typeof(options.onComplete) == 'function') {options.onComplete.call(_this, value);}
                }
            }
        });
    };
    $.fn.countTo.defaults = {
        from: 0,  // the number the element should start at
        to: 100,  // the number the element should end at
        speed: 1000,  // how long it should take to count between the target numbers
        refreshInterval: 100,  // how often the element should be updated
        decimals: 0,  // the number of decimal places to show
        onUpdate: null,  // callback method for every time the element is updated,
        onComplete: null  // callback method for when the element finishes updating
    };
})($);

$.sitesearch = function(){
    
    var loc = new String(window.location);  
    var host1 = new String('http://search.acainternational.org');
    var search;
    var searchButton;
    var inputCtrl = $("#q");
    
    if (bES!=true){searchButton='Search';search='/search?site=&client=drdebt_frontend&proxystylesheet=drdebt_frontend&output=xml_no_dtd&proxyreload=1&q=';}
    else{searchButton='Buscar';  search='/search?q=debt&client=drdebt_es_frontend&proxystylesheet=drdebt_es_frontend&output=xml_no_dtd&proxyreload=1&filter=0&q=';}
    var searchFrame = $('#search-frame1');
    searchFrame.attr('src', host1 + search); 
    $("#closesearch").click(function(){$('#searchresults').hide();$(inputCtrl).val(searchButton);return false;});
    $("#searchnow").click(function(){
        $.doTimeout(500, function(){
            if($(inputCtrl).attr("value").toString().length>0){
                var a = search + encodeURI($('#q').val());
                searchFrame.attr('src', host1 + a);
                $('#searchresults').slideDown(500, function() {
                    if($.browser.msie==true){this.style.removeAttribute('filter')}
                    searchFrame.css("height",'1100px');
                    $.doTimeout(100, function(){searchFrame.blur();
                    });
                });
            }
        });
    });
    
    $(inputCtrl).bind("keyup", function(e) {
        if($(inputCtrl).attr("value").toString().length>0){$("#searchnow").trigger("click");}
        return false;
    });
    $("#q").blur();
    $('#q').keypress(function(e){var code = null;code = (e.keyCode ? e.keyCode : e.which);if (code==13){return false;}});
    
}

function recentlyAnswered(){
    var ctrlFeatureList=$("ol.feature");
    
    if(ctrlFeatureList.length===1){
        
        $.doTimeout(500, function(){
            var sPathToQuestions;
            
            if(bES!=true){
                sPathToQuestions=g_pathPrefix + 'controls/content.aspx?qa=13699/3,1,180,100'
            }
            else{
                sPathToQuestions=g_pathPrefix + 'controls/content.aspx?qa=14541/3,1,30,100'
            }
            
            $.ajax({
                url: sPathToQuestions,
                dataType: "html",
                success: function(data){
                    
                    data=data.substring(data.indexOf("<body>")+6);
                    if(data.indexOf("</body>")>0){data=data.substring(0,data.indexOf("</body>"));}
                    data=$.trim(data);
                    if(data.length>0){
                        $.doTimeout(500, function(){
                            $("div#recentlyAnswered").append('<ul>' + data.toString() + '</ul>');
                            $("div#recentlyAnswered").cornerz({radius:8,background:"#ffffff"});
                            $("div#recentlyAnswered ul li").click(function(){
                                var sId=$(this).attr("id");
                                var sParentCID;
                                sId=sId.split("*");
                                sCID=sId[0];
                                sParentCID=sId[1];
                                sCID=replace(sCID,"_","");
                                if (IsNumeric(sCID)===true){
                                    window.location="getanswers.aspx?cid=" + sCID + "&rvl=!&p=" + sParentCID;
                                }
                                delete sId;
                                delete sParentCID;
                                
                            });
                            
                            $("div#recentlyAnswered .hdr").click(function(){window.location="getanswers.aspx";});
                            $("div#recentlyAnswered .itmmore").click(function(){window.location="getanswers.aspx";});
                            
                            $("#recentlyAnswered").css("display","block");
                        });
                    }
                }
            });
        });
    }
}    
    
/* util */
$.viewportHeight=function(){var h=0; if(typeof(window.innerHeight)=="number"){h=window.innerHeight;} else{ if(document.documentElement && document.documentElement.clientHeight){h=document.documentElement.clientHeight;} else{if(document.body && document.body.clientHeight){h=document.body.clientHeight;}} } return h;};
$.viewportWidth=function(){var h=0; if(typeof(window.innerWidth)=="number"){h=window.innerWidth;} else{ if(document.documentElement && document.documentElement.clientWidth){h=document.documentElement.clientWidth;} else{ if(document.body && document.body.clientWidth){h=document.body.clientWidth;} } } return parseInt(h);};

