// Image PopUpWindow
function popUpWinImage(img, winTitle, imgWidth, imgHeight){
	// 
	var imageWindow;
	var popupHtml;
	var leftPosition;
	var topPosition;
	var whlt;
	var w;
	var h;
	// 
	popupHtml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
	popupHtml += '    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	popupHtml += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="hr-HR" lang="hr-HR">\n';
	popupHtml += '\n';
	popupHtml += '<head>\n';
	popupHtml += '<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />\n';
	popupHtml += '<meta http-equiv="Content-language" content="hr-HR" />\n';
	popupHtml += '<title>' + winTitle + '</title>\n';
	popupHtml += '<link rel="stylesheet" href="style.css" type="text/css" />\n';
	popupHtml += '<body>\n';
	//
	if (imgWidth!='')
		popupHtml += '<img src="' + img + '" width="' +  imgWidth + '" height="' + imgHeight + '" title="' + winTitle + '" />\n';
	else
		popupHtml += '<img src="' + img + '" title="' + winTitle + '" />\n';
	//
	popupHtml += '</body>\n';
	popupHtml += '</html>';           
	//
	w = (imgWidth!='') ? imgWidth : 650;
	h = (imgHeight!='') ? imgHeight : 530;
	//
	leftPosition = (screen.width) ? (screen.width - w)/2 : 100;
	topPosition  = (screen.height) ? (screen.height - h)/2 : 100;
	//  
	whlt = ',width=' + w+100 + ',height=' + h+100 + ',top=' + topPosition + ',left=' + leftPosition;
	//
  imageWindow = window.open("", "ImageWindow","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1"+whlt);
  imageWindow.resizeTo(w, h);
  imageWindow.document.open();
  imageWindow.document.write(popupHtml);
  imageWindow.document.close();
  imageWindow.focus();
}

// 
var errfound = false;  
var emailpattern = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;

//
// error
function error(elem, text) {
	if (errfound) return;
	window.alert(text + "\t");
	elem.select();
	elem.focus();
	errfound = true;
}

//
// checkForm
function checkForm(f) {
  errfound = false;
  // ime
  if (f.ime.value == "") {
	  error(f.ime, "Molimo unesite ime!");
  }
  // prezime
  if (f.prezime.value == "") {
	  error(f.prezime, "Molimo unesite prezime!");
  }
  // Telefon
  if (f.phone_no.value == "") {
	  error(f.phone_no, "Molimo unesite broj telefona!");
  }
  broj=f.phone_no.value;
	for (var i=0;i<broj.length;i++){
   	cmp="0123456789";
  	tst=broj.substring(i,i+1);
   	if (cmp.indexOf(tst)<0)
	    error(f.phone_no, "Broj telefona može sadržavati samo znamenke!")
	}
  // E-mail
  if (f.email.value == "") {
	  error(f.email, "Molimo unesite E-mail adresu!");
  }
  if (emailpattern.test(f.email.value) == false) {
    error(f.email, "Molimo unesite pravilnu E-mail adresu!");
  }
  // Body
  if (f.body.value == "") {
	  error(f.body, "Molimo unesite pitanje!");
  }
  return ! errfound;
}