/************************/
/* PakjeGemak Bing Maps */
/************************/
function PakjeGemakMaps(element)
{
    var self = this;

    // VEMap
    var map;

    // holds all markers
    var markers = [];

    // icon html
    var markerIconHtml = '';

    /**
     * constructor
     */
    function constructor()
    {
        map = new VEMap(element);
        map.SetDashboardSize(VEDashboardSize.Small);
        map.LoadMap();
        map.SetCenterAndZoom(new VELatLong(52.132633, 5.291266), 7);

        map.AttachEvent("onclick", function(e)
        {
            if (e.elementID)
            {
                var shape = map.GetShapeByID(e.elementID);

                map.HideInfoBox();
                map.ShowInfoBox(shape);

                if (shape.locationData)
                {
                    console.log(shape, shape.locationData);
                }
            }
        });
    }

    /**
     * set the icon (html) for the markers
     * @param   string  html
     */
    this.setIcon = function(html)
    {
        markerIconHtml = html;
    };

    /**
     * get the locations
     * @param   string      url
     * @param   object      params
     */
    this.fetchLocations = function(url, params)
    {
        this.clearMap();

        $.getJSON(url, params, function(data)
        {
            locations = [];

            if ($.isArray(data))
            {
                for (var l in data)
                {
                    self.addLocation(data[l]);
                }

                self.fittToMarkers();
            }
        });
    };

    /**
     * add location to the map
     * @param   object      data    location data
     */
    this.addLocation = function(data)
    {
        // make sure all the data is a string
        for (var key in data)
        {
            data[key] = data[key].toString();
        }

        locations.push(data);
        var index = locations.length - 1;

        var info = $("<div>" +
                data.Street + " " + data.Housenumber + " " + data.HousenumberAdditional + "<br />" +
                data.PostalcodeNumeric + " " + data.PostalcodeAlpha + " " + data.City + "<br />" +
                '<a href="javascript:selectLocation(' + index + ')">Deze locatie gebruiken als afleveradres</a>' +
                "</div>");

        var infoWindow = {
            title   :   data.Name,
            html    :   info.html()
        };

        this.addMarker(new VELatLong(data.lat, data.lng), markerIconHtml, infoWindow);
    };

    /**
     * add marker to the map
     * @param   VELatLong   latlng
     * @param   string      iconHtml
     * @param   object      infoWindow { string title, string html }
     * @return  VEShape     shape
     */
    this.addMarker = function(latlng, iconHtml, infoWindow)
    {
        var shape = new VEShape(VEShapeType.Pushpin, latlng);
        shape.SetCustomIcon(iconHtml);

        shape.SetTitle(infoWindow.title);
        shape.SetDescription(infoWindow.html);

        markers.push({ shape: shape, latlng: latlng });

        map.AddShape(shape);

        return shape;
    };

    /**
     * zoom/position map to fitt the markers
     */
    this.fittToMarkers = function()
    {
        var latlngs = [];
        for (var i in markers)
        {
            latlngs.push(markers[i].latlng);
        }

        map.SetMapView(latlngs);
    };

    /**
     * clear the map
     */
    this.clearMap = function()
    {
        markers = [];
        map.DeleteAllShapes();
    };

    constructor();
}

/**********************/
/* animateHeaderactie */
/**********************/
function animateHeaderactie()
{
	$('#headeractie ul.fotos').cycle({ 
		timeout: 9000,
		speed:  3000,
		delay: -5000
	});
}

/**************/
/* Fotoboekje */
/**************/
function fotoBoekje()
{
	var foto_groot = '';
	var foto_normaal = '';
	var foto_titel = '';
	var foto_class = '';
	
	$("#content .fotoboek .thumbs a").hover(
	function()
	{
		foto_groot = $(this).attr("href");
		foto_normaal = $(this).attr("rel");
		foto_titel = $(this).attr("title");
		foto_class = $(this).attr("class");
		
		$("#content .fotoboek .fotogroot a").attr("class", foto_class);
		$("#content .fotoboek .fotogroot a").attr("href", foto_groot);
		$("#content .fotoboek .fotogroot a").attr("title", foto_titel);
		$("#content .fotoboek .fotogroot img").attr("src", foto_normaal);
		$("#content .fotoboek .fotogroot img").attr("alt", foto_titel);
	},
	function()
	{
		// niks
	});
	
	// Door middel van de class triggeren dat je op een thumb klikt ivm de gallery in de shadowbox
	$("#content .fotoboek .fotogroot a").click(function()
	{
		var fotoclass = $(this).attr("class");
		$("#content .fotoboek .thumbs a."+fotoclass).trigger("click");
		
		return false;
	});
	
	$(function()
	{
		$("#content .fotoboek .thumbs a").shadowbox({ gallery: "fotoboekje" });
	});
}

/*************************/
/* Nieuwsbrief formulier */
/*************************/
function toonNbForm()
{
	el = $(this).parent();
	
	$("body").one("click", function()
	{
		el.removeClass("nbactief");
	});
	$("#topmenu li.nb .nb-blok").click(function( e ) 
	{		
		e.stopPropagation();
	});	
	
	if( el.hasClass("nbactief") )
	{
		el.removeClass("nbactief");
	}
	else
	{
		el.addClass("nbactief");
	}
	
	return false;
}

/***********************/
/* Filter subcategorie */
/***********************/
function toonFilter()
{
	if( $(this).parent().hasClass("open") )
	{
		$(this).parent().removeClass("open");
	}
	else
	{
        $("#aantal-per-pagina li.open").removeClass("open");
		$("#filter li.open").removeClass("open");
		$(this).parent().addClass("open");
	}
}

function toonAantalRecordsKeuze()
{
	if( $(this).parent().hasClass("open") )
	{
		$(this).parent().removeClass("open");
	}
	else
	{
        $("#filter li:not(.aantal-per-pagina).open").removeClass("open");
		$(this).parent().addClass("open");
	}
}

function toonSorteerKeuze()
{
	if( $(this).parent().hasClass("open") )
	{
		$(this).parent().removeClass("open");
	}
	else
	{
		
		$(this).parent().addClass("open");
	}
}


/********************/
/* Zoom productfoto */
/********************/
function regelGroteFoto( id )
{
	$("#fotos .thumbs a").click(function()
	{
		var classfoto = $(this).attr("class");
		
		$("#fotos .fotogroot .foto").css("visibility", "hidden");
		$("#fotos .fotogroot ."+ classfoto).css("visibility", "visible");;
		
		return false;
	});
	
	$(".fotogroot a").jqzoom();

    if ( id != '' )
    {
        $("a.foto"+id+"1").click();
    }
}

/******************/
/* Input password */
/******************/
function inputPassword()
{
	$("input.ww-clear").show();
	$("input.ww-ww").hide();
	$("input.ww-clear").focus(function()
	{
		$(this).hide();
		$("input.ww-ww").show().focus();
	});
	$("input.ww-ww").blur(function()
	{
		if( $(this).val() == '' )
		{
			$(this).hide();
			$("input.ww-clear").show().blur();
		}
	});
}


function googleTranslateElementInit() 
{
	new google.translate.TranslateElement(
		{
			pageLanguage: 'nl',
			gaTrack: true,
			gaId: 'UA-15686435-1',
			layout: google.translate.TranslateElement.InlineLayout.SIMPLE
		}, 
		'google_translate_element'
	);
  
}



/**
 * Invoercontrole voor wachtwoord vergeten formulier
 *
 * @param   string      emailadres
 * @return  boolean
 */
function controleerWachtwoordVergeten( emailadres )
{
    var melding = '';
    var focus_op_veld = '';

    if(emailadres != '')
    {
        if (emailadres.search(/^(("[^"\x0D\\]+")|([^\x00-\x20\(\)\<\>\[\]\.\\",;:@]+(\.[^\x00-\x20\(\)\<\>\[\]\.\\",;:@]+)*))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([[a-zA-Z0-9\xC0-\xFF\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/) == -1)
        {
            melding += '- Emailadres moet een e-mailadres zijn (bv. voornaam.achternaam@domein.nl)\n';
            if(focus_op_veld == ''){ focus_op_veld = 'emailadres'; }
            error_veld = 'emailadres';
        }
    }
    else if (emailadres == "")
    {
        melding += '- Emailadres is leeg\n';
        if(focus_op_veld == ''){ focus_op_veld = 'emailadres'; }
        error_veld = 'emailadres';
    }

    if ( melding !== "" )
    {
        if ( focus_op_veld != "" )
        {
            $("#"+focus_op_veld).focus();
        }

        alert('Er is een fout opgetreden: \n' + melding);

        return false;
    }
    else
    {
        return true;
    }
}

/**
 * Invoercontrole voor wachtwoord veranderen formulier
 *
 * @param   string      emailadres
 * @return  boolean
 */
function controleerWachtwoordVeranderen()
{
    var melding = '';
    var focus_op_veld = '';

    if($("#wachtwoord_1").val() == '')
    {
        melding += '- Nieuwe wachtwoord mag niet leeg zijn\n';
        if(focus_op_veld == ''){ focus_op_veld = 'wachtwoord_1'; }
        error_veld = 'wachtwoord_1';
    }

    if($("#wachtwoord_2").val() == '')
    {
        melding += '- Nieuwe wachtwoord herhaald mag niet leeg zijn\n';
        if(focus_op_veld == ''){ focus_op_veld = 'wachtwoord_2'; }
        error_veld = 'wachtwoord_2';
    }

    if (melding == '')
    {
        if($("#wachtwoord_1").val() != $("#wachtwoord_2").val())
        {
            melding += '- Wachtwoorden komen niet overeen\n';
            if(focus_op_veld == ''){ focus_op_veld = 'wachtwoord_2'; }
            error_veld = 'wachtwoord_2';
        }
    }

    if ( melding !== "" )
    {
        if ( focus_op_veld != "" )
        {
            $("#"+focus_op_veld).focus();
        }

        alert('Het wachtwoord kan niet worden veranderd: \n' + melding);

        return false;
    }
    else
    {
        return true;
    }
}

/******************/
/* Menu functions */
/******************/
window.Menu = {
	delay		: 1200,
	timer		: null,
	menuitem	: null,
	
	/**
	 * apply
	 * @param	string	selector
	 */
	apply: function( selector ) {
		$(selector).hover(Menu.open, Menu.setTimer);
		$(document).click(Menu.close);
	},
	
	/** 
	 * cancelTimer
	 */
	cancelTimer: function() {
		if(Menu.timer)	{
			clearTimeout(Menu.timer);
     		Menu.timer = null;
		}
	},
	
	/**
	 * setTimer
	 */
	setTimer: function() {
		Menu.timer = window.setTimeout(Menu.close, Menu.delay);
	},
		
	/** 
	 * close
	 * @param	string	current_menu_id
	 */
	close: function( current_menu_id ) {
		if(Menu.menuitem)	{
			if(Menu.menuitem.data("menuID") != current_menu_id)	
			{
				$("div", Menu.menuitem).css({ height: 'auto', zIndex: "" }).stop().hide();
				$(Menu.menuitem).removeClass("hover");
			}
		}
	},
			
	/** 
	 * open
	 */
	open: function() {
		current_menu = $(this);
		
		current_menu.addClass("hover");
		
		// uniek menu id per submenu, dit om bij het sluiten te checken of niet de actieve wordt gesloten
		if(!current_menu.data("menuID"))	{
			current_menu.data("menuID", (Math.random() +''+ Math.random()).replace(/\./g,""))
		}
		
		Menu.cancelTimer();
		Menu.close( current_menu.data("menuID") );
		Menu.menuitem = current_menu;
		
		$("div", Menu.menuitem).css({ height: 'auto' }).stop().show();	
	}

};

/*****************************************************************/
/* Functie om hele blokken klikbaar te maken, en hover toevoegen */
/*****************************************************************/
$.fn.hoverClick = function()
{
	this.each(function()
	{
		if($("a:first", this).length)
		{
			$(this).hover(
				function() { $(this).addClass("hover").css("cursor", "pointer"); },
				function() { $(this).removeClass("hover").css("cursor", "pointer"); }
			);
			
			$(this).attr("title", $("a:first", this).attr("title"));
			
			$(this).click(function(){
				window.location = $("a:first", this).attr("href");
			});
		}
	});
	
	return this;
};

/** 
 * jquery.defaultvalue 
 * @param	string	defaultvalue
*/
$.fn.defaultvalue = function( defVal )
{
	return this.each(function()
	{
		var $input = $(this);
		if($input.val() == "" || $input.val() == defVal)
		{
			$input.addClass("defaultvalue").val(defVal);
		}
		
		$input
			.focus(function() {
				if($input.val() == defVal) 
					$input.val("").removeClass("defaultvalue");
			})
			.blur(function(){
				if($input.val() == "") 
					$input.addClass("defaultvalue").val(defVal);
			});
	});
};

/**********/
/* Easing */
/**********/
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		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;
	}
});

/**************/
/* Cycle Lite */
/**************/
(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery)


/********************/
/* URL encode in JS */
/********************/
$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
while(x<c.length){var m=r.exec(c.substr(x));
  if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
  }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
  o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
});









