//jquery
  


	/*$(".flash_map").click(function (){
		
		flashMapa=$(this).attr("id")
		setFlashMap(flashMapa)
		
		return false;
 
	});*/
	


function externalLinks() {
	
	//eksterni linkovi
	

	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external"){
		anchor.target = "_blank";
	}
	else if(anchor.getAttribute("href") && anchor.className == "flash_map"){
		
	
		anchor.onclick=function() {
		

		//alert(this.getAttribute("id"));
		setFlashMap(this.getAttribute("id"));
		
		return false;
		
		}
	}setPage()
 }
 
 	//ako postoji skript expand.js
	if(typeof window.collapses == 'function') {
		
		collapses();	
	}
	//ako postoji cookie
	
	if (get_cookie ("velicinafonta")!= null ){
		var vf=get_cookie ("velicinafonta");
        
		
		document.getElementsByTagName("body")[0].style.fontSize=vf+"%";
		activeLink=document.getElementById("velicina"+vf).getElementsByTagName("a")[0];
		activeLink.className="active";
		
	
	}else {
		document.getElementsByTagName("body")[0].style.fontSize="70%";
		set_cookie ("velicinafonta", "70", 2015, 01, 15,"/","www.kbcbanka.rs" );
		activeLink=document.getElementById("velicina"+niz[0]).getElementsByTagName("a")[0];
		activeLink.className="active";
	}
 	
}


//dodavnje linkova na trenutne stranice
function extractPageName(hrefString){

	    return  hrefString; 
}

function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++){
		
		if(extractPageName(arr[i].href) == crtPage){
			
			arr[i].className = "active";
		}
	}
}

function setPage(){	
	
	if(document.location.href){
		hrefString = document.location.href;
	
	}else{
		hrefString = document.location;
	}

	if (document.getElementsByTagName("a")!=0) {
		setActiveMenu(document.getElementsByTagName("a"), extractPageName(hrefString));
	}
}

//kursna lista
flashMovie = document.getElementById("sotester");
if(document.getElementById("kompletna_kursna")){
	
	document.getElementById("kompletna_kursna").onclick=function(){
	flashMovie.openExcangeRates();
	return false;
}
}

//branch Popup

if(document.getElementById("close")){
	
	document.getElementById("close").onclick=function(){
	this.parentNode.className="hide";
	document.getElementById("overlay").className="hide";
	document.getElementsByTagName("html")[0].style.overflow = "scroll";
	
	return false;
}
}


if(document.getElementById("gde_se_nalazimo")){
	
	document.getElementById("gde_se_nalazimo").onclick=function(){
	setFlashMap("pozeska_mc");	
}

}

function setFlashMap(mapName){
		document.getElementById("branch_lokator").className="show";
		document.getElementById("overlay").className="show";
		
		document.getElementsByTagName("html")[0].style.overflow = "hidden";
		
		if(typeof(lang) == "undefined"){
			var so = new SWFObject("/branch_lokator.swf", "sotester", "800", "400", "8", "#ffffff");
		
		}else {
			
			var so = new SWFObject("/en/branch_lokator_en.swf", "sotester", "800", "400", "8", "#ffffff");
		}
		so.addParam("allowScriptAccess", "always");
		so.addParam("FlashVars", "playerMode=embedded&amp;htmlMapName="+mapName+"");
		so.write("branch_flash");
		return false;
	}


if(document.getElementById("where_we_are")){
	
	document.getElementById("where_we_are").onclick=function(){
		
		document.getElementById("branch_lokator").className="show";
		document.getElementById("overlay").className="show";
		
		document.getElementsByTagName("html")[0].style.overflow = "hidden";
		var so = new SWFObject("/en/branch_lokator_en.swf", "sotester", "800", "400", "8", "#ffffff");
		so.addParam("allowScriptAccess", "always");
		so.write("branch_flash");
		return false;
}

}



//velicina fonta

niz=["70","73","80"]; //velicine teksta id u html u formatu id="velicina70"

for (i=0; i<niz.length; i++){
	
	shortcutLink=document.getElementById("velicina"+niz[i]);
	shortcutLink.brLinka=[i]; //kaci promenjivu na element
	
	shortcutLink.onclick=function() {
		
		
		document.getElementsByTagName("body")[0].style.fontSize=niz[this.brLinka]+"%";
		set_cookie ("velicinafonta", (niz[this.brLinka]), 2015, 01, 15,"/","www.kbcbanka.rs");
		linkoviVelicina=this.getElementsByTagName("a")[0]
		
		setActive();
		return false;
	}
}



setActive=function(){
if (linkoviVelicina.className!="active"){
			
			linkoviVelicina.className="active";
			activeLink.className="";
			activeLink=linkoviVelicina;
		}
		
		
}


function set_cookie (name, value, exp_y, exp_m, exp_d, path, domain, secure){

  var cookie_string = name + "=" + escape ( value );

  if (exp_y){
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
  if (path){
        cookie_string += "; path=" + escape ( path );
  }
  if (domain){
        cookie_string += "; domain=" + escape ( domain );
  }
  if (secure){
        cookie_string += "; secure";
  }
  document.cookie = cookie_string;
}

function get_cookie (cookie_name){

  var results = document.cookie.match ('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

  if (results){
    return ( unescape(results[2]));
  }else{
    return null;
  }
}


window.onload = externalLinks;

if(document.getElementById("dinamik")){
var dinamik=document.getElementById("dinamik");
var dinamik_box=document.getElementById("dinamik_box");
dinamik.onclick=function(){
	
	if(dinamik_box.className=="collaps"){
		dinamik_box.className="expand";	
		
	}else{
		dinamik_box.className="collaps";
	}
	return false;
}

var klasik=document.getElementById("klasik");
var klasik_box=document.getElementById("klasik_box");
klasik.onclick=function(){
	
	if(klasik_box.className=="collaps"){
		klasik_box.className="expand";	
	}else{
		klasik_box.className="collaps";
	}
	return false;
}
}

if(document.getElementById("kviz")){
var kviz=document.getElementById("kviz");
var kviz_box=document.getElementById("kviz_box");

kviz.onclick=function(){
	
	if(kviz_box.className=="collaps"){
		kviz_box.className="expand";	
	}else{
		kviz_box.className="collaps";
	}
	return false;
}
}
