// MENU DES LANGUES

function myopen(code, winCible)
{
//	alert("myopen : " + code);
//	var isLang = false ;
//	for ( var i=0 ; menuLang["code"][i] != undefined ; i++ )
//	{
//		if ( code == menuLang["code"][i] )
//		{
//			isLang = true ;
//			top.location = "/"+code ;
//		}
//	}
	
//	if(code != '' && !isLang)
	if(code != '')
	{
		top.location=code;
	}
}

function newLang(code, lib)
{
//	alert(code + " : " + lib);
	menuLang["code"][menuLang["code"].length] = code ;
	menuLang["lib"][menuLang["lib"].length] = lib ;
}

function mkLangues(option)
{
	menuLang = new Array() ;
	menuLang["code"] = new Array() ;
	menuLang["lib"] = new Array() ;

	newLang("en", "English") ;
	newLang("fr", "Français") ;
	newLang("es", "Español") ;
	newLang("pt", "Portugues") ;
	newLang("de", "Deutsch") ;
	newLang("tr", "Türkçe") ;
	newLang("pl", "Polski") ;
//	newLang("it", "Italiano") ;
}

function mkMenuLang()
{
	mkLangues() ;
	mySelector = '<FORM name="directos">'
	+ '<SELECT class="selectlang" name="direct" onChange="myopen(directos.direct.options[selectedIndex].value);">' ;

	for ( var i=0 ; i < menuLang["code"].length ; i++ )
	{
		if ( nd_lang == menuLang["code"][i] )
		{
			selection = " selected" ;
		}
		else
		{
			selection = "" ;
		}

		if ( nd_lang != "en" )
		{
			nd_Chemin = "../" ;
		}
		else
		{
			nd_Chemin = "" ;
		}

		mySelector += '<OPTION value="' + nd_Chemin + menuLang["code"][i] + '/"' + selection + '>' + menuLang["lib"][i] + '</OPTION>' ;
	}

	mySelector += "</select></form>" ;
	document.write(mySelector) ;
}

function nd_newRub(nom_en, nom_fr, nom_es, nom_pt, nom_de, nom_tr, nom_pl)
{
	nd_selector += '<option value="' + nd_nOptions + '" class="selectrub" disabled>&gt;&gt; ' + eval("nom_"+nd_lang) + '</option>' ;
	nd_nOptions++ ;
}

function newDisaster(code, nom_en, nom_fr, nom_es, nom_pt, nom_de, nom_tr, nom_pl)
{
	var cssNew = '' ;
	if ( able["promo"][code] )
	{
		cssNew = ' class = "selectNew"' ;
	}
	nd_selector += '<option' + cssNew + ' value="' + code + '">' + eval("nom_"+nd_lang) + '</option>' ;
//	nd_selector += '<option value="' + code + '">' + eval("nom_"+nd_lang) + '</option>' ;
	nd_option[nd_option.length] = nd_nOptions ;
	ndMode[ndMode.length] = code ;
	ndCheck[code] = true ;
	nd_nOptions++ ;
}

function menu_disaster()
{
	nd_pageUrl = document.location+"" ;

	if ( typeof nd_lang  == 'undefined' )
	{
		// LANGUE PAR DEFAUT anglais
				
		nd_lang = "en" ;

		// DETECTION DES LANGUES selon l'arborescence

		var reg_exp = /(\\|\/)((en)|(fr)|(es)|(pt)|(de)|(tr)|(pl))(\\|\/)/gi ;
		var cherche = reg_exp.exec(nd_pageUrl) ;
		if (cherche != null) 
		{
		    nd_lang = cherche[2] ;
		}
//		alert(nd_lang) ;
	}

	// ANALYSE PARAMETRES

	// vérifier si les options sont déjà définies dans des variables javascript

	if ( typeof nd_mode != 'undefined' || typeof nd_dest != 'undefined' || typeof nd_control != 'undefined' )
	{
		// au moins l'une des variables est définie
		// on est dans la minibar ou dans un dropdown sur un autre site
		nd_isMinibar = true ;
	}
	else
	{

		// sinon, on vérifie si des paramètres sont passés à la page
		// EN DEHORS DE LA MINIBARRE

		nd_isMinibar = false ;

		nd_params = nd_pageUrl.split("?") ;
		nd_randomize = false ;

		if ( typeof nd_params[1] != 'undefined' && typeof nd_mode == 'undefined' )
		{
			nd_mode = nd_params[1] ;
			nd_randomize = false ;
		}
		else
		{
			nd_mode = "" ;
			nd_randomize = true ;
		}

		if ( typeof nd_params[2] != 'undefined' )
		{
			nd_dest = nd_params[2] ;
		}
		else
		{
			nd_dest = "" ;
		}

		if ( typeof nd_params[3] != 'undefined' )
		{
			nd_control = nd_params[3] ;
		}
		else
		{
			nd_control = "" ;
		}
		
		if ( typeof nd_params[4] != 'undefined' )
		{
			nd_sound = nd_params[4] ;
		}
		else
		{
			nd_sound = "" ;
//			nd_sound = "on" ;
		}
	}

	nd_option = new Array() ;
	ndMode = new Array() ;
	ndCheck = new Array() ;
	nd_nOptions = 0 ;
	nd_selector = '<select id="selectmode" name="selectmode" onChange="modif()">' ;

	nd_defineProp() ;
	
	nd_newRub("Nature", "Nature", "Naturaleza", "Natureza", "Natur", "Doga", "Natura");

	newDisaster("meteor", "Meteors", "Météorites", "Meteoros", "Meteoritos", "Meteore", "Meteorlar", "Metory") ;
	newDisaster("flood", "Flood", "Déluge", "Inundación", "Dilúvio", "Flut", "Sel", "Krew") ;
	newDisaster("flowers", "Flower Power", "Flower Power", "Flower Power", "Flower Power", "Flower Power", "Çiçek Çocuklar", "Moc kwiatów") ;

	nd_newRub("Technology", "Technologie", "Tecnología", "Tecnologia", "Technik", "Teknoloji", "Technologia");

	// newDisaster("zeppelin", "Led Zeppelin", "Led Zeppelin", "Led Zeppelin", "Led Zeppelin", "Led Zeppelin", "Led Zeppelin", "Led Zeppelin") ;
	newDisaster("bomb", "Nuke", "Nucléaire", "Nuclear", "Nuclear", "Atombombe", "Atom Bombasi", "Rakiety") ;
	newDisaster("ufo", "Mars Attacks!", "Mars Attacks!", "Mars Attacks!", "Mars Attacks!", "Mars Attacks!", "Mars Attacks!", "Atak z marsa!") ;
	newDisaster("graff", "Graffiti", "Tag à donf", "Pintadas", "Graffiti", "Graffiti", "Graffiti", "Grafitti") ;
	newDisaster("shaver", "Screenshaver", "Rasoir à pixels", "Máquina de Afeitar", "Aparelho de Barbear", "Pixel Rasierer", "Ekran Trasi", "Wtrzas ekranu") ;
	newDisaster("gun", "Gun", "Fusillade", "Tiroteo", "Tiroteio", "Pistole", "Tabanca", "Pistolet") ;
	newDisaster("blood", "Bloody Gun", "Site en sang", "Arma sangrienta", "Site sangrento", "Pistole blutig", "Kanli Tabanca", "Krwisty pistolet") ;
	newDisaster("paint", "PaintBall", "PaintBall", "PaintBall", "PaintBall", "Paintball", "Paintball", "Paintball") ;
	newDisaster("chainsaw", "Chainsaw", "Tronçonneuse", "Tronzadora", "Serra de cadeia", "Kettensäge", "Motor Testeresi", "Pila maszynowa") ;

	nd_newRub("Life Forms", "Formes de vie", "Formas de vida", "Formes de vida", "Lebewesen", "Yasam", "Formy zycia");

	newDisaster("dino", "Dinosaurs", "Dinosaures", "Dinosaurios", "Dinossáurios", "Dinosaurier", "Dinazorlar", "Dinozaury") ;
 	newDisaster("wasp", "Wasps", "Guêpes", "Avispas", "Vespas", "Wespen", "Esek Arilari", "Osy") ;
	newDisaster("fly", "Flies", "Mouches", "Moscas", "Moscas", "Fliegen", "Sinekler", "Muchy") ;
	newDisaster("ants", "Ants", "Fourmis", "Hormigas", "Formigas", "Ameisen", "Karincalar", "Mrówki") ;
	newDisaster("snail", "Snail", "Escargot", "Caracol", "Caracol", "Schnecken", "Salyangozlar", "Slimak") ;
	newDisaster("worms", "Worms", "Asticots", "Gusanos", "Larvas", "Würmer", "Kurtlar", "Robaki") ;
	newDisaster("mold", "Mold", "Moisissure", "Moho", "Bolor", "Schimmel", "Küf", "Plesn") ;

	nd_newRub("Home, Office", "Maison, Bureau", "Hogar, Oficina", "Casa, Escritório", "Zu Hause und Büro", "Ev, Ofis", "Dom, biuro");

	newDisaster("baby", "Scribbling baby", "Bébé gribouille", "Bebé garabatea", "Bebê rabisca", "Kritzelndes Baby", "Karalayan Bebek", "Bazgroly dziecka") ;
	newDisaster("eggs", "Fried Eggs", "Oeufs sur le plat", "Huevos fritos", "Ovos estrelados", "Spiegeleier", "Pismis Yumurda", "Smazone jajka") ;
	newDisaster("coffee", "Spilled Coffee", "Café renversé", "Café derramado", "Café Derramado", "Verschütteter Kaffe", "Kahve Dökülmesi", "Rozlana kawa") ;
	newDisaster("burn", "Slow Burn", "Combustion", "Combustión", "Combustão", "Brandfleck", "Sigara Yanigi", "Wolny pozar") ;
	newDisaster("tomato", "Tomatoes", "Tomates", "Tomates", "Tomates", "Tomaten", "Domatesler", "Pomidory") ;
	newDisaster("creampie", "Cream Pie", "Entartage", "Tarta de Crema", "Torta de Creme", "Sahnekuchen", "Kremali Turta", "Kremowe ciasto") ;

	nd_newRub("Miscellaneous", "Divers", "Diverso", "Variado", "Sonstiges", "Diger", "Rózne");

	newDisaster("manif", "Demonstration", "Manifestation", "Manifestación", "Demonstração", "Aufstand", "Protesto", "Demonstracja") ;
	newDisaster("god", "God Almighty", "Dieu tout puissant", "Dios todopoderoso", "Deus todo poderoso", "Göttliche Allmacht", "Tanrinin Cezasi", "Reka boga") ;
//	newDisaster("sucker", "Text Sucker", "Pompe à textes", "Aspirador de textos", "Bomba aspira textos", "Textsauger", "Yazi Emer", "Zasysacz tekstu") ;

	nd_newRub("Dirty", "Crado", "Sucio", "Sujo", "Dreck", "Pis Isler", "Brud");

	newDisaster("cow", "Cow Dung", "Vache qui chie", "Vaca que caga", "Vaca que caga", "Kuhdung", "Inek Pisligi", "Krowi placek") ;
	newDisaster("dog", "Dog Poop", "Crotte de chien", "Caca de perro", "Bosta de cão", "Hundescheiße", "Köpek Pisligi", "Psia kupa") ;
	newDisaster("pee", "Pee", "Pipi", "Pis", "Xixi", "Urin", "Sidik", "Siki") ;
	newDisaster("acid", "Acid Pee", "Pipi acide", "Pis Ácido", "Xixi Ácido", "Ätzender Urin", "Asitli Sidik", "Kwasne siki") ;
	newDisaster("vomit", "Vomit (yuk!)", "Vomi (beurk!)", "Vómito", "Vómito", "Kotzen", "Kusmuk (Ögh!)", "Zygi (blech)") ;
	nd_selector += '</select>' ;
	document.write(nd_selector) ;

	// refuser l'accès sans un mode d'attaque valide
//	if ( typeof ndCheck[nd_mode] == 'undefined' && nd_isMinibar && !nd_mode.match("zeppelin", "gi") ) // avec exception
	if ( typeof ndCheck[nd_mode] == 'undefined' && nd_isMinibar )
	{
//		top.location.href = "http://www.netdisaster.com" ;
		top.location.href = "/" ;
	}

	var n = nd_option.length ;

	if (nd_randomize)
	{
		rnd = alea(n) ; // un désastre aléatoire
//		rnd = 3 ; // un désastre par défaut
		document.forms.nd_Form.selectmode.options[nd_option[rnd]].selected = true ;
	}
	else
	// SI UN MODE EST PRESELECTIONNE
	{
		if ( nd_mode != '' )
		{
			for (i=0; ndMode[i] != nd_mode && i < 100 ; i++)
			{
			}
			document.forms.nd_Form.selectmode.options[nd_option[i]].selected = true ;
		}
	}
}

function nd_defineProp()
{
	able = new Array() ;
	able["control"] = new Array() ;
	able["destruction"] = new Array() ;
	able["sound"] = new Array() ;
	able["promo"] = new Array() ;
	
//	able["promo"]["zeppelin"] = true ;

	able["control"]["meteor"] = true ;
	able["control"]["bomb"] = true ;
	able["control"]["eggs"] = true ;
	able["control"]["dino"] = true ;
	able["control"]["coffee"] = true ;
	able["control"]["worms"] = true ;
	able["control"]["burn"] = true ;
	able["control"]["mold"] = true ;
	able["control"]["flowers"] = true ;
	able["control"]["wasp"] = true ;
	able["control"]["dog"] = true ;
	able["control"]["cow"] = true ;
	able["control"]["tomato"] = true ;
	able["control"]["baby"] = true ;
	able["control"]["fly"] = true ;
	able["control"]["pee"] = true ;
	able["control"]["acid"] = true ;
	able["control"]["vomit"] = true ;
	able["control"]["creampie"] = true ;
	able["control"]["ufo"] = true ;
	able["control"]["zeppelin"] = true ;
	able["control"]["ants"] = true ;

	able["destruction"]["meteor"] = true ;
	able["destruction"]["bomb"] = true ;
	able["destruction"]["ufo"] = true ;
	able["destruction"]["wasp"] = true ;
	able["destruction"]["tomato"] = true ;
	able["destruction"]["chainsaw"] = true ;
	able["destruction"]["acid"] = true ;
	able["destruction"]["creampie"] = true ;
	able["destruction"]["zeppelin"] = true ;

	able["sound"]["meteor"] = true ;
	able["sound"]["bomb"] = true ;
	able["sound"]["dino"] = true ;
	able["sound"]["gun"] = true ;
	able["sound"]["blood"] = true ;
	able["sound"]["paint"] = true ;
	able["sound"]["manif"] = true ;
	able["sound"]["graff"] = true ;
	able["sound"]["ufo"] = true ;
	able["sound"]["zeppelin"] = true ;
	
	childsafe = new Array() ;
	childsafe["meteor"] = true ;
	childsafe["eggs"] = true ;
	childsafe["dino"] = true ;
	childsafe["coffee"] = true ;
	childsafe["worms"] = true ;
	childsafe["burn"] = true ;
	childsafe["mold"] = true ;
	childsafe["flowers"] = true ;
	childsafe["wasp"] = true ;
	childsafe["tomato"] = true ;
	childsafe["baby"] = true ;
	childsafe["fly"] = true ;
	childsafe["creampie"] = true ;
	childsafe["ufo"] = true ;

	// a priori pas nécessaire ici, mais présent dans mynd.js
	/* nd_version = new Array();
	nd_version["zeppelin"] = "6" ;
	nd_version["bomb"] = "6" ;
	nd_version["meteor"] = "6" ;
	nd_version["dino"] = "6" ;
	nd_version["graff"] = "6" ;
	nd_version["art"] = "6" ;
	nd_version["shaver"] = "6" ;
	nd_version["manif"] = "6" ;
	nd_version["gun"] = "6" ;
	nd_version["blood"] = "6" ;
	nd_version["paint"] = "6" ;
	nd_version["ufo"] = "6" ; */
}

function menu_control()
{
	// LANGUES MENU CONTROLE

	controlNameOff_en = "auto" ;
	controlNameOn_en = "mouse" ;

	controlNameOff_fr = "auto" ;
	controlNameOn_fr = "souris" ;

	controlNameOff_es = "auto" ;
	controlNameOn_es = "ratón" ;

	controlNameOff_pt = "auto" ;
	controlNameOn_pt = "rato" ;

	controlNameOff_de = "Automatisch" ;
	controlNameOn_de = "Maus" ;
	
	controlNameOff_tr = "Otomatik" ;
	controlNameOn_tr = "Fare Ile" ;
	
	controlNameOff_pl = "automatyczna" ;
	controlNameOn_pl = "myszka" ;

	document.write('<div id="controldiv">'
		+ '<select id="selectcontrol" name="selectcontrol" onChange="modif()">'
		+ '<option value="">' + eval("controlNameOff_"+nd_lang) + '</option>'
		+ '<option value="on">' + eval("controlNameOn_"+nd_lang) + '</option></select></div>') ;


	// SI UN CONTROLE EST PRESELECTIONNE

	if ( nd_control != '' )
	{
		for (i=0; document.forms.nd_Form.selectcontrol.options[nd_option[i]].value != nd_control ; i++)
		{
		}
		document.forms.nd_Form.selectcontrol.options[nd_option[i]].selected = true ;
	}
}

function menu_sound()
{
//	alert("menu_sound");

	soundNameOff_en = "mute" ;
	soundNameOn_en = "on" ;

	soundNameOff_fr = "muet" ;
	soundNameOn_fr = "on" ;

	soundNameOff_es = "off" ;
	soundNameOn_es = "on" ;

	soundNameOff_pt = "off" ;
	soundNameOn_pt = "on" ;

	soundNameOff_de = "Gedämpft" ;
	soundNameOn_de = "An" ;
	
	soundNameOff_tr = "Kapali" ;
	soundNameOn_tr = "Açik" ;

	soundNameOff_pl = "Nie" ;
	soundNameOn_pl = "Tak" ;

	document.write('<div id="sounddiv">'
		+ '<select id="selectsound" name="selectsound" onChange="modif()">'
		+ '<option value="">' + eval("soundNameOff_"+nd_lang) + '</option>'
		+ '<option value="on">' + eval("soundNameOn_"+nd_lang) + '</option></select></div>') ;


	// SI SON PRESELECTIONNE

	if ( nd_sound != '' )
	{
		for (i=0; document.forms.nd_Form.selectsound.options[nd_option[i]].value != nd_sound ; i++)
		{
		}
		document.forms.nd_Form.selectsound.options[nd_option[i]].selected = true ;
	}
}


function menu_destruction()
{
	// LANGUES MENU DESTRUCTION

	destructionNameOff_en = "self-repair" ;
	destructionNameOn_en = "massive" ;

	destructionNameOff_fr = "auto-réparation" ;
	destructionNameOn_fr = "massive" ;

	destructionNameOff_es = "auto-reparación" ;
	destructionNameOn_es = "masivo" ;

	destructionNameOff_pt = "auto-reparo" ;
	destructionNameOn_pt = "maciço" ;

	destructionNameOff_de = "Wiederherstellung" ;
	destructionNameOn_de = "Dauerhaft" ;
	
	destructionNameOff_tr = "Kendini Onaran" ;
	destructionNameOn_tr = "Sürekli" ;
	
	destructionNameOff_pl = "auto-naprawa" ;
	destructionNameOn_pl = "masywna" ;


	document.write('<div id="destructiondiv">'
		+ '<select id="selectdestruction" name="selectdestruction" onChange="modif()">'
		+ '<option value="">' + eval("destructionNameOff_"+nd_lang) + '</option>'
		+ '<option value="massive">' + eval("destructionNameOn_"+nd_lang) + '</option></select></div>') ;


	// SI UNE DESTRUCTION EST PRESELECTIONNEE

	if ( nd_dest != '' )
	{
		for (i=0; document.forms.nd_Form.selectdestruction.options[nd_option[i]].value != nd_dest ; i++)
		{
		}
		document.forms.nd_Form.selectdestruction.options[nd_option[i]].selected = true ;
	}
}

function alterne(myItem)
{
//	alert("alterne " + myItem);
	with (document.forms.nd_Form)
	{
		mySelect = document.getElementById(myItem + "div") ;
		myTitle = document.getElementById(myItem + "Titre") ;
		formItem = "select" + myItem ;

		if ( able[myItem][document.forms.nd_Form.selectmode.value] )
		{
			mySelect.style.display = "block" ;
			if ( myTitle )
			{
				myTitle.className = "on" ;
			}
			if (formItem.value == '')
			{
				formItem.options[0].selected = true ;
			}
		}
		else
		{
			mySelect.style.display = "none" ;
			formItem.value = '' ;
			if ( myTitle )
			{
				myTitle.className = "off" ;
			}
		}
	}
}

function modif()
{
	// liste des sous-domaines autorisés
	var allowedSubDom = new Array() ;
	allowedSubDom["www"] = true ;
	allowedSubDom["test"] = true ;
	allowedSubDom["demo"] = true ;
	
	// recherche le sous-domaine courant
	var subDom = document.location.href.split("//") ;
	subDom = subDom[1].split(".") ;
	subDom = subDom[0] ;

//	alert(subDom) ;

	if ( subDom.match("[\\/]") || !allowedSubDom[subDom] ) // mettre www dans tous les cas non prévus
	{
		subDom = "www" ;
	}

//	alert(subDom) ;
	
	if ( document.forms.nd_Form)
	{
		with (document.forms.nd_Form)
		{
			// victime = 'http://'+subDom+'.netdisaster.com/go.php?' ;
			myCode = '' ;

			alterne("control") ;
			alterne("destruction") ;
			alterne("sound") ;

			if ( !isNaN(selectmode.value) )
			{
				// l'utilisateur sélectionne par erreur un titre de rubrique

				newOption = Number(selectmode.value)+1 ;
				selectmode.options[newOption].selected = true ;
				modif();
				return true ;
			}
			else
			{
				// l'utilisateur a bien sélectionné un désastre

				if ( selectmode.value  )
				{
					// victime += 'mode=' + selectmode.value ;
					myCode += 'nd_mode="' + selectmode.value + '";\n' ;
				}

				if ( selectdestruction.value && able["destruction"][selectmode.value] == true )
				{
					// victime += '&destruction=' + selectdestruction.value ;
					myCode += 'nd_dest="' + selectdestruction.value + '";\n' ;
				}

				if ( selectcontrol.value && able["control"][selectmode.value] == true )
				{
					// victime += '&control=' + selectcontrol.value ;
					myCode += 'nd_control="' + selectcontrol.value + '";\n' ;
				}

				if ( selectsound.value && able["sound"][selectmode.value] == true )
				{
					// victime += '&sound=' + selectsound.value ;
					myCode += 'nd_sound="' + selectsound.value + '";\n' ;
				}
				
				if ( vAlign.value )
				{
					myCode += 'nd_vAlign="' + vAlign.value + '";\n' ;
				}
				
				if ( hAlign.value )
				{
					myCode += 'nd_hAlign="' + hAlign.value + '";\n' ;
				}
				
				if ( vMargin.value )
				{
					myCode += 'nd_vMargin="' + vMargin.value + '";\n' ;
				}
				
				if ( hMargin.value )
				{
					myCode += 'nd_hMargin="' + hMargin.value + '";\n' ;
				}
				
				if ( select_target.value )
				{
					myCode += 'nd_target="' + select_target.value + '";\n' ;
				}

				if ( nd_lang != "en" )
				{
					// victime += '&lang=' + nd_lang ;
					myCode += 'nd_lang="' + nd_lang + '";\n' ;
				}

				var reg_exp = new RegExp("[0-9a-zA-Z]+","gi");
//				if ( nopub.value.match(reg_exp) ) // si nopub est renseigné
//				{
//					victime += '&nopub=' + nopub.value ;
//					myCode += 'nd_nopub="' + nopub.value + '";\n' ;
//				}

				// if ( alt.value.match(reg_exp) ) // si alt est renseigné
				// {
					// victime += '&alt=' + alt.value ;
//					myCode += 'nd_alt="' + alt.value + '";\n' ;
				// }

				// victime += '&url=' + encodeIfParams(url.value) ;

				myInsert.value = '<script language="javascript">\n' + myCode + '</script>\n<script language="javascript" src="http://www.netdisaster.com/js/mynd.js"></script>' ;

				if ( disposition.checked )
				{
					myCode += 'nd_disp="h";\n' ;
				}

				myDropDown.value = '<script language="javascript" src="http://www.netdisaster.com/js/nd.js"></script>\n'
				+ '<script language="javascript">\n'
				+ myCode + 'nd_dropdown();\n</script>' ;

		        return true ;
			}
		}
	}
}

function encodeIfParams(urlString) // détection des pages attaquées qui ont des paramètres
{
	var reg_exp = /\?/gi ;
	if ( urlString.match(reg_exp) )
	{
		return escape(urlString) ; // encoder la page en URL, pour que les variables ne soient pas passées à Netdisaster
	}
	else
	{
		return urlString ;
	}
}

function goAlt()
{
	document.forms.nd_Form.alt.value = "ok" ;
	vazy();
}

function vazy(myTarget)
{
	var reg_exp = new RegExp(".[.].","gi");
	var reg_exp2 = new RegExp("@","gi");
	var nd_errMsg = new Array() ;
	var nd_alertUrl ;
	if ( !document.forms.nd_Form.url.value.match(reg_exp) || document.forms.nd_Form.url.value.match(reg_exp2) )
	{
		nd_errMsg["en"] = "Please type in a valid website address!\r\nExample: http://www.some-target-site.com" ;
		nd_errMsg["fr"] = "Donnez une adresse valide de site à détruire !\r\nExemple : http://www.some-target-site.com" ;
		nd_errMsg["es"] = "Introduzca la URL del sitio web que desea destruir, ejemplo: http://www.some-target-site.com" ;
		nd_errMsg["de"] = "Bitte geben sie eine gültige Internetadresse ein!\r\nBeispiel: http://www.some-target-site.com" ;
		nd_errMsg["tr"] = "Lütfen Geçerli Bir Web Sitesi Adresi Girin!\r\nÖrnek: http://www.some-target-site.com" ;
		nd_errMsg["pl"] = "Prosze wpisac poprawny adres strony WWW!\r\nPrzyklad: http://www.some-target-site.com" ;

		if ( typeof nd_errMsg[nd_lang] == "undefined" )
		{
			nd_alertUrl = nd_errMsg["en"] ;
		}
		else
		{
			nd_alertUrl = nd_errMsg[nd_lang] ;
		}

		alert(nd_alertUrl) ;
	}
	else
	{
//		alert(victime) ;
//		if (myTarget)
//		{
//			window.open ( victime, "netdisaster" ) ;
//		}
//		top.location.href = victime ;
		document.forms.nd_Form.action = (document.location.href.indexOf("netdisaster.com") > -1 ? "/go.php" : "http://www.netdisaster.com/go.php") ;
		// document.forms.nd_Form.target = ( myTarget ? myTarget : "_top" ) ;
		document.forms.nd_Form.target = ( myTarget ? myTarget : "_self" ) ;
		document.forms.nd_Form.lang.value = nd_lang ;
		document.forms.nd_Form.method = "POST" ;
		document.forms.nd_Form.submit();
	}
}

function submitenter(e)
{
	var keycode;
	if (window.event)
	{
		keycode = window.event.keyCode;
	}
	else if (e)
	{
		keycode = e.which;
	}
	else
	{
		return true;
	}

	if (keycode == 13)
	{
		modif();
		vazy();
		return false;
	}
	else
	{
		return true;
	}
}

function addHidden(nom)
{
	hidden[hidden.length] = nom ;
}

function hidden_fields()
{
	hidden = new Array() ;
	addHidden("myInsert") ;
 	addHidden("myDropDown") ;
 	addHidden("disposition") ;
 	addHidden("alt") ;
	addHidden("lang") ;
// 	addHidden("nopub") ;

	for ( var i=0 ; hidden[i] ; i++ )
	{
		document.write ( '<input type="hidden" name="' + hidden[i] + '">' ) ;
	}
}

function tableBreak()
{
	myBreak = "</td>" ;
	if ( nd_disp != "h" )
	{
		myBreak += "</tr><tr>" ;
	}
	myBreak += "<td>" ;
	document.write(myBreak) ;
}

function nd_dropdown()
{
	if ( !top.destruction )
	{
		if ( typeof nd_mode == 'undefined' )
		{
			nd_mode = "random" ;
		}

		if ( nd_mode != "random" )
		{
			nd_randomize = false ;
		}
		else
		{
			nd_randomize = true ;
		}

		if ( typeof nd_dest == 'undefined' )
		{
			nd_dest = "" ;
		}

		if ( typeof nd_control == 'undefined' )
		{
			nd_control = "" ;
		}

		if ( typeof nd_sound == 'undefined' )
		{
			nd_sound = "" ;
		}

		if ( typeof nd_disp == 'undefined' )
		{
			nd_disp = "" ;
		}

		if ( typeof nd_lang != 'undefined' )
		{
			nd_lang = nd_lang;
		}
		else
		{
			nd_lang = "en";
		}

		document.write('<form name="nd_Form" method="post"><table id="nd_table" cellspacing=0 cellpadding=2 border=0><tr><td>') ;
		menu_disaster();
		tableBreak();
		menu_destruction();
		tableBreak();
		menu_control();
		tableBreak();
		menu_sound();
		tableBreak();
		document.write('<input type="button" value="Go!" onClick="vazy(\'new\')" name="nd_go" class="bouton">') ;
		tableBreak();
		document.write('&copy; <a href="http://www.netdisaster.com" target="_blank" Title="Destroy the web!">Netdisaster</A>');

		document.write('</td></tr></table>') ;
		hidden_fields();
		document.write('<input type="hidden" name="lang"><input name="url" type="hidden"></form>') ;

		document.forms.nd_Form.url.value = top.location ;

		if ( !nd_randomize )
		{
			if ( typeof nd_mode != 'undefined' )
			{
				document.forms.nd_Form.selectmode.value = nd_mode;
			}
			if ( typeof nd_dest != 'undefined' )
			{
				document.forms.nd_Form.selectdestruction.value = nd_dest;
			}
			if ( typeof nd_control != 'undefined' )
			{
				document.forms.nd_Form.selectcontrol.value = nd_control;
			}
			if ( typeof nd_sound != 'undefined' )
			{
				document.forms.nd_Form.selectsound.value = nd_sound;
			}
			if ( typeof nd_lang != 'undefined' )
			{
				document.forms.nd_Form.lang.value = nd_lang;
			}
		}

		nd_police_type = "Verdana, Arial, sans-serif" ;
		nd_police_taille = "10px" ;

		with ( document.forms.nd_Form )
		{
			selectmode.style.fontFamily = nd_police_type ;
			selectmode.style.fontSize = nd_police_taille ;
			selectdestruction.style.fontFamily = nd_police_type ;
			selectdestruction.style.fontSize = nd_police_taille ;
			selectcontrol.style.fontFamily = nd_police_type ;
			selectcontrol.style.fontSize = nd_police_taille ;
			selectsound.style.fontFamily = nd_police_type ;
			selectsound.style.fontSize = nd_police_taille ;
			nd_go.style.fontFamily = nd_police_type ;
			nd_go.style.fontSize = nd_police_taille ;
		}

		document.getElementById("nd_table").style.fontFamily = nd_police_type ;
		document.getElementById("nd_table").style.fontSize = nd_police_taille ;

		modif();
	}
}

function alea(nb)
{
	return Math.floor(Math.random()*nb);
}