var ie4=document.all
var ns6=document.getElementById&&!document.all

///////////
//Template
///////////
var templateColor;
var defaultColor = '#FAEBD7';
var templateHours = 10;

function sf(defaultTemplate)
{
	
var mydate=new Date();
var hours=mydate.getHours();

if(!defaultTemplate)
{
	hours = templateHours;
	templateHours++;
	if( templateHours > 12 )
	templateHours -= 12;
}
	
if( hours > 12 )
	hours -= 12;

switch ( hours ) {
case 0: templateColor = '#E6E6FA'; //Lavender
  break;
case 1: templateColor = '#F8F8FF'; //GhostWhite
  break;
case 2: templateColor = '#F0FFF0';//HoneyDew
  break;
case 3: templateColor = '#DCDCDC'; //Gainsboro
  break;
case 4: templateColor = '#FFF0F5'; //LavenderBlush
  break;
case 5: templateColor = '#F5F5F5'; //WhiteSmoke
  break;
case 6: templateColor = '#FFFAF0'; //FloralWhite
  break;
case 7: templateColor = '#F5FFFA'; //MintCream
  break;
case 8: templateColor = '#FAF0E6'; //Linen
  break;
case 9: templateColor = '#FAEBD7'; //AntiqueWhite
  break;
case 10: templateColor = '#F0F8FF'; //AliceBlue 
  break;
case 11: templateColor = '#DFE8EF';
  break;
case 12: templateColor = '#F4F5F7'; //#BACBD5
  break;
default: templateColor = '#F4F5F7';
  break;
//SeaShell  #FFF5EE; OldLace  #FDF5E6; Snow  #FFFAFA; Azure  #F0FFFF; LavenderBlush  #FFF0F5; MistyRose  #FFE4E1; levi/desni #F4F5F7;#FAF8F5;
} //end switch
}
///////////
function fInit(defaultTemplate){
sf(!defaultTemplate);
if(navigator.userAgent.indexOf("MSIE") != -1){
document.getElementById('toptable').style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#ffffff', EndColorStr="+templateColor+")";
document.getElementById('topGAFMenu').style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#ffffff', EndColorStr="+templateColor+")";
document.getElementById('menu').style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#ffffff', EndColorStr="+templateColor+")";
document.getElementById('bmenu').style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr="+templateColor+", EndColorStr='#ffffff')";
} else{
//document.getElementById('toptable').style.background = templateColor;
//document.getElementById('topGAFMenu').style.background = templateColor;
document.getElementById('toptable').style.background = "-webkit-gradient(linear, center bottom, center top, from("+templateColor+"), to(#FFF))";
document.getElementById('topGAFMenu').style.background = "-webkit-gradient(linear, left bottom, left top, from("+templateColor+"), to(#fff))";
document.getElementById('toptable').style.background = "-moz-linear-gradient(90deg, "+templateColor+", #FFF)";
document.getElementById('topGAFMenu').style.background = "-moz-linear-gradient(90deg, "+templateColor+", #FFF)";
}
}

function menuTemplateOn(){
	gafOff1(document.getElementById("GAF_Home"));
	
	var menu_elements = getElementsByClassName(document.getElementById("menu"), "td", "crow");
	for (var i=0;i<menu_elements.length;i++) {
		//var cl = menu_elements[i].getAttribute("className");
		fOff(menu_elements[i]);
	}
	
	var topElements = getElementsByClassName(document.getElementById("topGAFMenu"), "*", "mainmenu");
	for (var i=0;i<topElements.length;i++) {
		gafOff(topElements[i]);
	}
	/*
	var topElements = getElementsByClassName(document.getElementById("topGAFMenu"), "td", "main_menu");
	for (var i=0;i<topElements.length;i++) {
		gafOff(topElements[i]);
	}
	*/
	/*
	//II nacin:
	var menu_elements = document.getElementsByTagName("TD");
	for (var i=0;i<menu_elements.length;i++) {
		var cl = menu_elements[i].getAttribute("className");
		if(cl == "crow"){
			fOff(menu_elements[i]);
		}
	}
	
	*/
	/*
	var topElements = document.all["main_menu"]; // samo IE
	for (var i=0;i<topElements.length;i++) {
		//var cl = menu_elements[i].getAttribute("className");
		gafOff(topElements[i]);
	}
	*/
}

function gafOn(obj) {
if(navigator.userAgent.indexOf("MSIE") != -1){
	obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr="+templateColor+", EndColorStr='#FFFFFF')";
} else obj.style.background = "-moz-linear-gradient(-90deg, "+templateColor+", #FFF)";
//obj.style.background = "#fcfcfc";
//EvalSound('sound1');
}
function gafOff(obj) { 
if(navigator.userAgent.indexOf("MSIE") != -1){
	obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#ffffff', EndColorStr="+templateColor+")";
} else obj.style.background = "-moz-linear-gradient(90deg, "+templateColor+", #FFF)";
//obj.style.background = templateColor;
}
function gafOn1(obj) {
if(navigator.userAgent.indexOf("MSIE") != -1){
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#d9d9d9', EndColorStr='#FFFFFF')";
} else obj.style.background = "-moz-linear-gradient(-90deg, #fcfcfc, #FFF)";
//obj.style.background = "#fcfcfc";
}
function gafOff1(obj) { 
if(navigator.userAgent.indexOf("MSIE") != -1){
	obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#ffffff', EndColorStr="+templateColor+")";
} else obj.style.background = "-moz-linear-gradient(90deg, "+templateColor+", #FFF)";
//obj.style.background = templateColor;
}

function showGrad(el) { document.all(el).style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FFFFFF', EndColorStr='#CCCCCC')"; }
function showGray(el) { document.all(el).style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#CCCCCC', EndColorStr='#FFFFFF')"; }

function fOn(obj) { 
if(navigator.userAgent.indexOf("MSIE") != -1){
	obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr="+templateColor+", EndColorStr='#FFFFFF')"; 
	obj.style.background="#ffffff";
	obj.style.borderRight="1px solid #ffffff";
} else {
	obj.style.background = "-webkit-gradient(linear, left top, right bottom, from("+templateColor+"), to(#FFF))";
	obj.style.background = "-moz-linear-gradient(0deg, "+templateColor+", #FFF)";
}
//obj.style.background=templateColor;
//obj.style.textDecoration = "underline";
//EvalSound('sound');
}

function fOff(obj) { 
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#ffffff', EndColorStr="+templateColor+")"; 
obj.style.background="#fff";
obj.style.borderRight="1px solid #c9c9c9";
//obj.style.textDecoration = "none";
}

function menuOn(obj) { 
if(navigator.userAgent.indexOf("MSIE") != -1){
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#d9d9d9', EndColorStr='#ffffff')"; 
obj.style.background="#FFFFFF";
} else obj.style.background = "-moz-linear-gradient(-90deg, #d9d9d9, #FFF)";
}

function menuOff(obj) { 
obj.style.filter = "0";
obj.style.background="#fcfcfc";
}

function menuGrayOn(obj) { 
obj.style.background = "-moz-linear-gradient(-90deg, #CCDDEE, #FFF)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#CCDDEE', EndColorStr='#ffffff')"; 
obj.style.background="#FFFFFF";
}

function menuGrayOff(obj) { 
obj.style.filter = "0";
obj.style.background="#CCDDEE";
}

function menuDarkGrayOn(obj) { 
obj.style.background = "-moz-linear-gradient(-90deg, #8DAED8, #FFF)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#8DAED8', EndColorStr='#ffffff')"; 
obj.style.background="#FFFFFF";
}
function menuDarkGrayOff(obj) { 
obj.style.background = "-moz-linear-gradient(-180deg, #8DAED8, #FFF)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#ffffff', EndColorStr='#8DAED8')"; 
obj.style.background="#FFFFFF";
}

function menuBlueOn(obj) { 
obj.style.background = "-moz-linear-gradient(-90deg, #114499, #FFF)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#114499', EndColorStr='#ffffff')"; 
obj.style.background="#FFFFFF";
//obj.style.color = "#ffffff";
}

function menuBlueOff(obj) { 
obj.style.filter = "0";
obj.style.background="#8DAED8";
//obj.style.color = "#000000";
}

function menuABlueOff(obj) { 
obj.style.filter = "0";
obj.style.background="AliceBlue";
}

function menuFilterOn(obj) {
obj.style.background = "-moz-linear-gradient(-90deg, #d9d9d9, #FFF)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#d9d9d9', EndColorStr='#ffffff')"; 
obj.style.background="#FFFFFF";
//obj.style.fontWeight = "bold";
}

function menuFilterOff(obj) { 
obj.style.background = "-moz-linear-gradient(0deg, #FFF, #d9d9d9)";
obj.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#ffffff', EndColorStr='#d9d9d9')"; 
obj.style.background="#d9d9d9";
//obj.style.fontWeight = "normal";
}

function eOn(obj,color) { document.getElementById(obj).bgcolor=color; }

function fnFilters(oTransCnt, oDIV) {
	oTransCnt = document.getElementById? document.getElementById(oTransCnt) : oTransCnt
	oDIV = document.getElementById? document.getElementById(oDIV) : oDIV

	if(oTransCnt.style.filter)
	{
	oTransCnt.filters[0].enabled = true;
	oTransCnt.filters[0].Apply();
	
	oTransCnt.style.visibility="visible";
    	oDIV.style.visibility="visible";
	
   	oTransCnt.filters[0].Play();
	}
}

function fnFiltersHide(oTransCnt, oDIV) {
	oTransCnt = document.getElementById? document.getElementById(oTransCnt) : oTransCnt
	oDIV = document.getElementById? document.getElementById(oDIV) : oDIV
	
	oDIV.style.visibility="hidden";
	oTransCnt.style.visibility="hidden";
}

function EvalSound(soundobj) {
  var thissound=document.getElementById(soundobj);
  thissound.Play();
}

function initSnd() {
	document.write('<embed src="functions/sounds/click.wav" autostart=false width=0 height=0 id="sound" enablejavascript="true">');
	document.write('<embed src="functions/sounds/click1.wav" autostart=false width=0 height=0 id="sound1" enablejavascript="true">');
}
/*
http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/
/*
Some ways to call it
To get all a elements in the document with a “info-links” class. 
getElementsByClassName(document, "a", "info-links"); 
To get all div elements within the element named “container”, with a “col” class. 
getElementsByClassName(document.getElementById("container"), "div", "col"); 
To get all elements within in the document with a “click-me” class. 
getElementsByClassName(document, "*", "click-me"); 
The first line in the function is to cover-up for a flaw in IE 5 where one can’t use the wildcard selector * to get all elements. The rest is basically about setting up a regular expression with the class name we’re looking for, where we escape hyphens and then match that to the class names of the elements where we’re looking for it.

Please try it out. Our hope is that it will help you develop unobtrusive JavaScripts and that it will make it easier for you to maintain your web sites. Any problems with the function, please let us know.

Go crazy now! 

*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}
