function ValidateField(el, validationtype, minvalue, maxvalue)
{
minvalue = parseInt(minvalue);
if (isNaN(minvalue)) {
minvalue = 1;
}
maxvalue = parseInt(maxvalue);
if (isNaN(maxvalue)) {
maxvalue = Math.pow(10000,10000);
}

if ((validationtype == 'text') || (validationtype == '')) {
   if ((el.value.length >= minvalue) && (el.value.length <= maxvalue)) {
     return true;
   } else {
     return false;
   }
}
if ((validationtype == 'email')) {
   if ((el.value.length >= minvalue) && (el.value.length <= maxvalue)) {
     if ((el.value.indexOf("@") > 0) && (el.value.indexOf("@") < el.value.length-1)) {
       return true;
     } else {
       return false;
     }
   } else {
     return false;
   }
}
if ((validationtype == 'number')) {
   intval = parseInt(el.value);
   if (isNaN(intval)) {
     return false;
   } else {
     if ((intval >= minvalue) && (intval <= maxvalue)) {
       return true;
     } else {
       return false;
     }
   }
}
if ((validationtype == 'select')) {
   if ((el.value == '')) {
   return false;
   } else {
   return true;
   }
}

}

function GetRequeryVal()
{
var d = new Date();
return d.getTime();
}

function PostFormAjaxProccesReturn(requestname, http_request, waitingtext) {
var elementid = '';

elementid = requestname;
if (http_request.readyState == 4) {
    irequest = GetRunningRequest(requestname);
    RemoveRunningRequest(irequest);
    if (http_request.status == 200) {
        result = http_request.responseText;
        document.getElementById(elementid).innerHTML = result;
		repositionpagelayout('contdiv', 'rightdiv'); repositionsubmeni();
    } else {
        document.getElementById(elementid).innerHTML = '<span style="color: red;">Napaka pri pošiljanju povpraševanja! Povpraševanje pošljite preko elektronske pošte.</div>';
		repositionpagelayout('contdiv', 'rightdiv'); repositionsubmeni();
    }
} else {
   document.getElementById(elementid).innerHTML = waitingtext;
   repositionpagelayout('contdiv', 'rightdiv'); repositionsubmeni();
}
}

function PostFormAjax(ajaxresultdivid, formid, scripturl)
{
actionstringpost = '';

formel = document.getElementById(formid);
tmpformelements = formel.elements;
for (iformel = 0; iformel < tmpformelements.length; iformel++) {
    if ((tmpformelements[iformel].type == 'text') || (tmpformelements[iformel].type == 'textarea') || (tmpformelements[iformel].type == 'hidden')) {
    formelname = tmpformelements[iformel].name;
    formelvalue = tmpformelements[iformel].value;
    }
    if ((tmpformelements[iformel].type == 'select-one')) {
    formelname = tmpformelements[iformel].name;
    formelvalue = tmpformelements[iformel].options[tmpformelements[iformel].selectedIndex].value;
    }
    actionstringpost = actionstringpost + formelname + "=" + encodeURIComponent(formelvalue) + "&";
}
makeRequest(ajaxresultdivid, scripturl, '?action=postform' + '&requeryval=' + GetRequeryVal() + '!POST?' + actionstringpost, PostFormAjaxProccesReturn, 'Pošiljam...', -1);
}

function ClearForm(formid)
{
formel = document.getElementById(formid);
tmpformelements = formel.elements;
for (iformel = 0; iformel < tmpformelements.length; iformel++) {
    if ((tmpformelements[iformel].type == 'text') || (tmpformelements[iformel].type == 'textarea')) {
    tmpformelements[iformel].value = '';
    }
}
}

function ValidateFormFAQ()
{
isvalid = true;
if (document.forms['faqform'].ime.value == '') {
   alert('Vpišite ime!');
   return false;
}
if (document.forms['faqform'].vprasanje.value == '') {
   alert('Vpišite vprašanje!');
   return false;
}
if (!ValidateField(document.forms['faqform'].email, 'email')) {
   alert('Neveljaven email!');
   return false;
}
return isvalid;
}

function ValidateFormZaposlitev()
{
isvalid = true;
if (document.forms['zaposlitevform'].ime.value == '') {
   alert('Vpišite ime!');
   return false;
}
if (document.forms['zaposlitevform'].priimek.value == '') {
   alert('Vpišite priimek!');
   return false;
}
if (document.forms['zaposlitevform'].drzava.value == '') {
   alert('Vpišite državo!');
   return false;
}
if (document.forms['zaposlitevform'].mesto.value == '') {
   alert('Vpišite mesto!');
   return false;
}
if (document.forms['zaposlitevform'].posta.value == '') {
   alert('Vpišite poštno številko!');
   return false;
}
if (document.forms['zaposlitevform'].ulica.value == '') {
   alert('Vpišite ulico!');
   return false;
}
if (document.forms['zaposlitevform'].telefon.value == '') {
   alert('Vpišite telefonsko številko!');
   return false;
}
if (!ValidateField(document.forms['zaposlitevform'].email, 'email')) {
   alert('Neveljaven email!');
   return false;
}
if (document.forms['zaposlitevform'].izobrazba.value == '') {
   alert('Vpišite izobrazbo!');
   return false;
}
if (document.forms['zaposlitevform'].izkusnje.value == '') {
   alert('Vpišite delovne izkušnje!');
   return false;
}
if (!(document.forms['zaposlitevform'].agree.checked)) {
   alert('Pred pošiljanjem se morate strnjati z pogoji!');
   return false;
}
return isvalid;
}

function repositionpagelayout(parentdivid, abschilddivid) {
parentdiv = document.getElementById(parentdivid);
abschilddiv = document.getElementById(abschilddivid);
if ((parentdiv != null) && (abschilddiv != null)) {
parentdiv.style.height = 'auto';
if (parseInt(abschilddiv.offsetHeight) > parseInt(parentdiv.offsetHeight)) {
parentdiv.style.height = parseInt(abschilddiv.offsetHeight) + 'px';
}
abschilddiv.style.visibility = 'visible';
}
}
function repositionsubmeni() {
parentdiv = document.getElementById('contdiv');
parentdiv2 = document.getElementById('mainmeniholder');
abschilddiv = document.getElementById('leftdiv');
if ((parentdiv != null) && (parentdiv2 != null) && (abschilddiv != null)) {
abschilddiv.style.height = 'auto';
if ((parseInt(parentdiv.offsetHeight) + parseInt(parentdiv2.offsetHeight)) < (parseInt(abschilddiv.offsetHeight))) {
parentdiv.style.height = parseInt(parseInt(abschilddiv.offsetHeight) - parseInt(parentdiv2.offsetHeight)) + 'px';
}
abschilddiv.style.height = parseInt(parseInt(parentdiv.offsetHeight) + parseInt(parentdiv2.offsetHeight) + 10) + 'px';
}
}

function openpopup(sender) {
w = screen.width;
h = screen.height;
var leftPos = (w-380)/2
var topPos = (h-250)/2;
popupwin = window.open(sender.href, "kdpopup", "status=0,scrollbars=0,resizable=0,width=380,height=250,left=" + leftPos + ",top=" + topPos);
popupwin.focus();
}
var hidesmkdtimer = null;
var showsmkdtimer = null;
function hidesmkd() {
smkdstophidetimer();
var endleft = 986;
if (document.getElementById('smkd').style.display == 'block') {
document.getElementById('smkdbtn').className = '';
ex1 = new Animator({
	transition: Animator.makeEaseIn(3),
    duration: 1000,
	onComplete: function() {document.getElementById('smkd').style.display = 'none';}
	});
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'left', parseInt(document.getElementById('smkd').style.left), endleft));
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'width', parseInt(document.getElementById('smkd').style.width), 0));
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'height', parseInt(document.getElementById('smkd').style.height), 0));
ex1.play();
}
}
function showsmkd() {
smkdstophidetimer();
document.getElementById('smkd').style.display = 'block';
}
function startopensmkd(fromclick) {
smkdstophidetimer();
var endleft = 986;
var fsc = document.getElementById('smkd').getElementsByTagName('div')[0];
var endwidth = parseInt(fsc.style.width);
var endheight = parseInt(fsc.style.height);
if (isNaN(parseInt(document.getElementById('smkd').style.left))) {
document.getElementById('smkd').style.left = endleft + 'px';
}
if (isNaN(parseInt(document.getElementById('smkd').style.width))) {
document.getElementById('smkd').style.width = '0px';
}
if (isNaN(parseInt(document.getElementById('smkd').style.height))) {
document.getElementById('smkd').style.height = '0px';
}
if (document.getElementById('smkd').style.display != 'block') {
showsmkd();
document.getElementById('smkdbtn').className = 'opened';
ex1 = new Animator({
	transition: Animator.makeEaseOut(3),
    duration: 1000
	});
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'left', parseInt(document.getElementById('smkd').style.left), parseInt(document.getElementById('smkd').style.left)-endwidth));
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'width', parseInt(document.getElementById('smkd').style.width), endwidth));
ex1.addSubject(new NumericalStyleSubject(document.getElementById('smkd'), 'height', parseInt(document.getElementById('smkd').style.height), endheight));
ex1.play();
}
}
function smkdstarthidetimer() {
smkdstophidetimer();
hidesmkdtimer = setTimeout('hidesmkd()',500);
}
function smkdstophidetimer() {
if (hidesmkdtimer != null) {
clearTimeout(hidesmkdtimer);
hidesmkdtimer = null;
}
}