var ajaxGet = function(what, params, where){
		new Request.HTML({
			headers: {'If-Modified-Since': 'Thu, 1 Jan 1970 00:00:00 GMT','Content-type':'text/html; charset=utf-8'},
			url: what,
			onRequest:function(){$(document.body).setStyle('cursor','progress');},
			method: 'get',
			evalScripts: true,
			evalResponse: true,
			update: where,
			onSuccess:function(){$(document.body).setStyle('cursor','auto');}
		}).send(params);
	}
var ajaxPost = function(form, what, where){
	new Request.HTML({
		url: what,
		onRequest:function(){$(document.body).setStyle('cursor','progress');},
		evalScripts: true,
		evalResponse: true,
		update: where,
		onSuccess:function(){$(document.body).setStyle('cursor','auto');}
	}).post(form);
}
var sendInfo = function(where, what){
	where.fade('in');
    where.innerHTML = "<span>"+what+"</span>";
    (function(){where.getElement('span').fade('out');where.fade('out');}).delay(3000);
}

var redirect = function(){
    (function(){
        document.location.href='index.php';
    }).delay(5000);
}

var reloadPage=function(){
	document.location.reload(true);
    return true;	
}
var clean_ms = function(str){
	//str = str.replace(/\n/gi, '[LB]');
	str = str.replace(/^\s*|\s*$/g,'');//remove whitespaces
	str = str.replace(/<meta(?:.*)\/>/gi, '');//remove META-tags
	str = str.replace(/<meta(?:.*)\>/gi, '');
	str = str.replace(/<link(?:.*)\/>/gi, '');//remove LINK-tags (with no clickable text - meaning the link tag is closed)
	str = str.replace(/<link(?:.*)\>/gi, '');
	str = str.replace(/<xml>(?:(\n|.)*)<\/xml>/gi, '');//remove XML-tags (n = linebreak) reg exp meaning "linebreak or any character-how many you like till you find </xml>"
	str = str.replace(/<\/xml>/gi, '');
	str = str.replace(/<!--(?:.*)-->/gi, '');//remove comments-tags
	str = str.replace(/<!--(?:(\n|.)*)-->/gi, '');//remove comments-tags over multiple lines
	str = str.replace(/\sclass="MsoNormal"/gi, '');//remove class "MsoNormal"
	str = str.replace(/<o:p>(?:.*)<\/o:p>/gi, '');//remove tag o:p???
	str = str.replace(/<style(?:(\n|.)*)<\/style>/gi, '');//remove style-tags (n = linebreak) reg exp meaning "linebreak or any character-how many you like till you find </style>"
	str = str.replace(/<style(?:.*)>/gi, '');//<style type="text/css">
	//experimental added by me (aiham)
	str = str.replace(/<o:(?:.*)\>/gi, '');
	str = str.replace(/<\/o:(?:.*)>/gi, '');
	str = str.replace(/<w:(?:.*)>/gi, '');
	str = str.replace(/<\/w:(?:.*)>/gi, '');
	str = str.replace(/<m:(?:.*)>/gi, '');
	str = str.replace(/<\/m:(?:.*)>/gi, '');//
	str = str.replace(/<!(?:.*)-->/gi, '');//
	//remove <p> to <br/>
	str = str.replace(/<p .*?>/gi, '');
	str = str.replace(/<p.*?>/gi, '');
	str = str.replace(/<\/p>/gi, '<br/><br/>');
	//str = str.replace(/<font .*?>/gi, ''); - this is removing style - not good leave it there for now...
	//str = str.replace(/<\/font>/gi, '');
	//str = str.replace(/\sstyle="(?:.*?)">/gi, '>');//remove style property
	//str = str.replace(/<span>/gi, '');//remove span tag
	//str = str.replace(/<\/span>/gi, '');
	str = str.replace(/^\s+/,''); // from START remove whitespace
	str = str.replace(/\s+$/,''); //  after END remove whitespace
	//el.getParent('table').getElement('.clean_text').value=str;
	//console.log("cleanning done");
	return str;
}

var searchDB = function(sok){
	if(sok.length>2){
		$('_search_results').fade('in');
		if(this.s==null){
			this.s=new Request();
		}else{
			this.s.cancel();
		}
		this.s=new Request({
			method: 'get', 
			url: 'suggest.php',
			data:'s='+$('txt_search').value,
			onRequest:function(){
				$('txt_search').setStyles({
					'background-image':'url(images/spinner.gif)',
					'background-position':'center right',
					'background-repeat':'no-repeat'
				});
			},
			onSuccess:function(responseText){
				$('_search_results').innerHTML=responseText;
				$('txt_search').setStyles({
					'background-image':'none'
				});
				$('search_close').setStyle('display','block');
			},
			evalScripts :true,
			evalResponse :false
		}).send();
	}else{
		$('_search_results').fade('out');
	}
}

var closeSearchDB = function(){
	$('_search_results').innerHTML='';
	$('_search_results').fade('out');
	$('txt_search').value='Sökord';
	$('search_close').setStyle('display','none');
}

var searchDataDB = function(sok){
	if(sok.length>2){
		if(this.s==null){
			this.s=new Request();
		}else{
			this.s.cancel();
		}
		this.s=new Request({
			method: 'get', 
			url: 'map_search.php',
			data:'s='+$('txt_map_search').value+'&arr='+arr_criterias,
			onRequest:function(){
				$('txt_map_search').setStyles({
					'background-image':'url(images/spinner.gif)',
					'background-position':'center right',
					'background-repeat':'no-repeat'
				});
			},
			onSuccess:function(responseText){
				$('map_results').innerHTML=responseText;
				$('txt_map_search').setStyles({
					'background-image':'none'
				});
				$('search_map_close').setStyle('display','block');
			},
			evalScripts :true,
			evalResponse :false
		}).send();
	}else{
		$('map_results').innerHTML='';
		if(m){
			m.clearOverlays();
		}
	}
}
var closeMapSearchDB = function(){
	$('map_results').innerHTML='';
	if(m){
		m.clearOverlays();
	}	
	$('txt_map_search').value='Sökord';
	$('search_map_close').setStyle('display','none');
}
var mslides;
var addthis_config = {
        services_compact: 'email, facebook, twitter, more',
        services_exclude: 'print'
}
window.addEvents({
		'domready' :function(){
			/*$('search_help').addEvents({
				'mouseenter': function(){this.src='images/ico_search_over.jpg';},
				'mouseleave': function(){this.src='images/ico_search.jpg';}
			})*/
			$('txt_search').addEvents({
				'focus':function(){
					if(this.value=='Sökord'){
						this.value='';
					}
				},
				'blur':function(){
					if(this.value.length<2){
						this.value='Sökord';
					}
				}
			})
			if($('txt_map_search')){
				$('txt_map_search').addEvents({
					'focus':function(){
						if(this.value=='Sökord'){
							this.value='';
						}
					},
					'blur':function(){
						if(this.value.length<2){
							this.value='Sökord';
							$('search_map_close').setStyle('display','none');
						}
					}
				})
			}
			//$('container').setStyle('position','relative');
			$('container').setStyles({
				'position':'relative',
				'top':$('header').offsetHeight-58,
				'margin-bottom':$('header').offsetHeight-58
			});
			$('_search_results').fade('hide');
		},
		'load':function(){
			
		}
})
