var bShowslashr = false;
var bEscapegtlt = false;

function getURL(p_url)
		{
		opener.location.href=p_url;
		window.close();
		}
		
function replace(str, original, replacement) {
	var result;
	result = "";
	while(str.indexOf(original) != -1) {
		if (str.indexOf(original) > 0)
			result = result + str.substring(0, str.indexOf(original)) + replacement;
		else
		result = result + replacement;
		str = str.substring(str.indexOf(original) + original.length, str.length);
	}
	return result + str;
}

function parse(p_object) {
	var strParse = p_object;
	strParse = replace(strParse, "\\", "\\\\");
	if (bShowslashr)
		strParse = replace(strParse, "\r", "\\r");
	else
		strParse = replace(strParse, "\r", "");
		// strParse = replace(strParse, '"', '\\"');
		// strParse = replace(strParse, "'", "\\'");
		// strParse = replace(strParse, "\t", "\\t");

	if (bEscapegtlt) {
		strParse = replace(strParse, "<", "\\<");
		strParse = replace(strParse, ">", "\\>");
	}
        
	while(strParse.indexOf("\n") != -1)
		strParse = strParse.substring(0, strParse.indexOf("\n")) + "\\n" + strParse.substring(strParse.indexOf("\n") + 1, strParse.length);
		return (strParse);
	}

function showslashr() {
	bShowslashr = !bShowslashr;
	parse();
}

function escapegtlt() {
	bEscapegtlt = !bEscapegtlt;
	parse();
}


function openWindow(p_file,p_windowName,p_width,p_height)
{
	var p_windowOptions = '"toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,'+p_width+','+p_height+'"';
	window.open(p_file,p_windowName,p_windowOptions);
}

  function jumpPage(newLoc) {
   newPage = newLoc.options[newLoc.selectedIndex].value

   if (newPage != "") {
    window.location.href = newPage
  }
  }
  
 
	function getDocuments(newURL)
	{
		var l_countitem = document.eventtype.event.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.eventtype.event.options[i].selected==true) {
				l_value=document.eventtype.event.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&event=' + l_value;
	//	}
	}  
	
	function getLink(newURL)
	{
		var l_countitem = document.linktype.lid.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.linktype.lid.options[i].selected==true) {
				l_value=document.linktype.lid.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&lid=' + l_value;
	//	}
	}  
	
	function getAvis(newURL)
	{
		var l_countitem = document.listepub.pub.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.listepub.pub.options[i].selected==true) {
				l_value=document.listepub.pub.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&pub=' + l_value;
	//	}
	}  
	function getAvisDate(newURL)
	{
		var l_countitem = document.listepub.an.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.listepub.an.options[i].selected==true) {
				l_value=document.listepub.an.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&an=' + l_value;
	//	}
	}  
	function getAvisDate2(newURL)
	{
		var l_countitem = document.listepub2.anp.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.listepub2.anp.options[i].selected==true) {
				l_value=document.listepub2.anp.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&anp=' + l_value;
	//	}
	}  

function getSubscriptionForm(p_subscriptionType,p_subscriptionNumber,p_subscriptionTitle,p_subscriptionDate,p_subscriptionPrice,p_subscriptionComment)
{
  /*      document.Subscription.Number.value=p_subscriptionNumber;
        document.Subscription.Title.value=p_subscriptionTitle;
        document.Subscription.Date.value=p_subscriptionDate;
        document.Subscription.Price.value=p_subscriptionPrice;
        document.Subscription.Comment.value=p_subscriptionComment;
        document.Subscription.URL.value=location.href;*/
	   if (p_subscriptionType == "Formation - FR"){
        	openWindow('/pls/CDM/!Fmt_SubscriptionForm?lng=FR&tid=1&num='+ p_subscriptionNumber + '&title=' + p_subscriptionTitle + '&dt='+ p_subscriptionDate + '&price=' + p_subscriptionPrice + '&comment=' + p_subscriptionComment ,'Inscription','width=600','height=460');
        }
        else if (p_subscriptionType == "Formation - DE"){
//        	openWindow('www.chambre-des-metiers.lu/pls/CDM/Fmt_SubscriptionForm?lng=DE','Inscription','width=600','height=460');
        	openWindow('/pls/CDM/!Fmt_SubscriptionForm?lng=DE&tid=1&num='+p_subscriptionNumber +'&title=' +p_subscriptionTitle+'&dt='+p_subscriptionDate+'&price='+p_subscriptionPrice+'&comment=' +p_subscriptionComment,'Inscription','width=600','height=460');
        }
        else if (p_subscriptionType == "Evénement - FR"){
        	//openWindow('www.chambre-des-metiers.lu/pls/CDM/Fmt_SubscriptionForm?lng=FR','Inscription','width=600','height=460');
        	        	openWindow('/pls/CDM/!Fmt_SubscriptionForm?lng=FR&tid=2&num='+p_subscriptionNumber +'&title=' +p_subscriptionTitle+'&dt='+p_subscriptionDate+'&price='+p_subscriptionPrice+'&comment=' +p_subscriptionComment,'Inscription','width=600','height=460');
        }
}

function getFormInfo(subject, comm, contact, mail) 
{
	var my_url="";
	var the_url=location.href;
	var where_is_lg=the_url.indexOf('lng=');
	var lng=the_url.charAt(where_is_lg+4) + the_url.charAt(where_is_lg+5);
	//alert(the_url);
	//alert(lng);
	openWindow('/pls/CDM/GetAskForm?lng='+lng + '&subject='+subject+'&comm='+comm+'&contact='+contact+'&mail='+mail+'&url='+my_url+'','Information','width=600','height=460');
}

	function getMetier(newURL)
	{
		var l_countitem = document.listemetier.idMetier.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.listemetier.idMetier.options[i].selected==true) {
				l_value=document.listemetier.idMetier.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&idMetier=' + l_value;
	//	}
	} 
	
	function getgroupeMetier(newURL)
	{
		var l_countitem = document.listemetier.idgroupeMetier.options.length;
		var l_value = "";
		for (i=0;i<=l_countitem;i++) {
			if ( document.listemetier.idgroupeMetier.options[i].selected==true) {
				l_value=document.listemetier.idgroupeMetier.options[i].value;
				break;
			}
		}
	//	if (l_value == ""){
			//alert("Veuillez sélectionner un type d''évènement")
		//	location.href='"' + newURL + '"';
	//	}
//		else{
			location.href= newURL + '&idMetier=' + l_value;
	//	}
	} 
	