/**
 * Utilitaires collections
 *
 * Rev 0.41 du 2009/09/29
 * - fix ré-entrance preview ajax
 * Rev 0.4 du 2009/09/22
 * - ré-écriture select country/subregion/region
 * Rev 0.3 du 2009/08/07
 * - +jquery
 */

/**
 * Affiche message fixe
 * @param string html
 */
function window_info(html) {
	var cr = $("#window-confirm");	
	cr.find(".win-content").html(html);
	cr.find("a.close, a.continue").click(
		function() {
			cr.hide();
		}
	);
	cr.show();
	centerInWindow(cr);
}

/**
 * Affiche message fugitif
 * @param string html
 */
function msg_return(html) {
	var cr = $("#msg-return");
	cr.find(".win-content").html(html);
	centerInWindow(cr);
	cr.show(10, 
		function(){
			setTimeout(
				function() {
					$("#msg-return").hide("slow");
				}
				, 2000
			);
		}
	);
}

// jquery start point
$(document).ready(
	
	function() 
	{
		var	COLL_CONTEXT;
		var country_datas = new Array;
		// localisation
		var	loc = {country:'', region:'', subregion:''};

		// queue des liens ajouter/enlever concernés par des actions
		var queue	= new Array;
		var handled = new Array;		
		// On positionne l'url de base ré-encodée correctement 
		var there = rawurldecode(window.location);
		jQuery.url.setUrl(there);

		COLL_CONTEXT = jQuery.url.attr("path").match(/\/etat-civil\//) ? "etat-civil" : "";

		/*
		 * traitement de la queue de caddie
		 */
		function handle_cart_queue(handled_a) {
			// lien déjà traité
			if (handled_a) {
				handled.push(handled_a);
			}
			var a;								
			if (queue.length > 0) {
				// lien courant restant dans la file
				a = queue.shift();									
			}
			else {
				// mise à jour des status des liens cart avec le dernier lot
				var cura;
				while(cura = handled.pop()) {
					// remplace le "vieux" lien par le nouveau
					cura.old.replaceWith(cura.newlink);										
				}
				return false;
			}

			
			var cart_action_url = a.attr('href')+"&ajax=1&context="+jQuery.url.param('action');
			a.trigger("waiting");

			$.get( cart_action_url
				, false
				,function(data, text_status) {
					var newlink = $(data).find("#current-status a");
					// lien caddie expiré ?
					if (newlink.hasClass("cart-expired")) {
						// redirige
						document.location = newlink.attr("href");
						return false;
					}

					if (jQuery.url.param("action") != "viewcart") {
 						// mode liste
						window_info($(data).find("#cart-action-done"));
					}
					else {											
						// mode vue finale du caddie						
						msg_return($(data).find("#cart-action-msg"));
						a.parents(".acte-unit").find(".rendered-preview").toggleClass("grayed", newlink.hasClass("addable"));
					}
					// mise a jour etat caddie
					$(".cart-summary").html($(data).find(".cart-summary").html());
					$(".cart-summary").show();
					// etat points
					$(".cart-points").html($(data).find(".cart-points").html());
					$(".cart-points").show();
					// panier vide ou credit faible
					var credit_low = $(data).find("#credit-low").length > 0;
					var cart_empty = $(data).find("#cart-empty").length > 0;					
					$("#order-button").toggle( ! credit_low && ! cart_empty);
					$("#low-credit").toggle(credit_low);
					// on est revenu, on peut continuer à dépiler
					handle_cart_queue({ 'old'	 	:a
										// nouveau lien renvoyé par le script
									,	'newlink'	:newlink
									});
				}
				, "html"
			);
			return false; 
		}

		// preload des messages à partir des traductions cachées si pas loadées
		if (typeof(MESSAGES) !="undefined"
		&&	! MESSAGES.length) 
		{
			$("#hidden-translations dt").each( 
				function() { 
					MESSAGES[$(this).text()] = $(this).next().text();
				}
			);	
		}

		/*
		 * Init loc
		 */
		function init_loc(loc) {
			loc.country 	= $("#country-select").val();
			loc.region		= $("#region-select").val();
			loc.subregion	= $("#subregion-select").val();
		}

		// changement de pays
		$("#country-select").change(
			function() {		
				loc.country = $(this).val();
				loc.region = false;
				loc.subregion= false;
				handle_loc(loc);
			}
		);

		// changement de région
		$("#region-select").change(
			function() {
				loc.region = $(this).val();
				loc.subregion = false;
				handle_loc(loc);
			}				
		);

		// changement de sous-région
		$("#subregion-select").change(
			function() {				
				loc.subregion=$(this).val();
				// le changement de subregion implique-t-il un changement de region ?
				if (loc.subregion !=false) {
					loc.region = false;
				}
				handle_loc(loc);
			}
		);
		
		// prise en charge d'un changement de localisation géo
		function handle_loc(loc) {
			if (!country_datas[loc.country]) {
				// obtenir les country_datas si ne les a pas
				$.get(new url_builder({'action':"country_datas", 'country': loc.country}, jQuery.url.attr("path")).toString()
					, false
					, function(data, text_status) {
							country_datas[loc.country] = data;
							handle_loc(loc);
							return;
					}
					, "json"
				);
				return;
			}
			else {
				// données dispo - déterminer l'état final de loc
				if (loc.region 		== false
				&&	loc.subregion	!= false)
				{
					// region en fonction de subregion
					loc.region = country_datas[loc.country].subregions[loc.subregion].region;
				}
				// regions
				build_region_select(loc);
				// subregions
				build_subregion_select(loc);
			}
		}

		/*
		 * Construction régions
		 */
		function build_region_select(loc) {
			var rs = $("#region-select");
			var w = rs.get(0).offsetWidth;
			rs.empty();
			var filled = 0;
			for(var p in country_datas[loc.country].regions) {
				rs.append(new select_option(p, country_datas[loc.country].regions[p].title).toString());
				filled++;
			}

			if (filled) {
				rs.prepend(new select_option('', "--- "+ i18('coll_choisir_region')+" ---").toString());
				rs.val(loc.region ? loc.region : '');
			}
			else {
				rs.prepend(new select_option('',"--- "+i18('coll_no_region')+" ---").toString());
			}
			// fix IE7 sur redimensionnement non souhaité
			rs.get(0).style.width= w+"px";
		}

		/*
		 * Construction sous-régions
		 */
		function build_subregion_select(loc) {
			var ss = $("#subregion-select");
			var w = ss.get(0).offsetWidth;
			ss.empty();
			var filled =0;
			for(var s in country_datas[loc.country].subregions) {			
				if (!loc.region 
				||	 loc.region == country_datas[loc.country].subregions[s].region)
				{
					// sans ou avec filtre par region
					ss.append(new select_option(s, country_datas[loc.country].subregions[s].full_title).toString());
				}
				filled++;
			}
			if (filled) {
				ss.prepend(new select_option('',"--- "+i18('coll_choisir_subregion')+" ---").toString());
				ss.val(loc.subregion ? loc.subregion : '');
			}
			else {
				ss.prepend(new select_option('',"-- "+i18('coll_no_subregion')+" ---").toString());
			}			
			// fix IE7 sur redimensionnement non souhaité
			ss.get(0).style.width= w+"px";
		}

		// bind les évenements custom sur l'indicateur d'etat
		$(".g3-results .show-preview").each(
			function() {
				// action sur waiting
				$(this).bind("waiting", 
					function() {
						$(this).find("span").removeClass().addClass("waiting");
					}
				);
				// déployé
				$(this).bind("deployed", 
					function() {
						$(this).html(i18('coll_masquer_detail')+"<span>&nbsp;</span>");
						$(this).find("span").removeClass().addClass("deployed");
					}
				);
				// clear
				$(this).bind("clear", 
					function() {
						$(this).html(i18('coll_voir_detail')+"<span>&nbsp;</span>");
						$(this).find("span").removeClass();
					}
				);
			}
		);
		var preview_encours;
		// preview acte
		$(".g3-results .show-preview").click(
			function() {	
				// l'ancetre tr dans cette table
				var	tr	= $(this).parents(".g3-results tr");
				var a = $(this);

				// déployée ?
				if (tr.hasClass("deployed")) {
					// on la replie
					tr.removeClass("deployed");
					tr.next().remove();
					a.trigger("clear");
					return false;
				}
				var url = $(this).attr('href')+"&ajax=1";
				// verrou
				if (preview_encours) {
					return false;
				}
				preview_encours = true;


				// action sur waiting
				a.trigger("waiting");

				$.get( url
					, false
					,  function (data, text_status) {
							// affiche le preview
							tr.addClass("deployed");
							// croix de fermeture pointant sur le lien de déploiement
							var c = $("<div>"+data+"</div>");
							tr.after("<tr><td colspan='9'>"+c.html()+"</td></tr>");
							tr.next().find("a.close").click(								
								function() {
									a.click();
									return false;
								}								
							);

							a.trigger("deployed");

							// clear du spinner
							function do_clear() {
								$(this).find("span").removeClass();
							}
							// fin de l'encours
							preview_encours = false;
						}
					, "html"
				);
				return false;
			}	
		);

		/*
		 * fonction "globales"
		 */
		// spinner	
		function do_spin() {
			$(this).find("span").removeClass().addClass("waiting");
		}

		/*
		 * Fonctions d'initialisation
		 */
		function init_etat_civil() {
			// initialiser la localisation
			init_loc(loc);
			// cacher la fenetre de confirmation
			$("#window-confirm").hide();
			// handler des spinners
			$("a.cart").live("waiting", do_spin);
			// Il faut binder "live" les actions sur les liens carts
			$("a.cart").live("click", 
				function() {
					queue.push($(this));
					return handle_cart_queue(); // false
				}								
			);
	
			// cacher résumé caddie
			$(".cart-summary").addClass("no-view");
			// pour ne pas cacher
			var ts = (new Date).getTime();
			// Obtenir le résumé du caddie en mode etat-civil
			$.get(new url_builder({	'action':		"summarycart"
								,	'ajax':			1 
								, 	'ts':			ts
								}, jQuery.url.attr("path")).toString()
				, false
				, function(data, text_status) { 
						if (data) {
							$(".cart-summary").html($(data).find(".cart-summary").html());
							$(".cart-summary").removeClass("no-view");
						}
				}
				, "html"
			);
			// mode search + preview ?
			if (jQuery.url.param('action') == "search"
			&&	jQuery.url.attr("anchor")  == "preview")
			{			
				$("a.show-preview").click();
			}	

			// Obtenir les documents relateds si on a un doc_id en mode viewdoc
			var doc_id = jQuery.url.param('doc_id');
		
			if (jQuery.url.param('action') == "viewdoc"
			&&	doc_id ) 
			{
				$.get(new url_builder({	'action':	"related_docs"
									,	'doc_id':	doc_id
									,	'ajax':		1 
									,	'ts':		ts
									}, jQuery.url.attr("path")).toString()
					, false
					, function(data, text_status) { 
							if (data) { 
								$("#related-docs").html(data);
								$("#related-docs").show();
							}
					}
					, "html"
				);		
			}
			// ":" pour les labels
			$("#search-form label").each(function() {$(this).html($(this).html()+" :");});
	
			// les cercles 
			$("#cercles > ul > li").each(
				function() {	
					$(this).removeClass().addClass("closed");
				}
			);
			// deployer / fermer
			$("#cercles h3 a").click(
				function() {
					$(this).parents("li").toggleClass("closed");
					return false;
				}
			);
			// limiter
			$("#cercles a.limit-cercle").click(
				function() {
					$("#limit-cercle select").val(jQuery.url.setUrl($(this).attr("href")).param("cercle"));
					msg_return(i18('coll_ec_cercle_active').replace(/XXXCERCLEXXX/, "<br />&quot;"+$("#limit-cercle select").find(':selected').text()+"&quot;"));
					return false;
				}
			);
		}

		/*
		 * Initilisations
	 	 */
		if (COLL_CONTEXT == "etat-civil") {
			init_etat_civil();
		}
 	}
);

/*
 * notification de la fenètre principale
 * de la fin du chargement d'une fille (ou d'elle-même)
 * Appel de la function de nom 'func_name', et affichage
 * de l'élément d'id 'id' si retour de func_name == false
 * @param object window win
 * @param string func_name
 * @param string id
 */
function notify(win, func_name, id) {
	// appelle la fonction dont le nom est passé en paramètre
	if (! self[func_name]()) {
		var p = win.document.getElementById(id);
		if (p) {
			p.style.display="block";
		}
		else {
			p.style.display="none";
		}
	}
}

/*
 * toggle
 * @param DOMNode n
 */
function toggle(n) {
	var targid = n.id.replace(/^[^-]+-/, '');
	var cible = document.getElementById(targid);

	if (! cible) {
		return;
	}
	// complémente l'état
	set_state(cible, ! get_state(cible));

	// si on cache
	if (get_state(cible) == false) {
		// on efface les éventuels input ajoutés
		delete_excluders(cible);
		// et le contenu restant des inputs
		reset_includers(cible);
	}
}

/*
 * Affiche / cache lien direct livre/page
 */
function show_dl(e) {
	var inp = getPrevSibling(e);

	if (e.className =='plus') {
		// montre
		e.className='moins';
		inp.style.display='inline'; 
		inp.style.width=Math.ceil(0.5 * inp.value.length)+'em';
		inp.select();
	}
	else {
		// cache
		e.className='plus';
		inp.style.display='none';
	}	
}
/*
 * explications privilege / payant
 */
function explain(p) {
	var cible	= document.getElementById(p.id.replace(/explain/, 'explication'));	
	var father	= document.getElementById(p.id.replace(/explain/, 'presentation'));

	if (! cible || !father) {
		return;
	}

	var strong = (p.getElementsByTagName('strong'))[0];	
	var x = strong.offsetLeft - 313 + Math.ceil(strong.offsetWidth /2);
	var y = strong.offsetTop + strong.offsetHeight;

	cible.style.left= x+"px";
	cible.style.top	= y+"px";
	cible.style.display="block";
	cible.style.zIndex=2;
	father.onmouseout = function(e) {
							if (!e) {
								e = window.event;

							}
							var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
							if (!reltg) {
								return;
							}
							// si la target n'a pour parent le pere, on reste
							if (! has_ancestor(reltg,father)) 
							{
								cible.style.display="none";
							}
						};
}

// supprime les excluders
function delete_excluders(cible) {
	var excluders = get_children_by_class(cible, 'excluder');
	if (excluders) { 
		for(var i = excluders.length - 1; i>=0; i--) {
			excluders[i].parentNode.removeChild(excluders[i]);
		}
	}
}

// reset les includers
function reset_includers(cible) {
	var includers = get_children_by_class(cible, 'includer');	
	if (includers) {
		for(var i = includers.length - 1; i>=0; i--) {
			// efface le contenu du champ
			((includers[i].getElementsByTagName('input'))[0]).value="";
		}
	}
}

// les with_words renseignés
function with_words() {
	return words('with-words');
}

// les without_words renseignés
function without_words() {
	return words('without-words');
}

// les mots 
function words(id) {
	var words = [];
	var e=document.getElementById(id);
	var excluders= get_children_by_class(e, 'excluder');
	if (!excluders) {
		return words;
	}
	for(var i = excluders.length - 1; i>=0; i--) {
		if (((excluders[i].getElementsByTagName('input'))[0]).value) {
			words.push( ((excluders[i].getElementsByTagName('input'))[0]).value );
		}
	}
	return words;
}

// affiche  simple
function show(id) {
	var e = document.getElementById(id);
	if (!e) {
		return;
	}
	e.style.display="block";
}

// masque simple
function hide(id) {
	var e = document.getElementById(id);
	if (!e) {
		return;
	}
	e.style.display="none";
}

// affiche ou masque
function set_state(e, state) {
	if (! e) {
		return;
	}
	// le lien
	var a  = document.getElementById("toggle-" + e.id);
	e.style.display= (state ? "block" : "none");
	a.className=(state ? "moins" : "plus");
}

// renvoie le status d'affichage
function get_state(e) {
	if (!e) {
		return false;
	}
	return (e.style.display == "none" ? false : true);
}


/*	
 * ajoute un champ de saisie d'identifiant
 * @param node n
 */
function add_field(n) {
	// determine le div parent du lien
	var div_p = n.parentNode;
	// le clone pour obtenir un nouveau +
	var	div_n = div_p.cloneNode(true);
	// on initialise à vide la valeur du nouveau
	((div_n.getElementsByTagName("input"))[0]).value = '';
	// que l'on ajoute à la liste existante
	div_p.parentNode.appendChild(div_n);

	// l'actuel devient un excluder
	div_p.className="excluder";
	// et on change le lien
	var a =	((div_p.getElementsByTagName("a"))[0]);
	// ainsi que le petit libellé de son span
	((a.getElementsByTagName("span"))[0]).innerHTML = "-";
	// l'attribut onclick de son lien fils (fermeture)
	a.onclick = 
		function() {
			remove_field(n);
		}
}	

/*	
 * enleve un champ de saisie d'identifiant
 * @param node n
 */
function remove_field(n) {
	// determine le div parent du lien
	var div_p = n.parentNode;
	// que l'on supprime !
	div_p.parentNode.removeChild(div_p);
}

/**
 * Elements fils par classe
 * qqsoit leur nom
 */
function get_children_by_class(e, class_name) {
	var ret = [];
	if (!e) {
		return;
	}
	var elements = e.getElementsByTagName('*');

	for (var i = 0; i < elements.length; i++) {
		if (elements[i].nodeType == 1
		&&	elements[i].className
		&&	elements[i].className == class_name
		) 
		{
			ret.push(elements[i]);
		}
	}
	return ret;
}

/**
 * Elements remplissant une condition
 */
function getElementsBy(tag,attr,val) {
  var tabOut = [];
  var elements = document.body.getElementsByTagName(tag);
  for (i = 0; i < elements.length; i++) {
    if (attr == 'class') {
      if (elements[i].className == val) {
        tabOut.push(elements[i]);
      }
    }
    else {
      if (elements[i].getAttribute(attr) == val) {
        tabOut.push(elements[i]);
      }
    }
  }
  return tabOut;
}

/**
 * 2008/09/29
 * Détection du support du PDF
 * inspiré de http://www.builtfromsource.com/2007/06/26/detecting-plugins-in-internet-explorer-and-a-few-hints-for-all-the-others/
 * @return true on success
 */
function acroread_plugin_detect() { 
	var isInstalled = false;  
	var version = null;  

	if (window.ActiveXObject) {  
 		var control = null;  
 		try {  
   			// AcroPDF.PDF is used by version 7 and later  
       		control = new ActiveXObject('AcroPDF.PDF');  
    	}
		catch (e) {  
        	// Do nothing  
     	}  

   		if (!control) {  
	        try {  
    	       // PDF.PdfCtrl is used by version 6 and earlier  
    	      control = new ActiveXObject('PDF.PdfCtrl');  
    	    } 
			catch (e) {  
				return false;  
      		}  
    	}  

    	if (control) {  
			return true;		
     	}  
 	} 
	else {  
		// Firefox style : On ne cherche pas par nom/description de l'objet, mais par support du mime-type
		var p = navigator.plugins;
		for(var i=0; i<p.length; i++) {
			// on cherche si l'un des plugins supporte le mime-type pdf
			for(var prop in p[i]) {	
				if (typeof(p[i][prop]) == "object"
				&&	p[i][prop].type == "application/pdf")
				{
					return true;
				}
			}
		}
 	} 
	return false;
}

/**
 * Hacks pour firefox qui n'ignore pas
 * les whitespaces
 * Courtesy http://www.agavegroup.com/?p=32
 */
function getNextSibling(startBrother){
  endBrother=startBrother.nextSibling;
  while(endBrother && endBrother.nodeType!=1){
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}
// et la copine...
function getPrevSibling(startBrother){
  endBrother=startBrother.previousSibling;
  while(endBrother && endBrother.nodeType!=1){
    endBrother = endBrother.previousSibling;
  }
  return endBrother;
}

/**
 * verifie si ancetre
 */
function has_ancestor(node, ancestor) {
	
	var daddy = node.parentNode;
	
	while (daddy) {
		if( daddy == ancestor) {
			return true;
		}
		daddy = daddy.parentNode;
	} 	
	return false;
}
/**
 * Objet option de select
 */
function select_option(opt_value, opt_text) {
	this.opt_value= opt_value;
	this.opt_text = opt_text;

	this.toString = function toString() {
		if (!this.opt_text) {
			this.opt_text = this.opt_value;
		}
		return '<option value="'+this.opt_value+'">'+this.opt_text+'</option>';
	}
}

/**
 * Courtesy of http://phpjs.org/
 */
function rawurldecode( str ) {
    // Decodes URL-encodes string  
    // 
    // version: 907.503
    // discuss at: http://phpjs.org/functions/rawurldecode
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Ratheous
    // *     example 1: rawurldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin+van+Zonneveld!'
    // *     example 2: rawurldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: rawurldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    // *     example 4: rawurldecode('-22%97bc%2Fbc');
    // *     returns 4: '-22—bc/bc'
    var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';

    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    // The hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';


    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }

    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = ret.replace(/%([a-fA-F][0-9a-fA-F])/g, function (all, hex) {return String.fromCharCode('0x'+hex);}); // These Latin-B have the same values in Unicode, so we can convert them like this
    ret = decodeURIComponent(ret);

    return ret;
}

/*
 * Courtesy http://www.setaou.net/yag.php
 */
// Center an object in the browser viewport
function centerInWindow(obj)
{
    var _object = $(obj);
    var _document = $(document);

    _object.css({
        left: getViewportSize().width / 2 - _object.outerWidth() / 2 + _document.scrollLeft(),
        top: getViewportSize().height / 2 - _object.outerHeight() / 2 + _document.scrollTop()
    });
}


// Return the size of the *browser* viewport
getViewportSize = function ()
{
    // Normal browsers
    if (typeof window.innerWidth != 'undefined')
        return {width: window.innerWidth, height: window.innerHeight};
    // IE6
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
        return {width: document.documentElement.clientWidth, height: document.documentElement.clientHeight};
    // Older
    else
        return {width: document.getElementsByTagName('body')[0].clientWidth, height: document.getElementsByTagName('body')[0].clientHeight};
}

/**
 * @param object ar_params
 * @param string path_value
 * @param string host
 * @param string protocol
 */
function url_builder() {
	this.params 	= {};
	this.path		= false;
	this.hostv		= false; 
	this.proto		= "http";

	this.set_params =( function set_params(params) {
		for(var i in params) { 
			this.params[i] = params[i];
		}
	});
	
	this.set_path = function set_path(path_value) {
		this.path = path_value;
	}

	this.toString = function toString() {
		var s = '';
		if (this.hostv) {
			s = s+this.proto+"://"+this.hostv;
		}

		s = s+ this.path;
		var q_string = jQuery.param(this.params);
		if (q_string) {	
			s = s + "?" + q_string;
		}
		return s;
	}

	if (arguments[0]) {	this.set_params(arguments[0]);	}
	if (arguments[1]) { this.path	= arguments[1];		}
	if (arguments[2]) { this.hostv	= arguments[2];		}
	if (arguments[3]) { this.proto	= arguments[3];		}

}