/// COOKIES ///



function setCookie(name, value, expires, path, domain, secure) {

  var curCookie = name + "=" + escape(value) +

      ((expires) ? "; expires=" + expires.toGMTString() : "") +

      ((path) ? "; path=" + path : "") +

      ((domain) ? "; domain=" + domain : "") +

      ((secure) ? "; secure" : "");

  document.cookie = curCookie;

}





/*

  name - name of the desired cookie

  return string containing value of specified cookie or null

  if cookie does not exist

*/



function getCookie(name) {

  var dc = document.cookie;

  var prefix = name + "=";

  var begin = dc.indexOf("; " + prefix);

  if (begin == -1) {

    begin = dc.indexOf(prefix);

    if (begin != 0) return null;

  } else

    begin += 2;

  var end = document.cookie.indexOf(";", begin);

  if (end == -1)

    end = dc.length;

  return unescape(dc.substring(begin + prefix.length, end));

}





/*

   name - name of the cookie

   [path] - path of the cookie (must be same as path used to create cookie)

   [domain] - domain of the cookie (must be same as domain used to

     create cookie)

   path and domain default if assigned null or omitted if no explicit

     argument proceeds

*/



function deleteCookie(name, path, domain) {

  if (getCookie(name)) {

    document.cookie = name + "=" +

    ((path) ? "; path=" + path : "") +

    ((domain) ? "; domain=" + domain : "") +

    "; expires=Thu, 01-Jan-70 00:00:01 GMT";

  }

}



// date - any instance of the Date object

// * hand all instances of the Date object to this function for "repairs"



function fixDate(date) {

  var base = new Date(0);

  var skew = base.getTime();

  if (skew > 0)

    date.setTime(date.getTime() - skew);

}



/// END OF COOKIES ///







/// EVENT HANDLERS ///



function addEvent(elm, evType, fn, useCapture)

      // cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko

      // By Scott Andrew

      {

		if (elm.addEventListener) {

				

          elm.addEventListener(evType, fn, useCapture); 

          return true; 

        } else if (elm.attachEvent) {

          var r = elm.attachEvent('on' + evType, fn); 

          return r; 

        } else {

          elm['on' + evType] = fn;

        }

      }

	

	



/* password functions */



function fokusiraj(e){

	var password = document.getElementById('password');

	//alert(password.type);

	password.value = '';

	password.setAttribute('type','password');

	



}





function bluraj(e){

	var password = document.getElementById('password');

	try{

		if(password.value == ''){

			password.type='text';

			password.value = zacetna_vrednost;

		}

	} catch (err) {} ;

}





function addListeners(e){

	

	var password = document.getElementById('password');

	

	if(password){

		addEvent(password, 'focus', fokusiraj, false);

		addEvent(password, 'blur', bluraj, false);

		zacetna_vrednost = password.value;

	}

	

	total_number_of_payments = document.getElementById('total_number_of_payments');

	if(total_number_of_payments){

		addEvent(total_number_of_payments, 'focus', izracun, false);

	}

	

	var date_of_birth = document.getElementById('date_of_birth');

	if(date_of_birth){

		kontrola_polnoletnosti();

	}

	

	

}

addEvent(window, 'load', addListeners, false);



/// END OF EVENT HANDLERS ///





/// AJAX ///



var xmlhttp=false;



///  TA KOMENTIRANA KODA MORA TU OBVEZNO BIT!!!!



/*@cc_on @*/

/*@if (@_jscript_version >= 5)

// JScript gives us Conditional compilation, we can cope with old IE versions.

// and security blocked creation of the objects.

  try {

  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

  } catch (e) {

   try {

    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

   } catch (E) {

    xmlhttp = false;

   }

  }

@end @*/



if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

	try {

		xmlhttp = new XMLHttpRequest();

	} catch (e) {

		xmlhttp=false;

	}

}

if (!xmlhttp && window.createRequest) {

	try {

		xmlhttp = window.createRequest();

	} catch (e) {

		xmlhttp=false;

	}

}



function loadFragmentInToElement(fragment_url, element_id, baseurl) {

	var element = document.getElementById(element_id);

	element.innerHTML = '<img src="'+baseurl+'imgs/bg/waiting.gif" border="0" alt="">';

	xmlhttp.open("GET", fragment_url, true);

	xmlhttp.onreadystatechange = function() {

		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

			element.innerHTML = xmlhttp.responseText;

		}

	}

	xmlhttp.send(null);

}



/// END OF AJAX ///



//////////////////////////////////////////////////////////////



function onLoadHandler() {

	fixOutlinedLinks();

}



function fixOutlinedLinks () {

	/* Set all hyperlink's outline styles to "none", 'cause we don't want border box around link to appear when following the hyperlink (RashA) */

	var st1, st2, stfix = "outline-style: none; outline: none;";

	var ahrefs = document.getElementsByTagName('A');

	for (var i = 0; i < ahrefs.length; i++)

	{

		st1 = ahrefs[i].getAttribute("style");

		if (typeof st1 == 'string' && st1.length)

			st2 = st1+"; "+stfix;

		else

			st2 = stfix;

		ahrefs[i].setAttribute("style", st2);

	}

	/* End of correcting hyperlink styles */

}






