var defaultFontSize = 76;
var currentFontSize = defaultFontSize;

var _images = new Array();
	_images[0] = new Image();
	_images[0].src = '/templates/kadrovik/images/square.gif';
	_images[1] = new Image();
	_images[1].src = '/templates/kadrovik/images/arrow_red.gif';	
	
function _swapClasses(el,mode,cl1,cl2){
	$extend(el, Element.prototype);
	if (mode){
		el.removeClass(cl1);
		el.addClass(cl2);	
	} else {
		el.removeClass(cl2);	
		el.addClass(cl1);		
	}	
}
function swapLeft(mode,id,bclass){
	var tbl = $('tbl_'+id);
	_swapClasses(tbl,mode,'brd_'+bclass,'brd_d'+bclass);
}
function swapSubLeft(mode,id){
	var img = $('limg_'+id);
	if (mode){
		img.src =_images[1].src; 
	} else {
		img.src =_images[0].src; 
	}	
}
function addToFavorites(){
 	var title = document.title;
	var url = new String(window.location);
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) {
		return true; 
	}	
}

function sendToFriend(){	
	var loc = new String(window.location);	
	var href ="index.php?option=com_mailto&tmpl=component&link="+Base64.encode(loc);
	var wnd = window.open(href,'win2','width=400,height=350,menubar=yes,resizable=yes');
}

function resetFontSize(){
	currentFontSize = defaultFontSize;
	setFontSize(currentFontSize);
}

function changeFontSize(sizeDifference){
 	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);
 	if(currentFontSize > 100){
 		currentFontSize = 100;
 	} else if(currentFontSize < 60){
 		currentFontSize = 60;
 	}

 	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
 	document.body.style.fontSize = fontSize + '%'; 
};


function swapTop(mode,id){
	var tdc = $('top_td_'+id);
	_swapClasses(tdc,mode,'topmenu','topmenu_hover');
	var tdl = $('top_tdl_'+id);
	_swapClasses(tdl,mode,'topmenu_left','topmenu_left_hover');
	var tdr = $('top_tdr_'+id);
	_swapClasses(tdr,mode,'topmenu_right','topmenu_right_hover');	
}
function swb(el, mode){
	$extend(el, Element.prototype);
	if (mode){
		el.removeClass('question_btn');
		el.addClass('question_btn_hover');
	} else {
		el.removeClass('question_btn_hover');
		el.addClass('question_btn');		
	}
}
function swb1(el, mode){
	$extend(el, Element.prototype);
	if (mode){
		el.addClass('red');
	} else {
		el.removeClass('red');
	}
}
function swb2(el, mode){
	$extend(el, Element.prototype);
	if (mode){
		el.removeClass('red');
		el.addClass('blue');
	} else {
		el.removeClass('blue');
		el.addClass('red');
	}
}