function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function changeLangSelect(y) {
	MM_changeProp('lang','','length','0','SELECT')
	var obj = MM_findObj('lang');
	if(!y) {
		newEntry = new Option('Deutsch',0);
		obj.options[obj.length] = newEntry;
		//newEntry = new Option('Russisch',1);
		//obj.options[obj.length] = newEntry;
		//newEntry = new Option('Polnisch',2);
		//obj.options[obj.length] = newEntry;
	}else{
		newEntry = new Option('Deutsch',0);
		obj.options[obj.length] = newEntry;
		//newEntry = new Option('Englisch',1);
		//obj.options[obj.length] = newEntry;
	}
}

function setRegionVisibility() {
	obj = MM_findObj('country')
	objRegion = MM_findObj('region_select')
	objRegionText = MM_findObj('region_text')
	if(objRegion.style) objRegion =objRegion.style
	if(objRegionText.style) objRegionText =objRegionText.style

	if(obj.options[obj.selectedIndex].text == "Deutschland" || obj.options[obj.selectedIndex].text == "DE") {
		objRegion.visibility = 'visible'
		objRegionText.visibility = 'visible'
	}else{
		objRegion.visibility = 'hidden'
		objRegionText.visibility = 'hidden'
		objRegion.value= ''
		objRegion.selected= 0
	}
}

function setRegion(regionIndex) {
	obj = MM_findObj('region')
	obj.value = regionIndex
}

function setCountry(countryIndex) {
	obj = MM_findObj('country')
	if(countryIndex) {
		for(i=0;i<obj.options.length;i++){
			if(obj.options[i].value == countryIndex) obj.options[i].selected = true
		}
	}
	setRegionVisibility()
}

function makePass(obj) {
	obj = MM_findObj(obj)
	passwort = "";
	randomNumber = Math.random();
	randomNumber = randomNumber.toString();
	randomNumber = randomNumber.substr(2,8);
	window.status = randomNumber
	for(i=0;i<8;i=i+2) {
		passwort+=randomNumber.substr(i,1)
		charCode = parseInt(randomNumber.substr(i,2))
		if(charCode>51) charCode = charCode-52;
		if(charCode<26) charCode = charCode+65
		else if(charCode>=26) charCode = charCode+71
		passwort+=String.fromCharCode(charCode)
	}
	obj.value = passwort.substr(0,8)
}

function setInputValue(from,to) {
	objFrom = MM_findObj(from)
	objTo = MM_findObj(to)
	objTo.value =  (objFrom.options[objFrom.selectedIndex].text)
}

function confirm_assign_callback(a,i,c) {
	if(i==0) conf_return = confirm('Wenn Sie auf OK klicken, wird die Zuteilung für diesen Rückrufwunsch gelöscht.\n Klicken Sie auf abbrechen, um den Vorgang abzubrechen.')
	else conf_return = confirm('Wenn Sie auf OK klicken, wird dieser Rückrufwunsch dem Benutzer ' + a + ' zugeteilt.\n Klicken Sie auf abbrechen, um den Vorgang abzubrechen.')
	if(conf_return) location.href = "index.php?p=callback_details&callback_id="+ c +"&assign_to=" + i
	else location.reload()
}

function confirm_delete_callback() {
	return confirm('Wollen Sie diesen Rückrufwunsch wirklich löschen?\nKlicken Sie auf \"OK\" zum löschen, \"Abbrechen\" um den Löschvorgang abzubrechen')
}

function deselectOtherCB(o) {
	obj = MM_findObj(o);
	if(obj.checked == true) {
		f = obj.form.name;
		obj = MM_findObj(f);
		oSliced = o.replace(/\[\d\]/,'');
		for(i=0; i<obj.elements.length; i++) {
			if(obj.elements[i].name.slice(0,oSliced.length) == oSliced && obj.elements[i].name != o) {
				obj.elements[i].checked = false;
			}
		}
	}
}

function deselectOneCB(o,d) {
	obj = MM_findObj(o);
	if(obj.checked == true) {
		obj = MM_findObj(d);
		obj.checked = false;
	}else return true;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}


function tmt_winOpen(u,id,f,df){
	if(eval(id)==null||eval(id+".closed")){
	eval(id+"=window.open('"+u+"','"+id+"','"+f+"')");eval(id+".focus()");}
	else if(df){eval(id+".focus()");}
	else{eval(id+"=window.open('"+u+"','"+id+"','"+f+"')");eval(id+".focus()");}
}
