function showImage(language_id, gallery_id, image_id){
  newWindow = window.open("images.php?lang=" + language_id + "&g_id=" + gallery_id + "&i_id=" + image_id, "Images",  "SCROLLBARS=YES, RESIZABLE=YES, WIDTH=640, HEIGHT=310");
  newWindow.focus();
}

function mailing_subscribe(email) {
	new ajax ('mailing_list.php', {postBody: 'email='+email, update: $('box_mailing')});
	
}



function infoMail(id) {
  newInfoWindow = window.open("povprasevanje.php?realestate_id=" + id, "Info", "RESIZABLE=YES, WIDTH=500, HEIGHT=570");
  newInfoWindow.focus();
}


function showImage(image_id){
  newWindow = window.open("slike.php?image_id=" + image_id, "Pomoč",  "SCROLLBARS=NO, RESIZABLE=YES, WIDTH=360, HEIGHT=280");
  newWindow.focus();
}


function PreveriVnos() {
	strKvadratura=document.frmIskalnik.kvadratura.value ;
	strCena=document.frmIskalnik.cena.value ;
	if (isNaN(strKvadratura)==true) {alert("Vrednost v polju 'Kvadratura' ni veljavno ątevilo!");}
	else if (isNaN(strCena)==true) {alert("Vrednost v polju 'Cena' ni veljavno ątevilo!");}
	else {document.frmIskalnik.submit(); }
}


/* AJAX */

function GetXmlHttpObject() {
	var xmlHttp;
	
	try	{    
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest(); 
		}
	catch (e) {    
		// Internet Explorer    
		try {      
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
			}
		catch (e) {      
			try {        
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e) {       
				return false;        
			}     
	 	}    
	}
	return xmlHttp;

}

function mailbox_updater() {
	if(xmlHttp.readyState==4) {
		if (xmlHttp.responseText == '0') {
			document.getElementById("box_mailing_info").innerHTML="<strong class=\"errorMsg\">Vneseni e-mail naslov je neveljaven!</strong>";
			document.m_form.email.value="";
		} else if (xmlHttp.responseText == '1') {
			document.getElementById("box_mailing_info").innerHTML="<p>E-mail naslov je bil dodan na mailing listo.</p>";
			document.getElementById("box_mailing_frm").innerHTML="";
		} else if (xmlHttp.responseText == '2') {
			document.getElementById("box_mailing_info").innerHTML="<p>E-mail naslov je bil odstranjen iz mailing liste.</p>";
			document.getElementById("box_mailing_frm").innerHTML="";
		} else {
			// Do nothing
		}
	}
}

function add_member() {
	
	if (document.getElementById("box_mailing_info")) document.getElementById("box_mailing_info").innerHTML="";
	
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	email = document.m_form.email.value;
	
	var url="mailing_list.php";
	url=url+"?email="+email;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=mailbox_updater;
	xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
	
}

function remove_member() {
	
	if (document.getElementById("box_mailing_info")) document.getElementById("box_mailing_info").innerHTML="";
	
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	email = document.m_form.email.value;

	var url="mailing_list.php";
	url=url+"?email="+email;
	url=url+"&task=remove";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=mailbox_updater;
	xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}
