// JavaScript Document
function processDataPwd(doc)
{
	if(doc.getElementsByTagName('error_label')[0] != undefined)
	{
		$('#email').parent().children('SPAN').css({color:'#a32020'});
		document.getElementById('mess').innerHTML = doc.getElementsByTagName('error_label')[0].childNodes[0].data;
	}
	else
	{
		var container = document.createElement("DIV");
		var newChildDiv = document.createElement("DIV");
		
		var newChildH2=document.createElement("H2");
		newChildDiv.appendChild(newChildH2);
		newChildH2.innerHTML = doc.getElementsByTagName('forgot_password')[0].getElementsByTagName('title')[0].childNodes[0].data;

		var newChildP=document.createElement("P");
		newChildDiv.appendChild(newChildP);
		newChildP.innerHTML = doc.getElementsByTagName('forgot_password')[0].getElementsByTagName('desc')[0].childNodes[0].data;

		newChildDiv.style.padding = "20px" ;
		container.appendChild(newChildDiv);
		updateOverlayContent(container.innerHTML);
		$("#overlay_close").css("display", "none");
		$("#overlay_background").click(function(){ hideOverlay();});
	}
}

function processDataEmail_Sharing(doc){
	
	if(doc.getElementsByTagName('error_label')[0] != undefined)
	{
		$('#content_popin').children('SPAN').css({color:'#a32020'});
		document.getElementById('mess').innerHTML = doc.getElementsByTagName('error_label')[0].childNodes[0].data;
		if(doc.getElementsByTagName('error_fields')[0].getElementsByTagName('field_email_sender')[0] != undefined)
		{
			$('#field_email_sender').css({color:'#a32020'});
			if(document.getElementById('field_email_sender').value == '') document.getElementById('field_email_sender').value = doc.getElementsByTagName('field_email_sender')[0].getElementsByTagName('label')[0].childNodes[0].data;
		}
		else $('#field_email_sender').css({color:'#858585'});
		
		if(doc.getElementsByTagName('error_fields')[0].getElementsByTagName('field_email_receiver')[0] != undefined)
		{
			$('#field_email_receiver').css({color:'#a32020'});
			if(document.getElementById('field_email_receiver').value == '')  document.getElementById('field_email_receiver').value = doc.getElementsByTagName('field_email_receiver')[0].getElementsByTagName('label')[0].childNodes[0].data;
		}
		else $('#field_email_receiver').css({color:'#858585'});
		
		if(doc.getElementsByTagName('error_fields')[0].getElementsByTagName('field_id_receiver')[0] != undefined)
		{
			$('#field_id_receiver').css({color:'#a32020'});
			if(document.getElementById('field_id_receiver').value == '')  document.getElementById('field_id_receiver').value = doc.getElementsByTagName('field_id_receiver')[0].getElementsByTagName('label')[0].childNodes[0].data;
		}
		else $('#field_id_receiver').css({color:'#858585'});
		
	}
	else
	{
		var container = document.createElement("DIV");
		var newChildDiv = document.createElement("DIV");
		
		var newChildH2=document.createElement("H2");
		newChildDiv.appendChild(newChildH2);
		newChildH2.innerHTML = doc.getElementsByTagName('labels')[0].getElementsByTagName('title')[0].childNodes[0].data;

		var newChildP=document.createElement("P");
		newChildDiv.appendChild(newChildP);
		newChildP.innerHTML = doc.getElementsByTagName('labels')[0].getElementsByTagName('title_ok')[0].childNodes[0].data;

		var newChildP=document.createElement("P");
		newChildDiv.appendChild(newChildP);
		newChildP.innerHTML = doc.getElementsByTagName('labels')[0].getElementsByTagName('desc_ok')[0].childNodes[0].data;

		newChildDiv.style.padding = "20px" ;
		container.appendChild(newChildDiv);
		updateOverlayContent(container.innerHTML);
		//$("#overlay_close").css("display", "none");
		$("#overlay_background").click(function(){ hideOverlay();});
	}
}

function sendEmail_sharing()
{
	field_id_sender = document.getElementById('field_id_sender').value;
	url_to_share = document.getElementById('url_to_share').value;
	field_id_receiver = document.getElementById('field_id_receiver').value;
	field_email_receiver = document.getElementById('field_email_receiver').value;
	field_email_sender = document.getElementById('field_email_sender').value;
	infosSharing = '{"field_id_sender":"'+field_id_sender+'","url_to_share":"'+url_to_share+'","field_id_receiver":"'+field_id_receiver+'","field_email_receiver":"'+field_email_receiver+'","field_email_sender":"'+field_email_sender+'"}'
	http.open("GET",sHttpRoot +'email_sharing/?display=flash&infosSharing='+encodeURIComponent(infosSharing),true);
	
	http.onreadystatechange = function(){
		if(http.readyState==4){
			if(http.status==200){
				processDataEmail_Sharing(http.responseXML);
			}
		}
	}
	http.send(null);
}

function sendEmail_wishlist(){
	field_id_sender = document.getElementById('field_id_sender').value;
	url_to_share = document.getElementById('url_to_share').value;
	field_id_receiver = document.getElementById('field_id_receiver').value;
	field_email_receiver = document.getElementById('field_email_receiver').value;
	field_email_sender = document.getElementById('field_email_sender').value;
	infosSharing = '{"field_id_sender":"'+field_id_sender+'","url_to_share":"'+url_to_share+'","field_id_receiver":"'+field_id_receiver+'","field_email_receiver":"'+field_email_receiver+'","field_email_sender":"'+field_email_sender+'"}'
	http.open("GET",url_to_share + '?display=flash&infosSharing='+encodeURIComponent(infosSharing),true);
	
	http.onreadystatechange = function(){
		if(http.readyState==4){
			if(http.status==200){
				processDataEmail_Sharing(http.responseXML);
			}
		}
	}
	http.send(null);
}
function sendPwd(){
	email = document.getElementById('email').value;
	infosPassword = '{"email":"'+email+'"}'
	http.open("GET",sHttpRoot +'club/forgot_password/?display=flash&infosPassword='+infosPassword,true);
	
	http.onreadystatechange = function(){
		if(http.readyState==4){
			if(http.status==200){
				processDataPwd(http.responseXML);
			}
		}
	}
	http.send(null);
}
function processDataPopin(doc, sPage, sUrl){

	var container = document.createElement("DIV");
	var newChildDiv = document.createElement("DIV");
	var bgClose = true ;

	switch(sPage){
		
		case "delete_watche":
			
			var newChildSection=document.createElement("DIV");
			newChildSection.style.textAlign = "center" ;

			var newChildText=document.createElement("P");
			newChildSection.appendChild(newChildText);
			newChildText.innerHTML = popinTitle;
			newChildText.style.marginBottom = "25px";
			
			var newChildLink=document.createElement("A");
			newChildSection.appendChild(newChildLink);
			newChildLink.href = 'javascript:hideOverlay();';
			newChildLink.id = "email";
			newChildLink.style.marginRight = "40px";
			newChildLink.innerHTML = popinTitleN;
			
			var newChildLink=document.createElement("A");
			newChildSection.appendChild(newChildLink);
			newChildLink.href = "javascript:"+doc+";";
			newChildLink.id = "email";
			newChildLink.innerHTML = popinTitleY;

			newChildDiv.appendChild(newChildSection);
			bgClose = false ;

		break;
		
		case "add_cart":
		
			sizeSelected = undefined ;

			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = popinTitle;
			
			var newChildLink=document.createElement("DIV");
			newChildDiv.appendChild(newChildLink);
			newChildLink.innerHTML = popinMesure;
			
			var newList=document.createElement("UL");
			newChildDiv.appendChild(newList);
			newList.id = "wishlist_size";
			
			var iMesures = doc.getElementsByTagName('item').length;			
			for(var i= 0; i < iMesures; i++){
				var newElement=document.createElement("LI");
				newList.appendChild(newElement);
				newElement.id = "cart_" + doc.getElementsByTagName('item')[i].getElementsByTagName('size_id')[0].childNodes[0].data;
				newElement.innerHTML = doc.getElementsByTagName('item')[i].getElementsByTagName('size_symbol')[0].childNodes[0].data;
				newElement.setAttribute("onclick", "javascript:updateWishlistSize(" + Number(doc.getElementsByTagName('item')[i].getElementsByTagName('size_id')[0].childNodes[0].data) + ");");
			}
					
			var newList=document.createElement("UL");
			newChildDiv.appendChild(newList);
			newList.id = "wishlist_size_labels";
			
			var newElement=document.createElement("LI");
			newList.appendChild(newElement);
			newElement.innerHTML = doc.getElementsByTagName('family')[0].getElementsByTagName('family_range_small')[0].childNodes[0].data;
			
			var newElement=document.createElement("LI");
			newList.appendChild(newElement);
			newElement.innerHTML = doc.getElementsByTagName('family')[0].getElementsByTagName('family_range_medium')[0].childNodes[0].data;
			
			var newElement=document.createElement("LI");
			newList.appendChild(newElement);
			newElement.innerHTML = doc.getElementsByTagName('family')[0].getElementsByTagName('family_range_large')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("DIV");
			newChildDiv.appendChild(newChildLink);
			newChildLink.id = "popinMess";
			newChildLink.className = "mess";
			
			var newChildLink=document.createElement("DIV");
			newChildDiv.appendChild(newChildLink);
			newChildLink.className = "valide";
			newChildLink.innerHTML = '<a id="email" href="' + popinCart.replace(/\PRODUCT/g,sUrl) + '" >' + popinCartMess + '</a>' ;
			
			var newChildLink=document.createElement("DIV");
			newChildDiv.appendChild(newChildLink);
			newChildLink.className = "valide";
			newChildLink.setAttribute("onclick", "hideOverlay()");
			newChildLink.innerHTML = popinBack;
		
		break;
		
		case "add_wishlist":
		
			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('return_title')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.innerHTML = doc.getElementsByTagName('return_label')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("A");
			newChildDiv.appendChild(newChildLink);
			newChildLink.id = "email";
			newChildLink.href = 'javascript:window.location.reload()';
			newChildLink.style.marginRight = '15px' ;
			newChildLink.innerHTML = doc.getElementsByTagName('btn_label')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("A");
			newChildDiv.appendChild(newChildLink);
			newChildLink.href = sHttpRoot + doc.getElementsByTagName('btn_wishlist')[0].getElementsByTagName('flash_events')[0].getElementsByTagName('level_1')[0].childNodes[0].data + '/' + doc.getElementsByTagName('btn_wishlist')[0].getElementsByTagName('flash_events')[0].getElementsByTagName('level_2')[0].childNodes[0].data + '/';
			newChildLink.id = "email";
			newChildLink.innerHTML = doc.getElementsByTagName('btn_wishlist')[0].getElementsByTagName('label')[0].childNodes[0].data;
		
		break;
		
		case "delete_wish":
		
			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('return_title')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.innerHTML = doc.getElementsByTagName('return_label')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("A");
			newChildDiv.appendChild(newChildLink);
			newChildLink.href = sUrl;
			newChildLink.id = "email";
			newChildLink.innerHTML = doc.getElementsByTagName('btn_label')[0].childNodes[0].data;
			bgClose = false ;
		
		break;
		
		case "delete_wishList":
				
			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('return_title')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.innerHTML = doc.getElementsByTagName('return_label')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("A");
			newChildDiv.appendChild(newChildLink);
			newChildLink.href = sHttpRoot + 'club/home/';
			newChildLink.innerHTML = doc.getElementsByTagName('btn_label')[0].childNodes[0].data;
			bgClose = false ;
		
		break;
		
		case "home_club":

			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('welcome')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.innerHTML = doc.getElementsByTagName('welcome_popin')[0].getElementsByTagName('desc')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.style.margin = "15px 0 15px 0" ;
			newChildText.innerHTML = '<input type="checkbox" id="view_mess" name="view_mess" style="width:auto;" /> ' + doc.getElementsByTagName('welcome_popin')[0].getElementsByTagName('checkbox')[0].childNodes[0].data;
			
			var newChildLink=document.createElement("DIV");
			newChildDiv.appendChild(newChildLink);
			newChildLink.className = "valide";
			newChildLink.innerHTML = '<a id="email" href="javascript:setClubCookie();">' + doc.getElementsByTagName('welcome_popin')[0].getElementsByTagName('btn')[0].childNodes[0].data + '</a>';
		
		break;
		
		case "pwdlost":
		
			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('title')[0].childNodes[0].data;
			
			var newChildText=document.createElement("DIV");
			newChildDiv.appendChild(newChildText);
			newChildText.id = "";
			newChildText.innerHTML = doc.getElementsByTagName('desc')[0].childNodes[0].data;
			
			var newChildInput=document.createElement("INPUT");
			newChildDiv.appendChild(newChildInput);
			newChildInput.id = "email";
			newChildInput.name = "email";
			newChildInput.type = "text";
			
			var newChildLink=document.createElement("A");
			newChildDiv.appendChild(newChildLink);
			newChildLink.id = "email";
			newChildLink.href = "javascript:sendPwd();";
			newChildLink.innerHTML = doc.getElementsByTagName('submit')[0].childNodes[0].data;
			
			var newChildSection = document.createElement("DIV");
			
			var newChildMess=document.createElement("SPAN");
			newChildSection.appendChild(newChildMess);
			newChildMess.id = "mess";
			
			newChildDiv.appendChild(newChildSection);
		
		break;
		
		case "email_sharing":
		case "email_wishlist":	
		
			var newChildH2=document.createElement("H2");
			newChildDiv.appendChild(newChildH2);
			newChildH2.innerHTML = doc.getElementsByTagName('labels')[0].getElementsByTagName('title')[0].childNodes[0].data;
					
			var newChildSection = document.createElement("DIV");
			
			var newChildInput=document.createElement("INPUT");
			newChildInput.id = "field_id_sender";
			newChildInput.name = "field_id_sender";
			newChildInput.type = doc.getElementsByTagName('field_id_sender')[0].getElementsByTagName('type')[0].childNodes[0].data;
			if(doc.getElementsByTagName('force_values')[0].getElementsByTagName('field_id_sender')[0] != undefined) 
			{
				newChildInput.setAttribute("readonly", "readonly");
				newChildInput.setAttribute("value", doc.getElementsByTagName('force_values')[0].getElementsByTagName('field_id_sender')[0].childNodes[0].data);
			}
			else 
			{
				newChildInput.setAttribute("onfocus", "javascript:this.value = ''");
				newChildInput.setAttribute("value", doc.getElementsByTagName('fields')[0].getElementsByTagName('field_id_sender')[0].getElementsByTagName('label')[0].childNodes[0].data);
			}
			newChildInput.origine = newChildInput.value;
			newChildSection.appendChild(newChildInput);
					
			var newChildInput=document.createElement("INPUT");
			newChildSection.appendChild(newChildInput);
			newChildInput.id = "field_email_sender";
			newChildInput.name = "field_email_sender";
			newChildInput.type = doc.getElementsByTagName('field_email_sender')[0].getElementsByTagName('type')[0].childNodes[0].data;
			if(doc.getElementsByTagName('force_values')[0].getElementsByTagName('field_email_sender')[0] != undefined) 
			{
				newChildInput.setAttribute("readonly", "readonly");
				newChildInput.setAttribute("value", doc.getElementsByTagName('force_values')[0].getElementsByTagName('field_email_sender')[0].childNodes[0].data);
			}
			else
			{
				newChildInput.setAttribute("onfocus", "javascript:this.value = ''");
				newChildInput.setAttribute("value", doc.getElementsByTagName('fields')[0].getElementsByTagName('field_email_sender')[0].getElementsByTagName('label')[0].childNodes[0].data);
			}
			newChildInput.origine = newChildInput.value;
			
			newChildDiv.appendChild(newChildSection);
			
			var newChildSection = document.createElement("DIV");

			var newChildInput=document.createElement("INPUT");
			newChildSection.appendChild(newChildInput);
			newChildInput.id = "field_id_receiver";
			newChildInput.name = "field_id_receiver";
			newChildInput.type = doc.getElementsByTagName('field_id_receiver')[0].getElementsByTagName('type')[0].childNodes[0].data;
			newChildInput.setAttribute("value", doc.getElementsByTagName('fields')[0].getElementsByTagName('field_id_receiver')[0].getElementsByTagName('label')[0].childNodes[0].data);
			newChildInput.origine = newChildInput.value;
			newChildInput.setAttribute("onfocus", "javascript:this.value = ''");

			var newChildInput=document.createElement("INPUT");
			newChildSection.appendChild(newChildInput);
			newChildInput.id = "field_email_receiver";
			newChildInput.name = "field_email_receiver";
			newChildInput.type = doc.getElementsByTagName('field_email_receiver')[0].getElementsByTagName('type')[0].childNodes[0].data;
			newChildInput.setAttribute("value", doc.getElementsByTagName('fields')[0].getElementsByTagName('field_email_receiver')[0].getElementsByTagName('label')[0].childNodes[0].data);
			newChildInput.origine = newChildInput.value;
			newChildInput.setAttribute("onfocus", "javascript:this.value = ''");
			
			newChildDiv.appendChild(newChildSection);
			
			var newChildInput=document.createElement("INPUT");
			newChildDiv.appendChild(newChildInput);
			newChildInput.id = "url_to_share";
			newChildInput.name = "url_to_share";
			newChildInput.type = "hidden";
			newChildInput.setAttribute("value", sUrl);
			
			var newChildSection=document.createElement("DIV");

			var newChildLink=document.createElement("A");
			newChildSection.appendChild(newChildLink);
			newChildLink.id = "email";
			if(sPage == 'email_sharing') newChildLink.href = "javascript:sendEmail_sharing();";
			else newChildLink.href = "javascript:sendEmail_wishlist();";
			newChildLink.innerHTML = doc.getElementsByTagName('submit')[0].childNodes[0].data;
			
			newChildDiv.appendChild(newChildSection);
			
			var newChildMess=document.createElement("SPAN");
			newChildMess.id = "mess" ;
			newChildDiv.appendChild(newChildMess);
		
		break;
		
		default:
		case "":

			var newdiv=document.createElement("DIV");
			newChildDiv.appendChild(newdiv);
			newdiv.id = "content_popin";
			newdiv.style.width = "700px" ;
			newdiv.style.height = "400px" ;
				
			var newChildH1=document.createElement("H1");
			newdiv.appendChild(newChildH1);
			newChildH1.innerHTML = doc.getElementsByTagName('items')[0].attributes.getNamedItem("name").value;
			
			var newChildMenu=document.createElement("DIV");
			newdiv.appendChild(newChildMenu);
			newChildMenu.id = "menu";
			newChildMenu.setAttribute("style", "background:none !important;") ;
			
			var newChildListe=document.createElement("UL");
			newChildMenu.appendChild(newChildListe);
			newChildListe.id="menu_options";
			newChildListe.setAttribute("style", "margin-left:500px; width:200px; margin-top:45px;") ;
			

			var newChildContentMask=document.createElement("DIV");
			newdiv.appendChild(newChildContentMask);
			newChildContentMask.id = "mask_pp";
			newChildContentMask.setAttribute("style", "width:470px; height:355px; margin-top:20px; overflow:" + (isMobileDevice ? 'hidden' : 'auto') + "; position:relative;") ;

			var newChildContent=document.createElement("DIV");
			newChildContentMask.appendChild(newChildContent);
			newChildContent.id = "content_pp";
			newChildContent.setAttribute("style", "position:absolute; top:0; left:0;") ;
		
			var mentionsLength = doc.getElementsByTagName('mention').length;
		
			for(var i= 0; i < mentionsLength; i++){
				var newElement=document.createElement("LI");
				newElement.setAttribute("style", "display:block; margin-bottom:0; height:auto; width:auto; line-height:10px; padding-left:15px; background-repeat:no-repeat;") 
				var sId =   doc.getElementsByTagName('mention')[i].attributes.getNamedItem("id").value;
				var sName = doc.getElementsByTagName('mention')[i].attributes.getNamedItem("name").value;
				if(doc.getElementsByTagName('mention')[i].attributes.getNamedItem("menu_name") != undefined){
					var sMenuName = doc.getElementsByTagName('mention')[i].attributes.getNamedItem("menu_name").value;
					if(doc.getElementsByTagName('mention')[i].attributes.getNamedItem("icon") != undefined){
						var sIcone = 'media/popins/cgv/' + doc.getElementsByTagName('mention')[i].attributes.getNamedItem("icon").value + '.png';
					}else{
						var sIcone = 'media/popins/cgv/questions.png';
					}
					newElement.id = "popin_" + sId;
					newChildListe.appendChild(newElement);
					
					newElement.innerHTML = '<a href="javascript:void(0);" onclick="javascript:updateDefaultPopinContentPosition(\'' + sId + '\');" style="padding:10px 0 5px 28px; background:url(' + sIcone + ') left 8px no-repeat;">' + sMenuName + '</a>';
				}
				
				var newElementContent=document.createElement("div");
				newElementContent.id = sId;
				if(doc.getElementsByTagName('mention')[i].childNodes[0] != undefined){
					var sContent = doc.getElementsByTagName('mention')[i].childNodes[0].data;
					newChildContent.appendChild(newElementContent);
					var newChildH2=document.createElement("H2");
					if(i > 0) newChildH2.style.marginTop = "25px" ;
					newElementContent.appendChild(newChildH2);
					newChildH2.innerHTML = sName;
					var newChildP=document.createElement("P");
					newElementContent.appendChild(newChildP);
					newChildP.innerHTML = sContent;
				}
			}
			
		break;
	}
	
	newChildDiv.style.padding = "20px" ;
	container.appendChild(newChildDiv);
	updateOverlayContent(container.innerHTML);
	//$("#overlay_close").css("border", "1px solid #ffcc00;");
	if(bgClose) $("#overlay_background").click(function(){ hideOverlay();});
	if(sPage == 'faq' || sPage == 'cgv') setDragOnDefaultPopin();
}

function setDragOnDefaultPopin()
{
	var popin_mask = document.getElementById('overlay_tab');
	var popin_content_mask = document.getElementById('content_pp');
	popin_mask.iCurrentPosY = 0 ;
	popin_mask.touchY = 0 ;
	popin_mask.gapY = 0 ;
	popin_mask.iHeight = $(popin_content_mask).innerHeight(true) ;
	popin_mask.iMaxHeightForScroll = 355 ;
	
	popin_mask.addEventListener('touchstart', function(e) {
	 
		var touch = e.touches[0];
		this.iCurrentPosY = Number(touch.pageY) ;
		this.touchY = this.iCurrentPosY ;
		if(!this.startY) this.startY = 0 ;
				
	}, false);
			
	popin_mask.addEventListener('touchmove', function(e) {
	 
		var touch = e.touches[0];
		this.iCurrentPosY = this.startY + Number(touch.pageY) - this.touchY ;
		popin_content_mask.style.top = this.iCurrentPosY + 'px' ;
//		document.getElementById("logo").innerHTML = this.iCurrentPosY + " => " + Number(this.iHeight - this.iMaxHeightForScroll);
				
	}, false);
	
	popin_mask.addEventListener('touchend', function(e) {
 
		var _top  = Number(popin_content_mask.style.top.replace('px', '')) ;
		if(_top > 0) 
		{
			_top = 0 ;
			$(popin_content_mask).animate({top:_top, duration:200}, "easein", function (){}) ;
		}
		else if(_top < 0 - Number(this.iHeight - this.iMaxHeightForScroll))
		{
			_top = 0 - Number(this.iHeight - this.iMaxHeightForScroll) ;
			$(popin_content_mask).animate({top:_top, duration:200}, "easein", function (){}) ;
		}
		this.startY = _top ;
			
	}, false);
}

function updateDefaultPopinContentPosition(pLabel)
{
	var popin_mask = document.getElementById('mask_pp');
	var popin_content_mask = document.getElementById('content_pp');
	var _top = document.getElementById(pLabel).offsetTop;
	popin_content_mask.style.top = Number (0 - _top) + "px" ;
	popin_mask.startY = _top ;
}

function openPopin(sPage, sPath, sUrl){
	http.open("GET",sPath,true);
	
	http.onreadystatechange = function(){
		if(http.readyState==4){
			if(http.status==200){
				processDataPopin(http.responseXML, sPage, sUrl);
			}
		}
	}
	http.send(null);
}
