function get_da_dir(laString){
	return laString.substr(0, laString.lastIndexOf("/")).substr(laString.substr(0, laString.lastIndexOf("/")).lastIndexOf("/")+1);
}

function go_to_rubrik(){
for (i = 0; i < document.forms[0].menu_sdep.options.length; i++) {
	if (document.forms[0].menu_sdep.options[i].selected)
		if (document.forms[0].menu_sdep.options[i].value != ""){
		 	parent.principal.location.href = "../soitdit/" + document.forms[0].menu_sdep.options[i].value;
			tempUrl = document.forms[0].menu_sdep.options[i].value;
		 }
		 else{
		 	document.forms[0].menu_sdep.options[0].selected = true;	
		 }
	}
document.forms[0].menu_sdep.options[0].selected = 1;
document.forms[0].menu_sdep.blur();
location.href = "../" + get_da_dir(tempUrl) + "/altmenu.php";
}

function get_da_name(){
	var l_adresse = document.location.href;
	return l_adresse.substr(l_adresse.lastIndexOf("/")+1);
}

function Frames_Checker(repertoire){
  //alert(navigator.appName + " - " + window.top.frames.length + " - " + window.top.length + " - " + document.location.href.indexOf('altmenu'));
  if (window.top.frames.length < 3){
	//if (window.name != "principal"){
    if (document.location.href.indexOf("altmenu") == -1){
		window.top.name = "nonameforme";
		window.top.document.location.href="../?go=" + repertoire + "/" + get_da_name();
    }
    else{
      window.top.document.location.href="../?go=" + repertoire;
    }
	}
	else{
		if (parent.menu.document.location.href.indexOf("altmenu.php") == -1){
			parent.menu.document.location.href="../" + repertoire + "/altmenu.php";
		}
		else{
			if (parent.menu.document.title != repertoire){
				parent.menu.document.location.href="../" + repertoire + "/altmenu.php";
			}
		}
	}
}

function old_Frames_Checker(repertoire){
	if (window.top.length < 4){

		window.top.document.location.href="../?go=" + repertoire + "/" + get_da_name()
	}
	else{
		if (parent.menu.document.title != repertoire){
			parent.menu.document.location.href="altmenu.html"
		}
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function SDEP_mail(){
	MM_openBrWindow('http://www.multimania.com/soitdit/mailer/index.html','Abonne','width=500,height=400')
}

function rien(){}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function change(){
	MM_swapImage('document.top','document.top','black_belt_jones/f_Elvis_top.gif','document.bottom','document.bottom','black_belt_jones/f_Elvis_bottom.gif','#948362667303')
}

function rechange(){
	MM_swapImgRestore()
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function WM_setCookie (name, NS_value, IE_value, hours, path, domain, evalValue) {


    daValue = (navigator.appName == 'Netscape')?NS_value:IE_value;

    //fix layer ref if not supported (thanks, Ken Sundermeyer!)

    if ((daValue.indexOf('document.layers[')==0 && document.layers==null)|| (daValue.indexOf('document.all[')==0 && document.all==null)) {

      daValue = 'document'+daValue.substring(daValue.substring(0,daValue.lastIndexOf('.')).lastIndexOf('.'),daValue.length);

    }


    if(evalValue == 1) daValue = eval(daValue + '.value');


  // set the cookie, adding any parameters that were specified

  // (convert hours to milliseconds (*3600000) and then to a GMTString)

    document.cookie = name + '=' + daValue + ((hours)?(';expires=' + ((new Date((new Date()).getTime() + parseInt(hours)*3600000)).toGMTString())):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'');

}

function WM_readCookie(name, NS_outputElement, IE_outputElement) {

  // if there's no cookie, don't do anything

  if(document.cookie != '') {

    var actualValue, outputElement, firstChar, lastChar;


    // get the entire cookie string (this may have other name=value pairs in it

    var theBigCookie = document.cookie;

    // grab just this cookie from theBigCookie string

    // find the start of 'name'

    firstChar = theBigCookie.indexOf(name);

    // if you found it

    if(firstChar != -1) {

      // skip 'name' and '='

      firstChar += name.length + 1;

      // find the end of the value string (i.e. the next ';')

      lastChar = theBigCookie.indexOf(';', firstChar);

      if(lastChar == -1) lastChar = theBigCookie.length;

      // return the value

      actualValue = theBigCookie.substring(firstChar, lastChar);

    } else {

      // if there was no cookie, return false

      actualValue = false;

    }


    outputElement = (navigator.appName == 'Netscape')?NS_outputElement:IE_outputElement;

    //fix layer ref if not supported (thanks, Ken Sundermeyer!)

    if ((outputElement.indexOf('document.layers[')==0 && document.layers==null)|| (outputElement.indexOf('document.all[')   ==0 && document.all   ==null)) {

      outputElement = 'document'+outputElement.substring(outputElement.substring(0,outputElement.lastIndexOf('.')).lastIndexOf('.'),outputElement.length);

    }


    if(outputElement && actualValue) {

      eval(outputElement+".value = '"+actualValue+"'");

    }

  }

}

function cookie_manager(){

	WM_readCookie('channel_SDEP','document.forms[0].previous','document.forms[0].previous');

	if (document.forms[0].previous.value.length > 10){
		retour_string = "Vous avez *cout* " + document.forms[0].previous.value + " lors de votre pr*c*dente visite, vous *coutez maintenant : "
	}
	else{
		retour_string = "Vous *coutez : "
	}

	retour_string = retour_string  + document.forms[0].channel.value + "."


	WM_setCookie('channel_SDEP','document.forms[0].channel','document.forms[0].channel','2400','','',1)
	return retour_string
}
