﻿function findObj(theObj, theDoc) {
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}


var menus=new Array();
menus[0]=["O nama","0",""];
menus[1]=["Delatnosti","1",""];
menus[2]=["Reference","2",""];
menus[3]=["Ovlašćenja","3",""];
menus[4]=["Propisi","4",""];
menus[5]=["Kontakt","5",""];

function initMenus(x) {
  var t="";
  var m1=findObj("meni_1");
  for (var i=0;i<menus.length;i++) {
    if (i>0) t+=" • ";
    t+='<a href="index.php?ID='+menus[i][1]+'" >'+menus[i][0]+'</a>';
  }
  m1.innerHTML=t;
//  initSubMenus(x);
}
function previnbrow() {
  var a1=findObj("newh1");
  var a2=findObj("newalt");
  var a3=findObj("newpic");
  var a4=findObj("advurl");
  var messageString="<a href=\""+a4.value+"\" title=\""+a2.value+"\"><h1>"+a1.value+"</h1><br><img src=\""+a3.value+"\" alt=\""+a2.value+"\" border=0></a>";
  win = window.open('','Preview','width=800, height=800, toolbar = no, status = no, resizable, scrollbars');
  win.document.write("<html><head><title>Preview</title>\n");
  win.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
  win.document.write("</head><body>\n");
  win.document.write(messageString + "<br><br>\n");
  win.document.write("<a href=\"javascript:window.close()\"> Close Window </a>\n ");
  win.document.write("</body></html>");
  win.document.close();
}
function viewpic(a,b) {
  var messageString="<a href=\""+a4.value+"\" title=\""+a2.value+"\"><h1>"+a1.value+"</h1><br><img src=\""+a3.value+"\" alt=\""+a2.value+"\" border=0></a>";
  win = window.open('','Preview','width=800, height=800, toolbar = no, status = no, resizable, scrollbars');
  win.document.write("<html><head><title>"+b+"</title>\n");
  win.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
  win.document.write("</head><body>\n");
  win.document.write(messageString + "<br><br>\n");
  win.document.write("<a href=\"javascript:window.close()\"> Close Window </a>\n ");
  win.document.write("</body></html>");
  win.document.close();
}
function checkContactForm() {
  var a1=findObj("con_ime");
  var a2=findObj("con_mail");
  var a3=findObj("con_mess");
  if (a1.value.length<1) {
    alert ("Unesite Vase ime!");
    a1.focus();
    return false;
  }
  if (a2.value.length<8) {
    alert ("Unesite validan E-mail!");
    a2.focus();
    return false;
  }
  if (a2.value.indexOf("@")<0) {
    alert ("Unesite validan E-mail!");
    a2.focus();
    return false;
  }
  if (a2.value.indexOf(".")<0) {
    alert ("Unesite validan E-mail!");
    a2.focus();
    return false;
  }
  if (a3.value.length<1) {
    alert ("Unesite tekst poruke!");
    a3.focus();
    return false;
  }
  return true;
}
