function DESemail(emailname,emailserver) {
	document.write("<a href='mailto:" + emailname + "@" + emailserver +"'>");
	document.write(emailname + "@" + emailserver); 
	document.write("</a>"); 
}


jQuery.fn.textLimiter = function(counter_id){
	return this.each(function(){
		if(typeof(nr) == "undefined") { nr = 0; }                           
			//var counter_id = 'des_counter';                           
			var max = this.getAttribute('maxlength');

			var jquery_pattern = '#' +counter_id +' > span';
			this.relatedElement = $(jquery_pattern)[0];
			nr++;
			$(this).bind("keyup", function(){
				var maxLength = this.getAttribute('maxlength');
				var currentLength = this.value.length;
				if(currentLength >= maxLength) {
					this.relatedElement.className = 'toomuch';
					this.value = this.value.substring(0, maxLength);
				} else {
					this.relatedElement.className = '';
				}
				var left_over = maxLength - currentLength; 
				this.relatedElement.firstChild.nodeValue = left_over;
			});
	});
};

$(document).ready(function(){
	
	$("#m_intro").textLimiter('des_counter');
	$("#m_description").textLimiter('des_counter2');
	
	$("input.btn").click( function() {
		$(this).val("Please Wait");
	});
	
	$(".fileUpload").each( function() {
		var cls = $(this).attr("class");
		//alert(cls);
		var width = ((cls.match(/w:(\d+)/)||[])[1]) || 640;
		var height = ((cls.match(/h:(\d+)/)||[])[1]) || 480;
		var fname = ((cls.match(/f:(\w+)/)||[])[1]) || "";

		$(this).html('<iframe src="/file_upload/index.php?fileName='+fname+'" width="'+width+'" height="'+height+'"></iframe>');
	});

});