function ConfirmURL(url, question)
{
	if (confirm(question))
	{
		document.location = url;
	}
	return false;
}

function ConfirmAction(actionString, question)
{
	if (confirm(question))
	{
		eval(actionString);
	}
	return false;
}


function popUpImage(URL, name) 
{
	
	var page = window.open('', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=1,height=1');
	
	html = "<html><head><title>"+name+"</title>";
	html += '<style type="text/css" media="all"> @import url("../common/adminstyle.css"); </style>';
	html += "</head><body bgcolor=\"#FFFFFF\" style=\"margin:2px\"><center>";
	html += "<script>function resizeWindow(width, height){window.resizeTo(width + 16, height + 90);}</script>";
	html += "<img src=\""+URL+"\" onload=\"resizeWindow(this.width , this.height)\"><br>";
	html += "<a href=\"#\" onclick='window.close()'><b>close</b></a> ";
	html += "</center></body></html>";
	page.document.write(html);
	
	return false;
}

function clearText(tArea)
{
	var el = document.getElementById(tArea);
	el.value = '';
}

function setText(tArea, text)
{
	try {
		tinyMCE.get(tArea).hide();
	} catch(e) {}
	
	
	try {
		var el = document.getElementById('div_smallText');
		if (el.style.display != 'none') 
		{
			
			el = document.getElementById(tArea);
			el.value += text + ' ';
		}
	} catch(e) {}
	
	try {
		
		var el = document.getElementById('div_bigText');
		if (el.style.display != 'none') 
		{
		el = document.getElementById('mTextBig');
		el.value += text + ' ';
		}
		
		
	} catch(e) {}
	
	try {
		tinyMCE.get(tArea).show();
	} catch(e) {}
	

}

function showWindow2(wnd)
{
	var el = document.getElementById(wnd);
	el.style.display = 'block';
	return false;
}


function hideWindow2(wnd)
{
	var el = document.getElementById(wnd);
	el.style.display = 'none';
	return false;
}

function showWindow(wnd, text)
{
	var el = document.getElementById(wnd);
	el.innerHTML=text;
	el.style.display = 'block';
	return false;
}

function hideWindow(wnd)
{
	var el = document.getElementById(wnd);
	el.style.display = 'none';
	el.innerHTML='';
	return false;
}


function textCounter(field,cntfield,maxlimit) 
{
	
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}

	
	try {
		cntfield.innerHTML = maxlimit - field.value.length;
	}
	catch(e) {
		cntfield.value = maxlimit - field.value.length;
	}

	
}


function SetLink(sControlName, text, sClick)
{
	var el = document.getElementById(sControlName);
	el.innerHTML = text;
	el.onclick = eval(sClick);
}


function showhideWindow(wnd, script)
{
	var el = document.getElementById(wnd);
	if (el.style.display != 'none')
	{
		el.style.display = 'none';
	}
	else
	{
		el.style.display = 'block';
	}
	
	if (script != 'undefined')
	{
		eval(script);
	}
	
	return false;
}


function DelPic()
{
	if (confirm('Сигурен ли сте че искате да изтриете тази снимка?'))
	{
		var el = document.getElementById('hdnDelPic');
		el.value = 1;
		SetLink('AddImageLink','Добави снимка','ShowPictureWnd');
	}
}

function DelVideo()
{
	if (confirm('Сигурен ли сте че искате да изтриете това видео?'))
	{
		DeleteVideo();
	}
}

function DelLink()
{
	if (confirm('Сигурен ли сте че искате да изтриете този линк?'))
	{
		DeleteLink();
	}
}


function changeTextArea()
{
	var el = document.getElementById('mText');
	el.style.height = 350;
}


function copyText()
{
	var el = document.getElementById('div_smallText');
	if (el.style.display != 'none') 
	{
		var el1 = document.getElementById('mText');
		var el2 = document.getElementById('mTextBig');
		el1.value = el2.value;
		el2.value = '';
	}

	el = document.getElementById('div_bigText');
	if (el.style.display != 'none') 
	{
		var el1 = document.getElementById('mTextBig');
		var el2 = document.getElementById('mText');
		el1.value = el2.value;
		el2.value = '';
	}
}
