if(top != self) top.location = self.location;


/* 
------------------------------------------
	Flipbox written by CrappoMan
	simonpatterson@dsl.pipex.com
------------------------------------------
*/

function flipBox(who, style) {
	if (!style) {
		style = 'block';
	}
	var tmp; 
	if (document.images['b_' + who].src.indexOf('_on') == -1) { 
		tmp = document.images['b_' + who].src.replace('_off', '_on');
		document.getElementById('box_' + who).style.display = 'none';
		document.images['b_' + who].src = tmp;
	} else { 
		tmp = document.images['b_' + who].src.replace('_on', '_off');
		document.getElementById('box_' + who).style.display = style;
		document.images['b_' + who].src = tmp;
	}
}


/*
------------------------------------------
	Window Opener
	by Christian Finkemeier
------------------------------------------
*/

function openwin(URL, NAME, SETS) {
	if (SETS == '') {
		SETS += 'dependent=0';
	}
	if (SETS.search(/menubar=(\d+)/) == -1) {
		SETS += ',menubar=1';
	}
	if (SETS.search(/scrollbars=(\d+)/) == -1) {
		SETS += ',scrollbars=1';
	}
	if (SETS.search(/status=(\d+)/) == -1) {
		SETS += ',status=1';
	}
	if (SETS.search(/location=(\d+)/) == -1) {
		SETS += ',location=1';
	}
	if (SETS.search(/resizable=(\d+)/) == -1) {
		SETS += ',resizable=1';
	}
	if (SETS.search(/toolbar=(\d+)/) == -1) {
		SETS += ',toolbar=1';
	}
	if (URL != '' && NAME != '') {
		window.open(URL, NAME, SETS);
	}
}


/* 
------------------------------------------
	Email-Encoder
	by Christian Finkemeier
------------------------------------------
*/
function decodeMail(name, domain, tld, output) {
  var decode_HTML1 = '%3Ca%20href%3D%22mailto%3A';
  var decode_HTML2 = '%26%2364%3B';
  var decode_HTML3 = '%26%2346%3B';
  var decode_HTML4 = '%22%3E';
  var decode_HTML5 = '%3C%2Fa%3E';
  if (typeof(tld) == 'undefined' || tld == '') {
    var tld = 'de';
  }
  if (typeof(output) == 'undefined' || output == '') {
    var output = name + decode_HTML2 + domain + decode_HTML3 + tld;
  }
  document.write(decodeURIComponent(
    decode_HTML1 + name +
    decode_HTML2 + domain +
    decode_HTML3 + tld +
    decode_HTML4 + output +
    decode_HTML5
  ));
}


/* 
------------------------------------------
	MSN profile viewer
	by Christian Finkemeier
------------------------------------------
*/
function decodeMSN(name, domain, tld, output) {
  var decode_HTML1 = '%3Ca%20href%3D%22';
  var decode_HTML2 = 'http%3A%2F%2Fmembers.msn.com%2F%3Fpgmarket%3Dde-de%26mem%3D';
  var decode_HTML3 = '%26%2364%3B';
  var decode_HTML4 = '%26%2346%3B';
  var decode_HTML5 = '%22%20target%3D%5C%22_blank%5C%22%3E';
  var decode_HTML6 = '%3C%2Fa%3E';
  if (typeof(domain) == 'undefined' || domain == '') {
    var domain = 'finkemeier';
  }
  if (typeof(tld) == 'undefined' || tld == '') {
    var tld = 'com';
  }
  if (typeof(output) == 'undefined' || output == '') {
    output = name + decode_HTML3 + domain + decode_HTML4 + tld;
  }
  document.write(decodeURIComponent(
    decode_HTML1 +
    decode_HTML2 + name +
    decode_HTML3 + domain +
    decode_HTML4 + tld +
    decode_HTML5 + output +
    decode_HTML6
  ));
}


/* 
------------------------------------------
	Change images on mouseover
	by Christian Finkemeier
------------------------------------------
*/

function swap(ID, NEW) {
  if (document.images[ID].src.indexOf('_off') != -1) {
    document.images[ID].src = document.images[ID].src.replace(/_off/, '_on');
  } else {
    document.images[ID].src = document.images[ID].src.replace(/_on/, '_off');
  }
}
/* 
------------------------------------------
	Smiley & UBB Code Inserter
	by Christian Finkemeier
------------------------------------------
*/

function insertText(theText) {
	if (textarea.createTextRange && textarea.curPos) {
		textarea.curPos.text = theText;
	} else {
		textarea.value += theText;
	}
	textarea.focus();
}

function insertText2(theText) {
	if (textarea2.createTextRange && textarea2.curPos) {
		textarea2.curPos.text = theText;
	} else {
		textarea2.value += theText;
	}
	textarea2.focus();
}

function AddText(wrap, unwrap) {
	if (!unwrap){
		if (wrap.substr(0, 1) != '<') {
			unwrap = '[/' + wrap + ']';
		} else {
			unwrap = '</' + wrap.substr(2, wrap.length - 1) + '>';
		}
	} else if (wrap.substr(0, 1) != '<') {
		unwrap = '[' + unwrap + ']';
	}
	if (wrap.substr(0, 1) != '<') {
		wrap = '[' + wrap +']';
	}
	if (textarea.curPos) {
		insertText(wrap + textarea.curPos.text + unwrap);
	} else {
		insertText(wrap + unwrap);
	}
}

function AddText2(wrap, unwrap) {
	if (!unwrap){
		if (wrap.substr(0, 1) != '<') {
			unwrap = '[/' + wrap + ']';
		} else {
			unwrap = '</' + wrap.substr(2, wrap.length - 1) + '>';
		}
	} else if (wrap.substr(0, 1) != '<') {
		unwrap = '[' + unwrap + ']';
	}
	if (wrap.substr(0, 1) != '<') {
		wrap = '[' + wrap +']';
	}
	if (textarea2.curPos) {
		insertText2(wrap + textarea2.curPos.text + unwrap);
	} else {
		insertText2(wrap + unwrap);
	}
}

function updatePos(obj) {
	if (obj.createTextRange) {
		obj.curPos = document.selection.createRange().duplicate();
	}
}

function ValidateForm(frm) {
	if (frm.subject.value == '' || frm.message.value == '') {
		alert('Du musst die Felder Betreff und Nachricht ausfüllen');
		return false;
	} else {
		return true;
	}
}
