// funkcija za kontrolu da li ckechbox kliknut pri brisanju newsletter grupe
function checkDeleteNewsletterGroups(container) {
         var chkList = container.getElementsByTagName("input"), i, chkNum = 0;
         for(i = 0; i < chkList.length; ++i) {
               if(chkList[i].type == "checkbox" && chkList[i].checked == true) {
                                     chkNum += 1;
               }
         }
         if(chkNum == 0) {
                   alert("Izaberi newsletter grupu za brisanje!");
                   return;
         }
         container.submit();
}

// funkcija za selekcioniranje / deselekcioniranje checkboxa
function checkAll(objId) {
         var formId = document.getElementById(objId), i, chkList = new Array();
         chkList = formId.getElementsByTagName("input");
         for(i = 0; i < chkList.length; ++i) {
               if(chkList[i].type == "checkbox" && chkList[i].checked == true) {
                                  chkList[i].checked = false;
               } else if(chkList[i].type == "checkbox" && chkList[i].checked == false) {
                                  chkList[i].checked = true;
               }
         }
}

// funckcija za generiranje file uploda kod unosa slika u galeriju
function gen_pic_up(num) {
var i, pic;
pic = "";
for(i = 0; i < num; i++) {
if(i <= 7) pic += "<input type='file' name='upload_file[]'><br><textarea name='comment[]' style='border:1px solid;width:300px;height:100px'></textarea><br><br>";
else { alert("Maksimalan broj slika za upload je 8!"); return false; }
}
document.getElementById("gen_pic").innerHTML = pic;
}

// funckija za kontrolu polja za upload slika u galeriju
function checkUploadFields(obj) {
         var list = obj.getElementsByTagName("input"), i;
         for(i = 0; i < list.length; ++i) {
               if(list[i].type == "file") {

               }
         }
}

// function which show gallery pics in hidden layer
function swimage(src_, width_, height_) {
var src_, x, y;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
document.getElementById("show_pic").style.display = "block";
document.getElementById("show_pic").style.top = (y - height_) / 2 + "px";
document.getElementById("show_pic").style.left = (x - width_) / 2 + "px";
document.getElementById("show_pic").innerHTML = "<img src='../uploads/"+src_+"' border='0' width='"+width_+"' style='border:2px solid orange;cursor:pointer' onclick='parentNode.style.display=\"none\"'>";
}

// function to show / hide selectbox
function showList(objId) {
         if(document.getElementById(objId).style.display == "none") {
             document.getElementById(objId).style.display = "block";
             document.getElementById('subemail').style.display = "block";
         } else {
           document.getElementById(objId).style.display = "none";
           document.getElementById('subemail').style.display = "none";
         }
}

// psotojeca za otvaranje forme za clanstvo
function forma()
{
	var popUpSizeX=290;
	var popUpSizeY=450;
	var popUpLocationX=450;
	var popUpLocationY=120;
	var popUpURL="../form.htm";
	splashWin = window.open("",'Obrazac','fullscreen=0,toolbar=0,location=1,directories=0,status=0,statusbar=0,menubar=0,scrollbars=0,resizable=0');
	splashWin.resizeTo(popUpSizeX,popUpSizeY);
	splashWin.moveTo(popUpLocationX,popUpLocationY);
	splashWin.location=popUpURL;
	splashWin.focus();
}

// funkcija za provjeru emaila
function checkMail(obj, mail) {
         if(mail.match(/^.*?\@(.*?|.*?\..*?)\..*?/)) obj.submit();
         else { 
           alert("E-posta nije u tocnom formatu!");
           return false;
         }
}

// funkcija za provjeru podataka vanjskih korisnika pri prijavljivanju
function chkUsers(obj) {
         var a = 0;
         if(document.getElementById("lozinka1").value != document.getElementById("lozinka2").value) {
						alert("Lozinke se ne podudaraju!");
						return false;
         }
				 
         if(document.getElementById("korime").value.length==0) {
         		a = a+1;
         }
         if(document.getElementById("ime").value.length == 0) {
                                                        a += 1;
         }
         if(document.getElementById("prezime").value.length == 0) {
                                                            a += 1;
         }
         if(document.getElementById("lozinka1").value.length == 0) {
                                                             a += 1;
         }
         if(document.getElementById("lozinka2").value.length == 0) {
                                                             a += 1;
         }
         if(document.getElementById("email").value.length == 0) {
                                                          a += 1;
         }
         if(a > 0) {
              alert("* Oznacena polja su obavezna ");
              return false;
         }
         if(checkMail(obj, document.getElementById("email").value) == false) {
                           return false;
         }
         return true;
}

// funkcija za kontrolu uploada datoteke
function chkRep() {
  var ff = document.getElementById("uploadfile").value;
         if(ff.length > 0) {
           if(ff.substr(-3).toLowerCase() == "doc" || ff.substr(-3).toLowerCase() == "pdf" || ff.substr(-3).toLowerCase() == "txt" || ff.substr(-3).toLowerCase() == "rtf" || ff.substr(-3).toLowerCase() == "zip" || ff.substr(-3).toLowerCase() == "rar") {

           } else {
                 alert("Datoteka nije u tocnom formatu."); return false;
           }
         } else {
           alert("Izaberite datoteku za upload ili za brisanje.");
           return false;
         } 
         return true;
}

// funkcija za jsrs get metodu
function do_get(url, objId) {
var receipt, requester;
receipt = document.getElementById(objId);
requester = null;
if (requester != null && requester.readyState != 0 && requester.readyState != 4) requester.abort();
try {
requester = new XMLHttpRequest();
} catch (error) {
try {
requester = new ActiveXObject("Microsoft.XMLHTTP");
} catch (error) {
requester = null;
return false;
}
}
requester.onreadystatechange = function() {
if (requester.readyState == 4) {
if (requester.status == 200) {

// receipt.innerHTML = requester.responseText;
//alert(url+"-"+objId);
//alert(requester.responseText);
if(objId) receipt.innerHTML = requester.responseText;
//if(receipt.innerHTML.length == 0) return;
/* receipt.style.left = parseInt(posx + 10) + "px";
receipt.style.top = parseInt(posy + 5) + "px";
receipt.style.visibility = "visible"; */
} else if (requester.status != 0) alert("There was an error while retrieving the URL: " + requester.statusText + "\nTry again.");
}
return true;
}
requester.open("GET", url);
requester.send(null);
return true;
}     

// funkcija za sakrivanje tootltipa
function hidetip() {
  document.getElementById("tooltip").innerHTML = "";
  document.getElementById("tooltip").style.visibility = "hidden";
}

function restorepassword() {
    window.open("../restore.php", "restoremail", "width=300,height=30,status=no,toolbars=no,scroll=no");
}


















