function rldContent(t, def) {
	if (t.value == def) {
		t.value = '';
	}
}

function rldContent2(t, def) {
	if (!t.value) {
		t.value = def;
	}	
}



function hideGalPic(n) {
	if (document.getElementById) {
		document.getElementById('picNoScript_' + n).style.display = 'none';
	}
}

function doNext() {
	var bts = document.getElementsByName(NDIV);
	var i;
	
	if(currentPic < (NUM_PICS)) {
		//document.getElementById(NDIV).style.textDecoration='none';
		//document.getElementById(NDIV).style.color='';
		
		for (i = 0; i < bts.length; i ++) {
			bts[i].style.textDecoration='underline';
			bts[i].style.color='';			
		}
		
	} else {
		for (i = 0; i < bts.length; i ++) {
			bts[i].style.textDecoration='line-through';
			bts[i].style.color=DISABLECOLOR;
		}		
		
		//document.getElementById(NDIV).style.color=DISABLECOLOR;
		//document.getElementById(NDIV).style.textDecoration='line-through';
	}
}

function doBack(){
	var bts = document.getElementsByName(BDIV);
	var i;	
	
	if(currentPic > 1) {
		for (i = 0; i < bts.length; i ++) {
			bts[i].style.textDecoration='underline';
			bts[i].style.color='';			
		}		
		//document.getElementById(BDIV).style.textDecoration='none';
		//document.getElementById(BDIV).style.color='';
	} else {
		for (i = 0; i < bts.length; i ++) {
			bts[i].style.textDecoration='line-through';
			bts[i].style.color=DISABLECOLOR;
		}			
		//document.getElementById(BDIV).style.color=DISABLECOLOR;
		//document.getElementById(BDIV).style.textDecoration='line-through';
	}
	//alert(bts[0].style.textDecoration);
}

function showDiv(nDiv) {	
	for(var i = 1; i <= NUM_PICS; i++) {
		
		//~ if (NUM_PICS > 1) {
			//~ document.getElementById(LINKID_PREF + i).style.backgroundPosition= '0 0';
			//~ document.getElementById(LINKID_PREF + i).className = '';
			
			//document.getElementById(LINKID_PREF + i).style.color= currentPicColor;
		//~ }
		
		var buttonid = i;
		var id = PICID_PREF + i;
		var node = document.getElementById(id);
		if(node && i==nDiv) {
			node.style.display='block';
			currentPic = i;
			document.getElementById(LINKID_PREF + i).style.backgroundPosition= '0 -112px';
			//document.getElementById(LINKID_PREF + currentPic).style.color= unselectedColor;
		} else if(node) {
			node.style.display='none';
			document.getElementById(LINKID_PREF + i).style.backgroundPosition= '';
		}
	}
	doBack();
	doNext();
}

function showRelDiv(nDiv) {
	for(var i = 1; i <= NUM_PICS; i++) {
		
		var buttonid = i;
		var id = PICID_PREF + i;
		var node = document.getElementById(id);
		if(node && i==nDiv) {
			node.style.display='block';
			currentPic = i;
		} else if(node) {
			node.style.display='none';
		}
	}
	doBack();
	doNext();		
}

function showDivPrev() {
	if(currentPic > 1) {
		if (!RelGall) {
			showDiv(currentPic - 1);
		} else {
			showRelDiv(currentPic - 1);
		}
	}
}

function showDivNext() {
	if(currentPic < NUM_PICS) {
		//alert(RelGall);
		if (!RelGall) {
			showDiv(currentPic + 1);
		} else {
			showRelDiv(currentPic + 1);
		}				
	}
}

function GallInit() {
	var i;

	for (i = 1; i < 20; i ++) {
		if (document.getElementById(NAV_DIV + i)) {
			document.getElementById(NAV_DIV + i).style.display='block';
		}
	}

	showDiv(1);
}
function RelGallInit() {
	showRelDiv(1);
	document.getElementById(NAV_DIV).style.display='block';
}

var allglobalopts = new Object();

function SwapFields(t) {
	var targel = document.getElementById('subsectorid');
	var targelname = targel.name;
	
	if (!allglobalopts[targelname]) {
		allglobalopts[targelname] = targel.cloneNode(true).options;
		for(i = 0; i < allglobalopts[targelname].length; i++) {
			allglobalopts[targelname][i].selected = targel[i].selected;
		}
	}
	var allopt = allglobalopts[targelname];
	
	targel.options.length = 0;
	targel.selectedIndex = -1;
	for(i = 0; i < allopt.length; i++) {
		if (allopt[i].getAttribute('sectorid') == t.options[t.selectedIndex].value || allopt[i].value == "") {
			neweli = targel.options.length;
			targel.options[neweli] = new Option(allopt[i].text, allopt[i].value, false, allopt[i].selected);
		}
	}
	if(targel.onchange) targel.onchange();
}

var kumulatsize = 0;
function resize(oper) {
	var elem = document.getElementById("ourStoryContent");
	if (oper == '+' && kumulatsize < 5) kumulatsize = kumulatsize + 1;
	if (oper == '-' && kumulatsize > -5) kumulatsize = kumulatsize - 1;
	elem.className = 'fontSize' + kumulatsize;
}

function vbaneri2(section, htmlstart, htmlend) {
	if (!banners[section]) return false;
	if (showban1==1) {
		document.write(htmlstart);
		vbaneriw(section);
		document.write(htmlend);
	}
}

function rldContentBuletin(t) {	
	if (t.value == 'Вашата е-поща') {
		t.value = '';
	}
	t.style.color = '#000';
}

function rldContentBuletin2(t) {
	if (!t.value) {
		t.value = 'Вашата е-поща';
	}	
	t.style.color = '#A4A4A4';
}
function openw(url, title, options) {
	var newwin = window.open(url, title, options);
	newwin.focus();
}

function replyTo(postNum, postAuthor) {
	var curVal = jQuery('#msg').val();
	var repStr;
	if(curVal.length > 0) {
		repStr = curVal + '\nДо коментар [#' + postNum + '] от "' + postAuthor + '":\n\n';
	} else {
		repStr = 'До коментар [#' + postNum + '] от "' + postAuthor + '":\n\n';
	}
	jQuery('#msg').val(repStr).focus();
	jQuery('html,body').animate({scrollTop: jQuery('#addcomment').offset().top},500);
	return false;
}
