NS = (navigator.appName=="Netscape")?true:false;
IEE = (navigator.appName=="Microsoft Internet Explorer")?true:false;
OP = (navigator.appName=="Opera")?true:false;
SupeIE = (navigator.appName=="Microsoft Internet Explorer"&&navigator.appVersion.substr(22,1)==6)?true:false;
version = navigator.appVersion.substr(22,1);
NetScapeBrow = (navigator.appName=="Netscape")?true:false;
ExplorerBrow = (navigator.appName=="Microsoft Internet Explorer")?true:false;

function objOverlay(O) {
	var oL = O.length, c = [];
	for(var i=0; i<oL; i++) {
		if(i%2==0) {
			c.push(O[i+1])
			$(O[i]).mouseenter(function(e){
				var $this = $(this), classN = new String(this.className), num = Number(classN.match(/\d{1,}/))-1, C = c, bgc = C[num];
				this.storeBGC = $this.css('background-color');
				$this.css({'background-color': bgc,'cursor': 'pointer'})
			}).mouseleave(function(){
				var $this = $(this);
				$this.css('background-color',this.storeBGC)
			});	
		}
	}
}
dcAjaxResize = function() {
	if(!$('.shadow')) return;
	var resMe = $('.shadow'), readMe = $('#ajaxC0nt3nt'), resH = resMe.height(), readH = readMe.height(), resW = resMe.width(), readW = readMe.width();
	var $this = document.getElementById('ajaxC0nt3nt')
	
	var incH = ($this.befH)?(readH-$this.befH):false;
	var newH = (incH)?(Number(incH)+Number(resH)):false;
	
	if(newH) {
		resMe.height(newH)
		resMe.dcResize().dcResize(false);
		
	}
	
	$this.befH = readH;
}

function resizeFF() {
	var Height = window.innerHeight;
	var Width = window.innerWidth;
	var eHeight =document.documentElement.offsetHeight;
	var eWidth =document.documentElement.offsetWidth;

	/**************************************/
	/***   Resize Main Index						***/
	/**************************************/
	
	var header = document.getElementById('readMeHeader').offsetHeight;
	var navLine = document.getElementById('readMeNavLine').offsetHeight;
	var footer = document.getElementById('readMeFooter').offsetHeight;
	var loc = document.getElementById('resizeMeMainWindow');
	
	
	var mainFrameDeduct = Number(header+navLine+footer);
	var allHei = Number(loc.offsetHeight+mainFrameDeduct)
	var tmpMainFrameIE_Height = eHeight-mainFrameDeduct;
	var tmpMainFrameNS_Height = Height-mainFrameDeduct;
	var mainFrameIE_Height = (tmpMainFrameIE_Height<200)?200:tmpMainFrameIE_Height;
	var mainFrameNS_Height = (tmpMainFrameNS_Height<200)?200:tmpMainFrameNS_Height;
		
	if(NS) {
		loc.style.height = mainFrameNS_Height+"px"; 
	} else if(IEE && version<=6) {
		loc.style.height = mainFrameIE_Height-4+"px"; 
	} else if(IEE && version == 7) {
		loc.style.height = mainFrameIE_Height+"px";
	} else if(IEE && version >= 8) {
		loc.style.height = mainFrameIE_Height-4+"px";
	} else if(OP) {
		loc.style.height = mainFrameNS_Height+"px"; 
	} else {
		loc.style.height = mainFrameNS_Height+"px";
	} 
	
}


function getHtmlContent(path) {
	if (typeof XMLHttpRequest != 'undefined') {
		var httpRequest = new XMLHttpRequest();
		httpRequest.open('GET', path, false);
		httpRequest.send(null);
		return httpRequest.responseText;
	}
		
}

function trace(add,text) {
	if(!document.getElementById("traceTheError")) {
		$("<div class='traceMe' id='traceTheError'></div>").appendTo("body");
		//return trace(add,text);
	}
	var obj = document.getElementById("traceTheError");
	
	if(obj) {
		if(add==1)
		obj.innerHTML += text+"<br>";
		else
		obj.innerHTML = text;
	}
}



function posAddWin() {
	var win = document.getElementById("infoAdd");
	var obj = document.getElementById('infoAddBack');
	
	if(ExplorerBrow) {
		var winW =document.documentElement.offsetWidth;
		var winH =document.documentElement.offsetHeight;
	} else {
		var winW = window.innerWidth;
		var winH = window.innerHeight;
	}
	var wW =win.offsetWidth;
	var wH =win.offsetHeight;
	
	var mL = Number(winW-wW)/2;
	var mT = Number(winH-wH)/2;
	win.style.top = mT+"px";
	win.style.left = mL+"px";
}
function infoAddNav(what) {
	var win = document.getElementById("infoAdd");
	var obj = document.getElementById('infoAddBack');
	var time = 2000;
	if(what) {
		win.style.display="block";
		obj.style.display="block";
		posAddWin();
		$(win).fadeTo(time, 1);
		$(obj).fadeTo(time, .9);
	} else {
		$(win).fadeTo(time, 0, function(){
															win.style.display="none";
													 });
		$(obj).fadeTo(time, 0, function(){
															obj.style.display="none";
													 });
	}
}
function fadeObj(ele, num) {
	try {
		$(ele).fadeTo(2000, num);
	} catch(taNapakaSePojavAndraz) { }
}





function pre_00(d_) {
	if (d_.length==1){ d_="0"+d_};
	return d_
}
function svetlost(col,proc,proc2) {
	proc=200-proc;
	x=proc*1.275;
	
	proc2=100-proc2;
	y=proc2*2.55;
	
	colo_r=parseInt(col.substr(1,2),16)
	colo_g=parseInt(col.substr(3,2),16)
	colo_b=parseInt(col.substr(5,2),16)
	
	if(x>127.5) {
		x=x-127.5
		colo_r=colo_r-x*(colo_r-0)/127.5
		colo_g=colo_g-x*(colo_g-0)/127.5
		colo_b=colo_b-x*(colo_b-0)/127.5
	} else {
		x=127.5-x
		colo_r=colo_r-x*(colo_r-255)/127.5
		colo_g=colo_g-x*(colo_g-255)/127.5
		colo_b=colo_b-x*(colo_b-255)/127.5
	}
	if(proc2) {
		k_r=127.5
		k_g=127.5
		k_b=127.5
		if(colo_r<127.5){k_r=127.5}
		if(colo_g<127.5){k_g=127.5}
		if(colo_b<127.5){k_b=127.5}
		colo_r=colo_r-y*(colo_r-k_r)/255
		colo_g=colo_g-y*(colo_g-k_g)/255
		colo_b=colo_b-y*(colo_b-k_b)/255
	}
	
	colo_r=pre_00((Math.floor(colo_r).toString(16)))
	colo_g=pre_00((Math.floor(colo_g).toString(16)))
	colo_b=pre_00((Math.floor(colo_b).toString(16)))
	
	return "#"+colo_r+colo_g+colo_b
}




function zapriDiv(divID) {
	var obj= document.getElementById(divID);
	obj.style.visibility = "hidden";
}

function odpriDiv(divID) {
	var obj= document.getElementById(divID);
	obj.style.visibility = "visible";
}

function makesure(msg) {
	
	if(msg == null) {
		msg = 'Ali ste prepričani, da želite zbrisati?';
	}
	
	if(confirm(msg)) {
		return true;
	} else {
		return false;
	}
}



function sleep(miliseconds) {
    // http://kevin.vanzonneveld.net
    // +   original by: Christian Doebler
    // %          note: For study purposes. Current implementation could lock up the user's browser. 
    // %          note: Consider using setTimeout() instead.
    // *     example 1: sleep(1);
    // *     returns 1: 0

    var start = new Date().getTime();
    while (new Date().getTime() < start + miliseconds);
    
    return 0;
}




function isValidEmail(str) {

return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}

function isValidWWW(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("//") > 0);
 
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= ".";
var minYear=1800;
var maxYear=2200;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}

// end date validation

