//<![CDATA[ 
function stretch(){
	$(document).ready(function() {		
		left = $('.leftwrapper').height();
		center = $('#content').height();
		right = $('#sidebar').height()-92;
		//alert(left + ' ' + center + ' ' + right);
		if(left>center&&left>right){
			$('#content').height(left+110);	
		}
		if(center>left&&center>right){
			$('.leftwrapper').height(center-110);
		}
		if(right>left&&right>center){
			$('.leftwrapper').height(right-110);
			$('#content').height(right);
		}
	});
}

function openShadowbox(url,width,height){
	$.fn.colorbox({href:url, width:width, open:true, height:height}); 
}

function openShadowboxIframe(url,width,height,title){
	$.fn.colorbox({href:url, width:width, open:true, height:height, iframe:true,title:title}); 
}

function openShadowboxText(text,width,height){
	$.fn.colorbox({html:text, width:width, open:true, height:height}); 
}

function stretchFront(){
	$(document).ready(function() {		
		left = $('.leftwrapper').height() + 225;
		center = $('#frontbar1').height() + 117;
		right = $('#frontbar2').height() + 117;
				
		//alert(left + ' ' + center + ' ' + right);
		
		if(left>center&&left>right){
			$('#frontbar1').height(left-117);
			$('#frontbar2').height(left-117);
		}
		if(center>left&&center>right){
			$('.leftwrapper').height(center-225);
			$('#frontbar2').height(center-117);
		}
		if(right>left&&right>center){
			$('.leftwrapper').height(right-225);
			$('#frontbar1').height(right-117);
		}	
	});
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}




/*$(document).ready(function() {		
	var x = "";
	$("input#search").keypress(function (e) {
		  if (e.which == 32 || (65 <= e.which && e.which <= 65 + 25)
							|| (97 <= e.which && e.which <= 97 + 25)) {
			var c = String.fromCharCode(e.which); 
			x = x + c;
		  }
		  if(x==' admin'){
			$.fn.colorbox({href:'/inc/login.cfm', open:true, width:350, height:250, title:'Artenspezialisten Admintool'}); 
		  }
	});
});*/

function getMask(table,masktype,field,id,lang,divid){
	$.get("/inc/masks/"+masktype+".cfm", { table: table, field: field, id: id, lang: lang, divid: divid },
		  function(data){
			$('#' + divid).html(data);
		  });
}

function save(formname,masktype,divid){
	$.post("/inc/masks/"+masktype+".cfm", $("#" + formname).serialize(), function(data){
		$.post("/inc/masks/"+masktype+".cfm", $("#" + formname).serialize(),function(data){
			//location.reload();
			if(data!=''){
				$('#'+divid).html(data);
				$('#'+divid).removeClass('toggle');
			}
			else{
				$('#'+divid).addClass('toggle');
				$('#'+divid).html(masktype+': [NO CONTENT]');
			}
		});
	});
}

function abortedit(table,masktype,field,id,lang,divid){
	$.get("/inc/masks/"+masktype+".cfm", { table: table, field: field, id: id, lang: lang, divid: divid, abort: 1 },
		  function(data){
			if(data!=''){
				$('#'+divid).html(data);
				$('#'+divid).removeClass('toggle');
			}
			else{
				$('#'+divid).addClass('toggle');
				$('#'+divid).html(masktype+': [NO CONTENT]');
			}
		  });
}

function delElement(table,masktype,field,id,lang,divid){
	$.get("/inc/masks/"+masktype+".cfm", { table: table, field: field, id: id, lang: lang, divid: divid, del: 1 },
		  function(data){
			//$('#'+divid).html(data);
			$('#'+divid).addClass('toggle');
			$('#'+divid).html(masktype+': [NO CONTENT]');
		  });
}

function emptyElement(table,masktype,field,id,lang,divid){
	$.get("/inc/masks/"+masktype+".cfm", { table: table, field: field, id: id, lang: lang, divid: divid, empty: 1 },
		  function(data){
			//$('#' + divid).html(data);
			$('#'+divid).addClass('toggle');
			$('#'+divid).html(masktype+': [NO CONTENT]');
		  });
}

function getCustomMask(table,masktype,field,id,lang,divid,width,height){
	openShadowbox('/inc/masks/'+masktype+'.cfm?table='+table+'&masktype='+masktype+'&field='+field+'&id='+id+'&lang='+lang+'&divid='+divid,width,height);
}

//]]>
