function show_hide_fs()
	{
	if(gid('fs_div').style.display=='none')
		{
		gid('fs_div').style.display='';
		}
	else{
		gid('fs_div').style.display='none';
		}
	}
	

function show_hide(id)
 {
 if(gid(id).style.display == 'none')
 	{
		 gid(id).style.display = ''
 	}
 else{
		 gid(id).style.display = 'none'
		 }
	 }

function fake_post(address_target,params)
	{

	var adrt = address_target.split('|');
	var url = adrt[0];
	var target = adrt[1];

	//napravi nova forma 
	var form = document.createElement( "form" );
	form.method = 'POST';
	form.action = url;

	if(target)
		{
		form.target  = target;
		}

	//Zapochi da nabivash vytre inputcheta
	

	var params_array = params.split(',');
	for (i=0;i<params_array.length;i++)
		{
		pma = params_array[i].split('=');
		name = pma[0];
		value = pma[1];

		//JS TRIM :)
		name = name.replace(/^[\s]+/,'');
		value = value.replace(/^[\s]+/,'');

		name = name.replace(/[\s]+$/,'');
		value = value.replace(/[\s]+$/,'');
		
		input_el = document.createElement( "input" );
		input_el.type = 'hidden';
		input_el.name = name;
		input_el.value = value;

		form.appendChild(input_el);
		
		}

	//skrii shibanata forma ot shibani FF
	form.style['display'] = 'none';

	//NAII FORMATA U DOKUMENTO
	document.body.appendChild(form);

	//ARE ZAMINAVAY
	form.submit();
	}


function gid(id)
	{
	return document.getElementById(id);
	}



function ipop(url) {
  window.open(url,'ipop','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



//POST
  function post(hf,url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = eval(hf);
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Accept-Charset", "windows-1251");
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      //http_request.setRequestHeader("Content-Transfer-Encoding","binary");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "keep-alive");
      http_request.send(parameters);
   }




function loading_location(region_id)
	{
	if(!(region_id>0)) return;

	lld = gid('loc_div');
	lld.innerHTML = '..::  LOADING  .......... ::..';

	post('loaded_location',window.location,'action=ajax&ajax_region=1&ajax_region_id='+region_id);

	}







function loaded_location(){

	if (http_request.readyState == 4  && http_request.status == 200 )
			{

				try {	
					//alert(http_request.responseText);
					eval(http_request.responseText);
					lld = gid('loc_div');
					lld.innerHTML = '';

											
					
					for ( key in location_array )
						{
						if(!(key>=0)) continue;
						//location_array[key] ;
						lld.innerHTML +=('<input type="checkbox"  name="search[locar][]" value="'+location_array[key]+'">  '+location_array[key]+'<br>');
						}

											

					}
					catch(e){
						alert('Error loading regions Plese exuse us.');
						return false;
						} 

			}
		else if(http_request.readyState == 4  && http_request.status != 200)
			{
			alert('error with Ajax status!= 200');
			}

}




function loading_location_fs(basic_location_id)
	{
	if(!(basic_location_id>=0)) return;

	regobj = gid('ajax_location');


	regobj.disabled = true;
	regobj.length = 1;

	regobj.options[regobj.options.length] = new Option('Loading ...','') ;
	regobj.value = '';
	post('loaded_location_fs',window.location,'action=ajax&ajax_basic_location=1&basic_location_id='+basic_location_id);

	}


function loaded_location_fs(){

	if (http_request.readyState == 4  && http_request.status == 200 )
			{ 

				try {	
					//alert(http_request.responseText);
					eval(http_request.responseText);
					regobj = gid('ajax_location');


					
					//STRANICI
					regobj.length = 1;
	
					gid('countlocation').innerHTML = location_array.length;

					for ( key in location_array )
						{
						if(!(key>=0)) continue;

						regobj.options[regobj.options.length] = new Option(location_array[key],location_values[key]) ;
				
						}

					regobj.disabled = false;

					}
					catch(e){
						alert('Error loading regions Plese exuse us.');
						return false;
						} 

			}
		else if(http_request.readyState == 4  && http_request.status != 200)
			{
			alert('error with Ajax status!= 200');
			}

}



