function dopop(page,name,w,h,scroll,status,fixed) {
	 var LeftPosition = ((screen.width) ? (screen.width-w)/2 : 0);
	 var TopPosition = ((screen.height) ? (screen.height-h)/2 : 0);
	 var settings =  'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',status='+status+',resizeable='+fixed;
	 var its = window.open(page,name,settings);
 }

function activeRegister(set,ActiveID) {
 for(i=1;i<=eval(set+'_count');i++) {
	 className = (i == ActiveID )? 'mmain_a' : 'mmain';
    tes = 'titel_'+set+'_'+i;
    chgBg( document.getElementById( tes ) , className );
 }
}

function switchtotargetdiv(itemID) {

	document.getElementById('alpesmaritime').className = 'hidden';
	document.getElementById('lesalpilles').className = 'hidden';
	document.getElementById('luberon').className = 'hidden';
	document.getElementById('levar').className = 'hidden';
   document.getElementById(itemID).className = 'visible';

}

function dateien(typ,id) {
	dopop('./../dateien/index.php?DATEITYP='+typ+'&ID='+id,'dateien',855,640,1,0,0);
}

function go(target) { location.href = target; }
function dopop(page,name,w,h,scroll,status,fixed) {
	LeftPosition = ((screen.width) ? (screen.width-w)/2 : 0);
	TopPosition = ((screen.height) ? (screen.height-h)/2 : 0);
	settings =  'height='+h+',width='+w+',';
	settings += 'top='+TopPosition+',left='+LeftPosition+',';
	settings += 'scrollbars='+scroll+',status='+status+',resizeable='+fixed;
	var its = window.open(page,name,settings);
	its.focus();
}
function confirmDelete(MSG) { 	var is_confirmed = confirm(MSG); return is_confirmed; }
function activateContent(ActiveID,ContentLayerGroup,MenuGroup) {
// alert('activateContent - max:'+Content_count+' - '+ActiveID+' - '+ContentLayerGroup+' - '+MenuGroup);
	aOneOG(ActiveID,ContentLayerGroup,Content_count,'hidden','visible') ;
	aOneOG(ActiveID,MenuGroup,Content_count,'navi2_sub','navi2_sub_a') ;
}
function aOneOG(ActiveID,Group,MaxGroupCount,styleFrom,styleTo) {
	// alert('aOneOG - max:'+MaxGroupCount+' - '+ActiveID+' - '+Group+' - '+styleFrom+' - '+styleTo);
	for(i=1;i<=MaxGroupCount;i++) {     switchStyle(  Group+'_'+i , styleFrom);  }
	switchStyle(  Group+'_'+ActiveID  , styleTo);
}
function switchStyle(itemID,style) {
	// alert('switchStyle: '+itemID+' changed to class '+style);
	itemEL = document.getElementById(itemID);
	itemEL.className = style;
}
function toggle(itemID){
	itemEL = document.getElementById(itemID);
	itemEL.className = itemEL.className == 'visible' ? 'hidden' : 'visible';
}
function alter_textarea_height(name, change) {
	var ta = document.getElementById( name );
	var height = parseInt(ta.style.height);
	if((height + change) > 0 && (height + change) < 640 ) { ta.style.height = (height + change) + 'px'; }
}
function switch_ActivField(newActiveTextfield) {
	// alert (newActiveTextfield);
	return ActiveTextfield = newActiveTextfield;
}
function SubMitForm() {

	var fail = 0;

	if (document.KForm.F_name1.value == "") {
	fail++; alert("Bitte einen Vornamen eingeben!"); document.KForm.F_name1.focus();
	} else if (document.KForm.F_name2.value == "") {
	fail++; alert("Bitte einen Nachnamen eingeben!");document.KForm.F_name2.focus();
	} else if (document.KForm.F_strasse.value == "" || document.KForm.F_plz.value == "" || document.KForm.F_stadt.value == "") {
	fail++; alert("Bitte eine komplette Adresse eingeben!"); document.KForm.F_strasse.focus();
	} else if (document.KForm.F_fon.value == "") {
	fail++; alert("Bitte eine Rufnummer eingeben!");document.KForm.F_fon.focus();
	} else if  (document.KForm.F_email.value.indexOf('@') == -1) {
	fail++; alert("Bitte eine gültige Email-Adresse eingeben");document.KForm.F_email.focus();
	} else if (document.KForm.F_message.value == "") {
	fail++; alert("Bitte schicken Sie kein Leeres Textfeld ab."); document.KForm.F_message.focus();
	} else { fail = 0; }
	if(fail>0) { return false; }
	else { dopop('','seewolf_pop',800,520,0,0,0); return true; }

}

 function BB_Code_Insert(aTag, eTag) {
  var input = document.forms['CMS_Formular'].elements[ActiveTextfield];
  input.focus();

  if(typeof document.selection != 'undefined') {
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
     range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);
    }
    range.select();
  }   else if(typeof input.selectionStart != 'undefined')   {

    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);

    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }

  else   {

    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }

    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}

function BB_CODE_2(type_,value_,wert_) {
	BB_Code_Insert("["+type_+"=\""+value_+"\"]"+wert_+"[/"+type_+"] "," ");
}
function AddBBCode_News(x,name_) { BB_CODE_2('news',x,name_); }
function AddBBCode_Seite(x,name_) { BB_CODE_2('seite',x,name_); }

function cfp() {window.open('http://www.FPSB.de','fpsb');}
function din() {
	/* window.open('','din_iso22222'); */
}


/* find Position */
function findPos(obj) {
	var curleft = curtop = 0;
	if(obj) {
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
	}
	return [curleft,curtop];
}



