//change img source picture
function setImg(img,a) {
	img.src = a;
}
//preload all rollovers
function preloadRollOvers() {
	
	//go over the images and preload the rollovers

}

//make links loose the louse on click frame
function looseLousyFrame() {
	$$("a").each(function (lnk) {
		if (!lnk.onclick)
			lnk.onclick = function () {this.blur();}
	});
}

//call init functions
//window.addEvent('domready', function(){
//	preloadRollOvers();
//	looseLousyFrame();
//});

//form functions
var required = new Array();

function submitform(name) {
     var valid = true;
     var form = document.getElementById(name);
     var fields = form.getElementsByTagName('input');
     for (var i=0;i<fields.length;i++ ) {
         if (fields[i].alt) {
             switch(fields[i].alt) {
                  case 'num' : valid = valid && (/[\d\.]+/.test(fields[i].value));break;
                  case 'text' : valid = valid && (/../.test(fields[i].value));break;
                  case 'file' : valid = valid && (/../.test(fields[i].value));break;
                  case 'date' : valid = valid && (/\d\d\.\d\d.\d\d\d\d/.test(fields[i].value));break;
                  case 'checkbox' : valid = valid && fields[i].checked;break;
                  case 'email' : valid = valid && (/^.*?@.*\..*$/.test(fields[i].value));break;
                  case 'puretext' : valid = valid && (/^[A-Za-z0-9_]+$/.test(fields[i].value));break;
                  
              }
         }

     }

     if (valid) {
         form.submit();
     } else {
         //
         alert('Bitte füllen Sie alle obligatorischen* Felder korrekt aus');
     }

}

function initTinyMCE() {

tinyMCE.init({
	mode : "textareas",
	theme : "simple",
	theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,link,unlink,outdent, indent, image",
	theme_advanced_buttons2 : "styleselect, code, hr, removeformat, forecolor, charmap",
	theme_advanced_buttons3 : "",
	//content_css : "/content.css",
	force_p_newlines : false,
	trim_span_elements : false,
    convert_newlines_to_brs : true,
    force_br_newlines : true,
	convert_fonts_to_spans : true,
	remove_linebreaks : false
});

}

function searchCatOpen() {

	if ($('searchDropList').getStyle('display') == 'none') {
		$('searchDropList').setStyle('display','block');
		$('searchDropText').focus();
	} else {
		searchTimer = "";
		$('searchDropList').setStyle('display','none');
	}
	
}

function searchCatSelect(val, txt) {
	searchTimer = "";
	$("searchCat").value = val;
	$("searchDropText").innerHTML = txt;
	
	searchCatOpen();
}

var searchTimer = "";
function searchCloseTimed() {
	searchTimer = setTimeout('searchClose()', 500);
}

function searchClose() {
	if (searchTimer != "")
	if ($('searchDropList').getStyle('display') == 'block') {
		searchTimer = "";
		$('searchDropList').setStyle('display','none');
	}
}