function showLoading(){
					
					$('ajaxloadingcont').style.display="block";	
					return true;
}

function hideLoading(){
					
					$('ajaxloadingcont').style.display="none";	
					return true;
}

function closeOverlay(){
			$('overlay').innerHTML="";
			$('overlay').style.display = 'none';
			$('overlay').onclick = function(){};
			
}


function link_confirm(msg, link){
	if(qconfirm(msg)){location.href = link;}

}
function chooseSearch(what){
	if(what == 'csponsor'){
		$('cmaz').checked=false;$('opismaz').style.display = 'none';
		$('cfriend').checked=false;$('opisfriend').style.display = 'none';
		$('clover').checked=false;$('opislover').style.display = 'none';
	}else{
		$('csponsor').checked=false;
		
		if(what == 'cmaz'){	if($('opismaz').style.display == 'none'){$('opismaz').style.display = 'block';}else{$('opismaz').style.display = 'none';}}
		if(what == 'clover'){	if($('opislover').style.display == 'none'){$('opislover').style.display = 'block';}else{$('opislover').style.display = 'none';}}
		if(what == 'cfriend'){	if($('opisfriend').style.display == 'none'){$('opisfriend').style.display = 'block';}else{$('opisfriend').style.display = 'none';}}

}
}

function bounce(){
$('informer').stop();
}
function infoLeft(){
$('informer').direction='left';

}
function infoRight(){
$('informer').direction='right';
}


function favDel(userid, typ){
if (typ=='fav'){var msg=DEL_FAV_CONF;}
if (typ=='block'){var msg=DEL_BLOCK_CONF;}

	if(($('confirm') && $('confirm').checked == false) || qconfirm(msg)){

		var ajax = new Ajax.Request($('page_url').value+'modules/favdel.php?userid='+userid+'&typ='+typ,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
				if(typ=='fav'){
					if($('hit_id_'+userid))$('hit_id_'+userid).style.display = "none";
					if($('favtxt'))$('favtxt').innerHTML = ADD_TO_FAV;
					if($('favtxt'))$('favimg').src = 'img/checked_icon_big.gif';
					if($('favtxt'))$('favlink').onclick=function() {
							 favoriteAdd(userid, typ);
						};
				}
				if(typ=='block'){
					if($('hit_id_'+userid))$('hit_id_'+userid).style.display = "none";
					if($('blocktxt'))$('blocktxt').innerHTML = ADD_TO_BLOCK;
					if($('blockimg'))$('blockimg').src = 'img/block_icon_big.gif';
					if($('blocklink'))$('blocklink').onclick=function() {
							 favoriteAdd(userid, typ);
						};
				}
				}else{
				my_error (CANT_DEL);
				}
				 
					 
		 }
		});
	
	}
}


function toggleS_Sponsor(){

	if($('preferencje').value == "sponsor"){
		$('s_sponsor').style.display = "block";
		//location.href = '#sponsor';
	}else{
		$('s_sponsor').style.display = "none";
	}

}
function toggleS_SponsorBlocked(){
	if($('preferencje').value == "sponsor"){
		showBoth();
		$('preferencje').options[0].selected=true ;
	}

}
function switcher(co){
	if(co == "szukaj"){
		$('SU_hits').style.display = "none";
		$('form_container').style.display = "block";
		$('SW_results').style.display = "none";
		$('SW_search').style.display = "block";
	}

	if(co == "wyniki"){
		$('SU_hits').style.display = "block";
		$('form_container').style.display = "none";
		$('SW_results').style.display = "block";
		$('SW_search').style.display = "none";
	}
}
function showProfile(element){

var fszyskie = $$('div.see_user_data');

        if(element != "all"){

                        for (i=0; i < fszyskie.length; i++) {
                                if($(fszyskie[i].id)){$(fszyskie[i].id).style.display = "none";}
                        }
                        $(element).style.display = "block";
        }else{
                                for (i=0; i < fszyskie.length; i++) {
                                if($(fszyskie[i].id)){$(fszyskie[i].id).style.display = "block";}
                        }
        }



}
function top10sw(element){

	var mycars=new Array();
	mycars[0] = "SU_top10";
	mycars[1] = "SU_wgyou";
	mycars[2] = "SU_active";
mycars[3] = "SU_visits";

	if(element!="all"){

		for (var i = 0; i < mycars.length; i++){
			if($(mycars[i]))$(mycars[i]).style.display = "none";
			}
		$(element).style.display = "block";
	}
}	
	
	
	
function setFlirtMsg(){
	$('flirt_area').style.display="block";
	$('flirt_buttons').style.display="block";
	
	getFlirtTresc($('msg').value);

}
function getFlirtTresc(id){

	var ajax = new Ajax.Request($('page_url').value+'modules/flirt_tresc.php?msg='+id,
	   {

		method: 'GET',	
		
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					  alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			var data = response.responseText.evalJSON();
			
			var polish = replace_polish(data['msg']);
			$('flirtMsgView').innerHTML=data['msg']; 
					 
		 }
		});

}
function activateFlirtMsg(){

	$('flirt_area').style.display="none";
	$('flirt_buttons').style.display="none";


	var ajax = new Ajax.Request($('page_url').value+'modules/flirt_msgs.php?branch='+$('kat').value,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			var data = response.responseText.evalJSON();
			$('msg').options.length=0;
			

			for (var i=0;i<data.length;i++){
				var polish = replace_polish(data[i]['nazwa']);
				$('msg').options[i] = new Option(polish,data[i]['id']);
			}
			$('msg').disabled=false; 
					 
		 }
		});

}


function widokToggle(value){
$('s_hits').className=value;

}
function activateKraje(){




	var ajax = new Ajax.Request($('page_url').value+'modules/kraje.php?continent='+$('continent').value,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			var data = response.responseText.evalJSON();
				dm.options.length=0;
				$('kraje').options.length=0;
			$('kraje').options[0]=new Option('***wybierz***','');
			for (var i=1;i<data.length;i++){
				var polish = replace_polish(data[i]['nazwa']);
				$('kraje').options[i] = new Option(polish,data[i]['id']);
			}
			$('kraje').disabled=false; 
					 
		 }
		});

}
function activateMiasta(){

//alert($('dmtxt').value);
	if($('kraje').value != ""){	
		var ajax = new Ajax.Request($('page_url').value+'modules/miasta.php?kraj='+$('kraje').value+'&string='+$('dmtxt').value,
		   {

			method: 'GET',	
				overrideMimeType: 'text/html; charset=ISO-8859-2',
		
			onLoading: function(){
				showLoading();
			},
			onFailure: function(){
						   
						   alert(ERROR_OCUR);
						 },	
			onSuccess: function(response){
							 hideLoading();
							 //if($('combolist').isVisible)dm.toggle();
				dm.options.length=0;
				var data = response.responseText.evalJSON();
				//if($('combotbl'))$('combotbl').parentNode.removeChild($('combotbl'));
				for (var i=0;i<data.length;i++){
					dm.add(new ComboBoxItem(data[i]['nazwa'],data[i]['id']));
				}
				 
				if(dm.options.length > 0 && $('combolist').style.display!="block")dm.toggle();	
				
			 }
			});
	}
}

function replace_polish(txt){
var newtxt = txt.replace("&changea;", "ą");
newtxt = newtxt.replace("&changel;", "ł");
newtxt = newtxt.replace("&changee;", "ę");
newtxt = newtxt.replace("&changeo;", "ó");
newtxt = newtxt.replace("&changezz;", "ź");
newtxt = newtxt.replace("&changez;", "ż");
newtxt = newtxt.replace("&changes;", "ś");
newtxt = newtxt.replace("&changec;", "ć");
newtxt = newtxt.replace("&changen;", "ń");


return newtxt;
}

function getCountries(){
	

	var ajax = new Ajax.Request($('page_url').value+'modules/kraje.php',
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			for (var i=0;i<1000;i++){
				dm.add(  new ComboBoxItem(data[i]['nazwa'],1) )
					}
				 
					 
		 }
		});
	
}
function readKiss(msg){
		if($('confirm').checked == false ||qconfirm(MRK_KSS_RD)){
	if($('kiss_tr_'+msg).className!="read"){
		$('kiss_tr_'+msg).className="read";
		if($('countNewKisses').innerHTML!=0)$('countNewKisses').innerHTML = $('countNewKisses').innerHTML - 1;
	}
	var ajax = new Ajax.Request($('page_url').value+'modules/readkiss.php?kiss='+msg,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
				

				}else{
				my_error (CNT_RD);
				}
				 
					 
		 }
		});
		}
}
function readSmile(msg){
	if($('confirm').checked == false ||qconfirm(MRK_SML_RD)){
	if($('kiss_tr_'+msg).className!="read"){
		$('kiss_tr_'+msg).className="read";
		if($('countNewSmiles').innerHTML!=0)$('countNewSmiles').innerHTML = $('countNewSmiles').innerHTML - 1;
	}
	var ajax = new Ajax.Request($('page_url').value+'modules/readkiss.php?kiss='+msg,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
				

				}else{
				my_error (CNT_RD);
				}
				 
					 
		 }
		});
	}
}


function qconfirm(qtext){ 
	if (typeof(window.opera) != 'undefined') return true; 
	var is_confirmed = confirm(qtext); 
	return is_confirmed; 
}	

function favoriteAdd(usid, typ){
	
if (typ=='fav'){var msg= TO_FAV ;}
if (typ=='block'){var msg= CNF_ADD_BLCK ;}
	if( qconfirm(msg)){
	//type 1 = kiss
	// type 0 = smile
		  var ajax = new Ajax.Request($('page_url').value+'modules/favorites.php?user_id='+usid+'&typ='+typ,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
					if(typ=='fav'){
						$('favtxt').innerHTML = DEL_FAV;
						$('favimg').src = 'img/bin_icon_big.gif';
						$('favlink').onclick=function() {
								 favDel(usid, typ);
							};
					}
					if(typ=='block'){
						$('blocktxt').innerHTML = DEL_BLOCK;
						$('blockimg').src = 'img/block_icon_big2.gif';
						$('blocklink').onclick=function() {
								 favDel(usid, typ);
							};
					}
				}else{
				my_error (CANT_ADD_FAV);
				}
				 
					 
		 }
		});
	}
}
function sendKiss(usid,type){
	if(type == 0){var rodzaj = SMILE}
	if(type == 1){var rodzaj = KISS}
	if(qconfirm(SEND_CONF + rodzaj+"?")){
		//type 1 = kiss
		// type 0 = smile
			  var ajax = new Ajax.Request($('page_url').value+'modules/kiss.php?user_id='+usid+'&type='+type,
		   {

			method: 'GET',	
				overrideMimeType: 'text/html; charset=ISO-8859-2',
		
			onLoading: function(){
				showLoading();
			},
			onFailure: function(){
						   
						   alert(ERROR_OCUR);
						 },	
			onSuccess: function(response){
				hideLoading();
				data = response.responseText.evalJSON();
				if (data['status']=='ok'){
					if(type == '1')$('lastkiss').innerHTML = data['data'];
					if(type == '0')$('lastsmile').innerHTML = data['data'];
					}else if (data['status']=='error'){
						my_error (UNO_MINUTO);
					}else if (data['status']=='blocked'){
						my_error (BLOCKED_MSG);
					}
					 
						 
			 }
			});
	}
}




function changeHeart(mark){

				for (var i=1;i<=mark;i++) {
					var heart = $('rating_heart_'+i);
					heart.className="full";
				}
		$('rate').innerHTML=YR_RATE+": "+mark;
	
}
function changeHeartBack(){
	$('rate').innerHTML=YR_RATE+": 0";
				for (var i=1;i<=10;i++) {
					var heart = $('rating_heart_'+i);
					heart.className="empty";
				}
	
}

function UnRate(){

$('your').parentNode.removeChild($('your'));
if ($('yourrt'))$('yourrt').parentNode.removeChild($('yourrt'));
$('serca').style.display = "block";
$('rate').style.display = "block";
}


function rateMe(user_id,mark){
		
if (mark < 0 || mark > 10){  my_error ("Do dzioba, Broda!!!"); return };
	   var ajax = new Ajax.Request($('page_url').value+'modules/rating.php?mark='+mark+'&user_id='+user_id,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
						
					showLoading();
				
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
			
					$('serca').style.display = "none";
					$('rate').style.display = "none";
					$('main_rt').innerHTML=GENER_RATE +": "+data['srednia'];

					$('main_rt_gr').style.width = data['srednia'] / 10 * 149 +"px";
					

					var rate = document.createElement("div");
					$('ocenianie').appendChild(rate);
					
					rate.className="rt";
					rate.id="yourrt";
					rate.innerHTML=YR_RATE+": "+mark;

					var total_rating = document.createElement("div");
					$('ocenianie').appendChild(total_rating);
					total_rating.className="total_rating";
					total_rating.id="your";

					var tr_bg = document.createElement("div");
					total_rating.appendChild(tr_bg);
					tr_bg.className="tr_bg";
					

					var tr_fill = document.createElement("div");
					tr_bg.appendChild(tr_fill);
					tr_fill.className="tr_fill";

					var percent = mark / 10;
					var ww = 149 * percent;
					tr_fill.style.width = ww+"px";

					

					var reset = document.createElement("a");
					total_rating.appendChild(reset);
					reset.className="reset";
					reset.innerHTML= CHANGE ;
					reset.onclick=function() {
						 UnRate();
					};
			 }else{
			 my_error (LOGIN_FIRST);
			 }
		 }
		});
	



}

function delMsg(msg,type,status,whose){
	if($('confirm').checked == false || qconfirm(DEL_CONF)){

				
	var ajax = new Ajax.Request($('page_url').value+'modules/delmsg.php?msg='+msg+'&type='+type+'&whose='+whose,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
			showLoading();
		},
		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
			hideLoading();
			data = response.responseText.evalJSON();
			if (data['status']=='ok'){
				if(whose!='sent'){
					if (type == 'kiss' ){var tr_type='kiss';var counting="countNewKisses";	var counting2="countKisses";}
					if (type == 'smile'){var tr_type='kiss';var counting="countNewSmiles";	var counting2="countSmiles";}
					if (type == 'msg'){var tr_type='msg';var counting="countNewMsgs";		var counting2="countMsgs";}
					if (type == 'flirt'){var tr_type='msg';var counting="countNewFMsgs";	var counting2="countFMsgs";}
					var res = document.getElementById(tr_type+'_tr_'+msg);
					res.parentNode.removeChild(res);
					if($(counting2).innerHTML!=0)$(counting2).innerHTML = $(counting2).innerHTML - 1;
					if(status=="0"){
						
						if($(counting).innerHTML!=0)$(counting).innerHTML = $(counting).innerHTML - 1;
						
					}
				}else if(whose=='sent'){

					if (type == 'kiss' ){var tr_type='kiss';var counting="countSentNewKisses";	var counting2="countSentKisses";}
					if (type == 'smile'){var tr_type='kiss';var counting="countSentNewSmiles";	var counting2="countSentSmiles";}
					if (type == 'msg'){var tr_type='msg';var counting="countSentNewMsgs";		var counting2="countSentMsgs";}
					if (type == 'flirt'){var tr_type='msg';var counting="countSentNewFMsgs";	var counting2="countSentFMsgs";}
					var res = document.getElementById(tr_type+'_tr_'+msg);
					res.parentNode.removeChild(res);
					if($(counting2).innerHTML!=0)$(counting2).innerHTML = $(counting2).innerHTML - 1;
					if(status=="0"){
						
						if($(counting).innerHTML!=0)$(counting).innerHTML = $(counting).innerHTML - 1;
					}		
				}
				}else{
				my_error (CANT_DEL);
				}
				 
					 
		 }
		});




	}
}

function cyclic(userId){


	   var ajax = new Ajax.Request($('page_url').value+'modules/cyclic.php',
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	

		onFailure: function(){
					   
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){

			data = response.responseText.evalJSON();
			

			if(data['0']['nowe']!= $('cyclic').innerHTML){if(data['0']['nowe']> $('cyclic').innerHTML){flashing('cyclic',data['0']['nowe'])};$('cyclic').innerHTML = data['0']['nowe'];}
			if(data['1']['nowe']!= $('cyclic1').innerHTML){if(data['1']['nowe']> $('cyclic1').innerHTML){flashing('cyclic1',data['1']['nowe'])};$('cyclic1').innerHTML = data['1']['nowe'];}
			if(data['2']['nowe']!= $('cyclic2').innerHTML){if(data['2']['nowe']> $('cyclic2').innerHTML){flashing('cyclic2',data['2']['nowe'])};$('cyclic2').innerHTML = data['2']['nowe'];}
			if(data['3']['nowe']!= $('cyclic3').innerHTML){if(data['3']['nowe']> $('cyclic3').innerHTML){flashing('cyclic3',data['3']['nowe'])};$('cyclic3').innerHTML = data['3']['nowe'];}
		 }
		});


}
function flashing(el, val){
	
	var blink= $(el).parentNode.appendChild(document.createElement("blink"));
	$(el).parentNode.removeChild($(el));
	blink.id =el;
	blink.innerHTML = val;
	blink.style.color = "red";
}
function get_fromUrl(){
var url = $('page_url').value;
var string = $('QString').value;
var fromUrl = url;
if (string != ""){fromUrl = fromUrl + "?" + string;}
$('fromUrl').value = fromUrl;

}

function showAns(){

$('answer').parentNode.removeChild($('answer'));
$('msg_ff').style.display="block";
$('topic').value='Re: ' + $('reciv_msg_subject').innerHTML;

}
function showFAns(){

$('answer').parentNode.removeChild($('answer'));
$('flirt_f').style.display="block";


}
function expandSzukaj(what){


        if($(what + '_form').style.display != "block"){
			
			if(!$(what+'_test'))loadAjaxForm(what);
			if(!$('wiek_test')){loadAjaxWiekForm(what);}else{
					$(what+'_wiek_form').appendChild($('wiek_test'));
			}
			$('maz_form').style.display = "none";$('maz').style.height = "80px";
			$('friend_form').style.display = "none";$('friend').style.height = "80px";
			$('lover_form').style.display = "none";$('lover').style.height = "80px";
			$('unknwn_form').style.display = "none";$('unknwn').style.height = "80px";

                $(what + '_form').style.display = "block";
                $(what).style.height = "";
        }else{
                $(what + '_form').style.display = "none";
                $(what).style.height = "80px";

        }

}






function chk_nick(value){
getData($('page_url').value+'modules/nick.php?nick='+value, 'chk_nick', '0');
$('chk_nick').style.display = "block";
}

function CloseLogin(){

		var thisid = $('interdeus').childNodes[0].id;
		if (thisid == 'login_body' || thisid == 'register_body'|| thisid == 'both_body'){	
			$('hidden_body').appendChild($(thisid));
		}


			closeOverlay();

}
function Deus(){

	var body = document.getElementById("body");		
			
	
	var overlay = $('overlay');
	overlay.style.display = 'block';
	var height = screen.height;
	
	if(height < getElementHeight('wrapper')){height = getElementHeight('wrapper');}else{height = height -50;}
	$('overlay').style.height =   height +"px";

	
	var deusexmachina = overlay.appendChild(document.createElement("div"));
	deusexmachina.id = "deusexmachina";

	var x_container = deusexmachina.appendChild(document.createElement("div"));
	x_container.id="x_container";
	
	
	var deustop = deusexmachina.appendChild(document.createElement("div"));
	deustop.id = "deustop";
	//deustop.className = "deustop";
	
	deustop.style.width = "616px";
	deustop.style.height = "12px";
	deustop.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/deus_top_bg.png',sizingMethod='image')";
	var aa = deustop.appendChild(document.createElement("a"));

	var x = x_container.appendChild(document.createElement("div"));
	x.id="x";
	

	var ximg = x.appendChild(document.createElement("img"));
	ximg.src = $('page_url').value+"img/x.jpg";
	ximg.id = "ximg";
	ximg.onclick = function(){CloseLogin();};

	var deusmiddle = deusexmachina.appendChild(document.createElement("div"));

	deusmiddle.id = "deusmiddle";
	deusmiddle.style.width = "616px";
	deusmiddle.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/deus_bg.png',sizingMethod='scale')";
	//var deusmiddle_l = deusmiddle.appendChild(document.createElement("div"));
	//deusmiddle_l.id = "deusmiddle_l";

	var interdeus = deusmiddle.appendChild(document.createElement("div"));
	interdeus.id="interdeus";


	
	//var deusmiddle_r = deusmiddle.appendChild(document.createElement("div"));
	//deusmiddle_r.id = "deusmiddle_r";

	var deusbottom = deusexmachina.appendChild(document.createElement("div"));
	deusbottom.id = "deusbottom";
	deusbottom.style.width = "616px";
	deusbottom.style.height = "12px";
	deusbottom.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/deus_bot_bg.png',sizingMethod='image')";

	deusexmachina.setAttribute("z-index", "999");


	
}


function Welcome(){
	Deus();
	getData($('page_url').value+'modules/welcome.php', 'interdeus', '0');
}

function showBoth(){
	Deus();

	$('interdeus').appendChild($('both_body'));
	$('both_l').appendChild($('login_body'));
	$('both_r').appendChild($('register_body'));
	//getData($('page_url').value+'modules/login.php', 'interdeus', '0');
	location.href = '#page_top';
	get_fromUrl();
}

function showRegister(){
	Deus();

	$('interdeus').appendChild($('register_body'));
	//getData($('page_url').value+'modules/register.php', 'interdeus', '0');
	get_fromUrl();
}

function showLogin(){
	Deus();

	$('interdeus').appendChild($('login_body'));

	get_fromUrl();
	//getData($('page_url').value+'modules/login.php', 'interdeus', '0');
}
function loadAjaxForm(what){
	getData($('page_url').value+'modules/form.php?what='+what, what+'_profil_form', '1');
}
function loadAjaxWiekForm(what){
	getData($('page_url').value+'modules/form.php?', what+'_wiek_form', '0');
}
function loadAjaxFastForm(){
	
	getData($('page_url').value+'modules/form.php?what=fast', 'fast_form', '1');
	
}
function showMsg(to_user){
	Deus();
	getData($('page_url').value+'modules/msg.php?to='+to_user, 'interdeus', '1');
}

function showFlirt(to_user){
	Deus();
	getData($('page_url').value+'modules/flirt.php?to='+to_user, 'interdeus', '1');
}

function showMsgContent(msg, typ){
	Deus();
	if(typ != 'sent'){
		if($('msg_tr_'+msg).className!="read"){
			$('msg_tr_'+msg).className="read";
			if($('countNewMsgs').innerHTML!=0)$('countNewMsgs').innerHTML = $('countNewMsgs').innerHTML - 1;
		}
	}
	getData($('page_url').value+'modules/msg2.php?msg='+msg+'&typ='+typ, 'interdeus', '1');
}

function showMsgFContent(msg, typ){
	Deus();
	if(typ != 'sent'){
		if($('msg_tr_'+msg).className!="read"){
			$('msg_tr_'+msg).className="read";
			if($('countNewFMsgs').innerHTML!=0)$('countNewFMsgs').innerHTML = $('countNewFMsgs').innerHTML - 1;
		}
	}
	getData($('page_url').value+'modules/msg_f2.php?msg='+msg+'&typ='+typ, 'interdeus', '1');
}


   
      function ajax_msg(){
		  var ajax = new Ajax.Request($('page_url').value+'modules/msg.php',
          {
           //Ustawiamy metodę requestu na POST
			method: 'post',
	        parameters: {topic: $F('topic'), tresc: $F('tresc'), user_id: $F('user_id'),token: $F('token')},
			onSuccess: function(response){
				hideLoading();
				data = response.responseText.evalJSON();
					if(data.status == "ok"){							
							if($('msg_form')){

								$('msg_form').style.textAlign = "center";
								$('msg_form').innerHTML = MSG_SENT;
							
								if ($('lastmsg'))$('lastmsg').innerHTML = data['data'];
								}
						

					}else if (data.status=='blocked'){
							if($('msg_f')){
								$('msg_f').style.className = "blocked_info";
								$('msg_f').innerHTML = BLOCKED_MSG;
								
								
								}
							if($('msg_ff')){
								$('msg_ff').style.className = "blocked_info";
								$('msg_ff').innerHTML = BLOCKED_MSG;
								
								
								}

					}else if (data.status=='token'){

						alert(GIVE_TOKEN);
						
					}else{
                           $('msg_f').innerHTML = "Błąd";
                      }
                    
  
                      },
 
                     
  
		onLoading: function(){
					showLoading();
				
			},
 

           onFailure: function(){
                         $('ajax').innerHTML = '';
                         alert(ERROR_OCUR);
                       }
          });

       }
	         function ajax_flirtmsg(){
		  var ajax = new Ajax.Request($('page_url').value+'modules/flirt.php',
          {
           //Ustawiamy metodę requestu na POST
			method: 'post',
	        parameters: {msg: $F('msg'), user_id: $F('user_id')},
			onSuccess: function(response){
				hideLoading();

					data = response.responseText.evalJSON();
					if(data.status == "ok"){	
						
							if($('flirt_f')){
								$('flirt_f').style.textAlign = "center";
								$('flirt_f').innerHTML = MSG_SENT;
								if ($('lastfmsg'))$('lastfmsg').innerHTML = data['data'];
								}
		
                    }else if (data.status=='blocked'){
							if($('flirt_f')){
								$('flirt_f').style.className = "blocked_info";
								$('flirt_f').innerHTML = BLOCKED_MSG;
								
								
								}
							if($('msg_ff')){
								$('flirt_f').style.className = "blocked_info";
								$('msg_ff').innerHTML = BLOCKED_MSG;
								
								
								}

						
					}else{
                           $('flirt_f').innerHTML = "Błąd";
                      }
                    
  
                      },
 
                     
  
		onLoading: function(){
					showLoading();
				
			},
 

           onFailure: function(){
                         $('ajax').innerHTML = '';
                         alert(ERROR_OCUR);
                       }
          });

       }
function getData(zrodlo, cel, loadSign){
 	   var ajax = new Ajax.Request(zrodlo,
	   {

		method: 'GET',	
			overrideMimeType: 'text/html; charset=ISO-8859-2',
	
		onLoading: function(){
				
				if(loadSign == 1){	
					showLoading();
				}
			},

		 onFailure: function(){
					   $(cel).innerHTML = '';
					   alert(ERROR_OCUR);
					 },	
		onSuccess: function(response){
					 var response = response.responseText;
					 $(cel).innerHTML = response;
					 if(loadSign == 1){	
				hideLoading()
					 }	
					 
					 
		 }
		});
   hideLoading()
 }
function getElementHeight(Elem) {

		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}

	
			xPos = elem.offsetHeight;
	
		return xPos;

}
function showFoto(key, fotto){

	var height = screen.height;
	var body = document.getElementById("body");		

	var overlay = $('overlay');
	overlay.style.display = 'block';
	var height = screen.height;
	
	if(height < getElementHeight('wrapper')){height = getElementHeight('wrapper');}else{height = height -50;}
	$('overlay').style.height =   height +"px";

	overlay.onclick = function(){
			closeOverlay();

			};
	//overlay.setAttribute("z-index", "90");
	var foto = overlay.appendChild(document.createElement("div"));
	foto.id = "fotos";
	//alert($('page_url').value+'getfoto.php?user='+user+'&foto='+fotto);
	getData($('page_url').value+'modules/getfoto.php?key='+key+'&fotoid='+fotto+'&type=nothumb', 'fotos', '1')
	//foto.innerHTML="<div onclick='javascript:close_error()' id='err_x' class='err_x'>X</div><ul><li><span class='error_msg'>"+phrase+"</span></li></ul>";
location.href = '#page_top'; 
}
function show2ndFoto(key, fotto, usid){

	var height = screen.height;
	var body = document.getElementById("body");		

	var overlay = $('overlay');
	overlay.style.display = 'block';
	var height = screen.height;
	
	if(height < getElementHeight('wrapper')){height = getElementHeight('wrapper');}else{height = height -50;}
	$('overlay').style.height =   height +"px";

	overlay.onclick = function(){
		//	closeOverlay();

			};
	//overlay.setAttribute("z-index", "90");
	var foto = overlay.appendChild(document.createElement("div"));
	foto.id = "fotos";
	//alert($('page_url').value+'getfoto.php?user='+user+'&foto='+fotto);


getData($('page_url').value+'modules/get2ndfoto.php?key='+key+'&fotoid='+fotto+'&user_id='+usid+'&type=nothumb', 'fotos', '1')

	//foto.innerHTML="<div onclick='javascript:close_error()' id='err_x' class='err_x'>X</div><ul><li><span class='error_msg'>"+phrase+"</span></li></ul>";
	location.href = '#page_top';
}

function onLoad(){

//powiekszanie height overlaya
if($('overlay')){
	var height = screen.height;
	if(height < getElementHeight('wrapper')){height = getElementHeight('wrapper');}else{height = height -50;}
	$('overlay').style.height =   height +"px";
}
//****************8

if($('Id').value == "home"){loadAjaxFastForm();}




	if($('Id').value == "search" || $('Id').value == "wlasnieon"){
		dm=new ComboBox("dm");
		$('dmtxt').value =$('miasto_last').value;
		//getCountries();
		$('combo').appendChild($('comboDiv'));	
	  $('dmtxt').onkeyup = function(){activateMiasta();};
	  $('dmtxt').setAttribute("autocomplete", "off");
	}

	if($('informer'))$('informer').stop();
	//if ($('Id').value == "home"){Welcome();}
	var wrapper = document.getElementById('grid'); 
	if($('user_id')){
		var user_id = "user_id";
		var ourInterval = setInterval("cyclic($('user_id').value)", 3000);
	}
}
function my_error (phrase){

	
	var height = screen.height;
			
	$('overlay').style.display="block";

	if(height < getElementHeight('wrapper')){height = getElementHeight('wrapper');}else{height = height -50;}
	$('overlay').style.height =   height +"px";
	$('overlay').onclick = function(){
				
					closeOverlay();

			};
	//overlay.setAttribute("z-index", "90");
	var error = $('overlay').appendChild(document.createElement("div"));
	error.id = "errors";


	error.innerHTML="<div id='err_x' class='err_x'><img onclick='javascript:close_error();' src='img/x.jpg'/></div><ul><li><span class='error_msg'>"+phrase+"</span></li></ul>";
	location.href = '#page_top';
			
}

function close_error(){
				
				closeOverlay();

			}

function setPasek(){

var width = $('loadedfoto').width;
$('pasek').style.width = width + 10 + "px";


}

