
//Prototype Version
function pr_change_cal(m,Y,p) {

	document.searchdetails.date_month.value = m;
  	document.searchdetails.date_year.value = Y;

  	switch(p){
	  	case 1: page='dating';
	  	break;
	  	default: page='searching';
	}
	  var myAjax1 = new Ajax.Request(
	    "/ajax/rld_cal.php",
	    {   method: 'post',
	    	parameters: 'page='+page+'&month='+m+'&year='+Y,
	    	//parameters: Form.serialize($('dienstplan'))+'&filid='+filid+'&feiertag='+feiertag+'&karlimanni=1',
	    	//onLoading:function(){$('loading').style.visibility = 'visible';},
	    	//onSuccess:function(){$('loading').style.visibility = 'hidden';},
	    	//onComplete:function(originalRequest){$('div_cal').innerHTML = originalRequest.responseText;}
	    	onComplete:myajax_response
	    	}
	  );

}
function myajax_response( originalRequest ) {
  // $('div_cal').innerHTML = "Rasiner";//originalRequest.responseText;

   document.getElementById('div_cal').innerHTML = originalRequest.responseText;
}

////////////////////////////////////////////////////////////////////////////////////////





function createRequestObject() {
                var req = null;
                try{
                    req = new XMLHttpRequest();
                }
                catch (ms){
                    try{
                        req = new ActiveXObject("Msxml2.XMLHTTP");
                    }
                    catch (nonms){
                        try{
                            req = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (failed){
                            req = null;
                        }
                    }
                }
    return req;
}

var http = createRequestObject();

function sndReq(action, search_str, city_id) {
    //http.open('get', './ajax/ajax_functions.php?ajax_action='+action+'&ajax_like='+search_str+'&ajax_city_id='+city_id);
    http.open('get', './index.ajax?ajax_action='+action+'&ajax_like='+search_str+'&ajax_city_id='+city_id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function send_ajax_email(action,from, to, message,url,u){
    http.open('get', './ajax/ajax_functions.php?ajax_action='+action+'&from='+from+'&to='+to+'&message='+message+'&url='+url+'&tusername='+u);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function send_ajax_testtool(action,docid, testmessage,url,u, req){
    http.open('get', './ajax/ajax_functions.php?ajax_action='+action+'&doc_id='+docid+'&testmessage='+testmessage+'&url='+url+'&testusername='+u+'&req='+req);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function send_ajax_location_suggestion(action,tusername,sender_email,suggest_spot_name,new_spot_desc,suggest_spot_street,suggest_spot_zip,suggest_city_id,suggest_spot_suburb,category){
    http.open('get', './ajax/ajax_functions.php?ajax_action='+action+'&suggest_city_id='+suggest_city_id+'&sugg_username='+tusername+'&sugg_sender_email='+sender_email+'&suggest_spot_name='+suggest_spot_name+'&new_spot_desc='+new_spot_desc+'&suggest_spot_street='+suggest_spot_street+'&suggest_spot_zip='+suggest_spot_zip+'&suggest_spot_suburb='+suggest_spot_suburb+'&category='+category);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function myalert(action){
alert(action);

}

function sndReq_via_ajax_functions(action, search_str, city_id) {

    http.open('get', './ajax/ajax_functions.php?ajax_action='+action+'&ajax_like='+search_str+'&ajax_city_id='+city_id);
    //http.open('get', './index.ajax?ajax_action='+action+'&ajax_like='+search_str+'&ajax_city_id='+city_id);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function change_cal(m,Y,p) {

  	switch(p){
	  	case 1: page='dating';
	  	break;
	  	default: page='searching';
	}
	if(m<10)document.searchdetails.date_month.value = "0"+m;
	else document.searchdetails.date_month.value = m;
  	document.searchdetails.date_year.value = Y;

    http.open('get', './ajax/ajax_functions.php?ajax_action=div_cal&page='+page+'&month='+m+'&year='+Y);
    http.onreadystatechange = handleResponse;
    http.send(null);
}


function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;

        var update = new Array();
//alert(response);
             //document.getElementById('myspots').value = response;
        if(response.indexOf('|' != -1)) {
            update = response.split('|');


            document.getElementById(update[0]).style.display = "inline";
            document.getElementById(update[0]).style.visibility = "visible";
            document.getElementById(update[0]).innerHTML = update[1];

            //document.getElementById('myspots').innerHTML = "hallo";
        }
    }
}

function loadrecord(uname,fullname,id) {

		document.getElementById('spot_fullname').value=fullname;
		//document.getElementById('hidden_spot_username').value=uname;
		//document.getElementById('hidden_spot_id').value=id;
}
function loadrecord_ls(fullname) {
		document.getElementById('spot_fullname_ls').value=fullname;
}
function loadrecord_ls2(fullname) {
		document.getElementById('spot_fullname_ls2').value=fullname;
}
function loadrecord_ld(fullname) {
		document.getElementById('spot_fullname_ld').value=fullname;
}
function loadrecord2(fullname) {
		document.getElementById('spot_fullname2').value=fullname;
}
function loadrecord_sp(fullname) {
		document.getElementById('spot_fullname_sp').value=fullname;
}


function clean_loc() {
		document.getElementById('spot_fullname').value='';
}
function clean_loc_ls() {
		document.getElementById('spot_fullname_ls').value='';
}
function clean_loc_ls2() {
		document.getElementById('spot_fullname_ls2').value='';
}
function clean_loc_ld() {
		document.getElementById('spot_fullname_ld').value='';
}
function clean_loc2() {
		document.getElementById('spot_fullname2').value='';
}
function clean_loc_sp() {
		document.getElementById('search_spot_fullname').value='';
}

function hide_tag(val){
		document.getElementById(val).value="";
		document.getElementById(val).style.visibility = "hidden";
}
function nodisplay(val){
		document.getElementById(val).value="";
		document.getElementById(val).style.display = "none";
}

/*
var url = "./ajax/ajax_functions.php?param=";

function get_spot(idValue)
{

	//var idValue = document.getElementById("agtel").value;
	var myRandom = parseInt(Math.random()*99999999); // cache buster
	http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}


function handleHttpResponse()
{
	if (http.readyState == 4)
	{
		document.getElementById("hiddenDIV2").innerHTML=http.responseText;
		document.getElementById("hiddenDIV2").style.width="200px";
		//alert(document.getElementById("response_table_font").size);
		var l = document.getElementById("response_table").rows.length;
	    document.getElementById("hiddenDIV2").style.height= l*25 +"px";
		document.getElementById("hiddenDIV2").style.visibility="visible";
	}
}

function loadrecord(record) {
	//document.forms[1].telno.value = record;
	document.getElementById("spot_fullname").value = record;
	document.getElementById("hiddenDIV2").innerHTML='';
	document.getElementById("hiddenDIV2").style.height="0px";
	document.getElementById("hiddenDIV2").style.width="0px";
	document.getElementById("hiddenDIV2").style.visibility="hidden";
}
*/





var dragobjekt = null;//Das Objekt, das gerade bewegt wird.
// Position, an der das Objekt angeklickt wurde.
// relativ zur oberen, rechten Ecke des Objekts
var dragx = 0;
var dragy = 0;
// Mausposition
// relativ zur oberen, rechten Ecke des Fensters
var posx = 0;
var posy = 0;
function draginit() {
// Initialisierung der �berwachung der Events
document.onmousemove = drag;
document.onmouseup = dragstop;
}
function dragstart(element) {




//Wird aufgerufen, wenn ein Objekt bewegt werden soll.
//Parameter element: Das zu bewegende Objekt.
dragobjekt = element;
dragx = posx - dragobjekt.offsetLeft;
dragy = posy - dragobjekt.offsetTop;
}
function dragstop() {

//Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
dragobjekt=null;
}
function drag(ereignis) {
//Wird aufgerufen, wenn die Maus bewegt wird und bewegt bei Bedarf das Objekt.
posx = document.all ? window.event.clientX : ereignis.pageX;
posy = document.all ? window.event.clientY : ereignis.pageY;
if(dragobjekt != null) {
dragobjekt.style.left = (posx - dragx) + "px";
dragobjekt.style.top = (posy - dragy) + "px";
}
}

function hide(id)
{
  document.getElementById(id).style.display = 'none';
 // document.getElementById('verdunkler').style.display = 'none'
}
function show(id)
{
  //document.getElementById(id).style.display = 'block';
 // document.getElementById('verdunkler').style.display = 'block'
 // document.getElementById('verdunkler').style.zIndex  = 100;
 // document.getElementById(id).style.zIndex  = 200;

	document.getElementById(id).style.zIndex  = 500;
	document.getElementById(id).style.display = 'block';

  //document.getElementById(id).style.display = 'inline';


}

function showleft(id)
{
  document.getElementById(id).style.display = 'block'
  document.getElementById('calendar_right').style.display = 'none'
}

function showright(id)
{
  document.getElementById(id).style.display = 'block'
  document.getElementById('calendar_left').style.display = 'none'
}

function maus(id)
{
  //alert(document.getElementById(id).style.zIndex);

   document.getElementById('div1').style.zIndex  = 1;
   document.getElementById('div2').style.zIndex  = 2;
   document.getElementById('div3').style.zIndex  = 3;
   document.getElementById(id).style.zIndex  = 300;


}


