function setCVisible(s)
{
   
   //alert(s);   
   
	document.getElementById('popup').className='crvisible';
	document.getElementById('src_id').src = s;
	
	
}

function Navigate(url) {
	window.location=url;
}

function setCHidden()
{
	javascript:document.getElementById('popup').className='crhidden';
	document.getElementById('src_id').src = "";
}

//1
function setCVisibleRegister()
{
	document.getElementById('pup').className='crvisible';
}
function setCHiddenRegister()
{
	javascript:document.getElementById('pup').className='crhidden';
}

function setCVisibleSearch()
{
	document.getElementById('search').className='crvisible';
}
function setCHiddenSearch()
{
	javascript:document.getElementById('search').className='crhidden';
}

function expand(divName, id) {
	document.getElementById(divName).style.display = 'block';
	document.getElementById(divName).style.font = 'normal 10px Tahoma';
	document.getElementById(divName).style.padding = '3px';
	document.getElementById(divName).id='expanded_'+id;
	document.getElementById('plus_'+id).id='minus_'+id;
	document.getElementById('minus_'+id).style.background='#FFF url(img/but/minus.gif) no-repeat';
	document.getElementById('minus_'+id).style.color='#333';
	document.getElementById('minus_'+id).style.font='bold 10px Tahoma';
	document.getElementById('minus_'+id).style.padding='1px 3px 2px 18px';
	document.getElementById('minus_'+id).style.border='solid 1px #BABABA';
	document.getElementById('minus_'+id).style.cursor='pointer';
}
function collapse(divName, id) {
	document.getElementById(divName).style.display= 'none';
	document.getElementById(divName).id='collapsed_'+id;
	document.getElementById('minus_'+id).id='plus_'+id;
	document.getElementById('plus_'+id).style.background = '#FFF url(img/but/plus.gif) no-repeat';
	document.getElementById('plus_'+id).style.color='#333';
	document.getElementById('plus_'+id).style.font='bold 10px Tahoma';
	document.getElementById('plus_'+id).style.padding='1px 3px 2px 18px';
	document.getElementById('plus_'+id).style.border='solid 1px #BABABA';
	document.getElementById('plus_'+id).style.cursor='pointer';
}
function ec(id){
	if(document.getElementById('expanded_'+id, id)){
		collapse('expanded_'+id, id);
	}
	else{
		if(document.getElementById('collapsed_'+id, id)){
			expand('collapsed_'+id, id);
		}
	}
}
function setQuoteId(quoteId, txtInputId){
	document.getElementById(txtInputId).value = quoteId;
	document.getElementById("quote_text").innerHTML = '<a href="#quick" id="cancel" onClick="document.getElementById(\'' + txtInputId + '\').value=\'\';document.getElementById(\'quote_text\').innerHTML=\'\';" class="bold" title="Cancel quote" style="float: left;"></a>';
	document.getElementById("quote_text").innerHTML += "<span class='red11'>&nbsp;&nbsp;Making quote on post </span> " + "<span class='red11'><b>" + quoteId + "</b></span>";
}

var is_opera = /opera\/9/i.test(navigator.userAgent);
var is_gecko = /gecko/i.test(navigator.userAgent);
var is_ie    = /MSIE/.test(navigator.userAgent);
function getSelectionText(txtField) {
	if(is_gecko || is_opera){
		return txtField.value.substring(txtField.selectionStart, txtField.selectionEnd);
	}
	else if(is_ie){
		if (txtField.caretPos) {
			return txtField.caretPos.text;
		}
	}
	return "";
}
function getSelectionLength(txtField){
	if(is_gecko || is_opera){
		return txtField.selectionEnd - txtField.selectionStart
	}
	else if(is_ie){
		if (txtField.caretPos) {
			return txtField.caretPos.text.length;
		}
	}
	return 0;
}
function openURLPopup(txtField){
	popupWin = window.open("", null, "height=100,width=200,status=no,toolbar=no,menubar=no,location=no");
	popupWin.document.open();
	popupWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n');
	popupWin.document.write('<html><head>\n');
	popupWin.document.write('<title>Ð”Ð¾Ð±Ð°Ð²Ð¸Ñ‚ÑŒ Ñ?Ñ?Ñ‹Ð»ÐºÑƒ</title>\n');
	popupWin.document.write('<link rel="stylesheet" href="dhtml/zahvat.css" type="text/css" />\n');
	popupWin.document.write('<link rel="stylesheet" href="dhtml/page.css" type="text/css" />\n');
	popupWin.document.write('<script language="javascript" type="text/javascript">\nfunction setURLText(txtField){\nurlTextValue = \'[url\';\nif(document.urlPopup.urlLink.value != ""){\nurlTextValue += \'=\' + document.urlPopup.urlLink.value;\n}\nurlTextValue += \']\';\nif(document.urlPopup.urlText.value != ""){\nurlTextValue += document.urlPopup.urlText.value;\n}\nelse{\nurlTextValue += document.urlPopup.urlLink.value;\n}\nwindow.opener.insertAtCursor(txtField, urlTextValue, \'[/url]\', false);\nwindow.close();\n}</script>\n');
	popupWin.document.write('</head><body>\n');
	popupWin.document.write('<form name="urlPopup" action="#">\n');
	popupWin.document.write('<table summary="">\n');
	popupWin.document.write('<tr>\n');
	popupWin.document.write('<td>Ð¡Ñ?Ñ‹Ð»ÐºÐ°:</td>\n');
	popupWin.document.write('<td><input type="text" name="urlLink" value="http://"></td>\n');
	popupWin.document.write('</tr>\n');
	popupWin.document.write('<tr>\n');
	popupWin.document.write('<td>Ð¢ÐµÐºÑ?Ñ‚:</td>\n');
	popupWin.document.write('<td><input type="text" name="urlText" value="' + getSelectionText(txtField) + '"></td>\n');
	popupWin.document.write('</tr>\n');
	popupWin.document.write('<tr><td colspan="2" align="center">\n');
	popupWin.document.write('<input type="submit" class="button" value="ÐŸÐ¾Ñ‚Ð²ÐµÑ€Ð´Ð¸Ñ‚ÑŒ" onClick="javascript:setURLText(window.opener.document.getElementById(\'' + txtField.id + '\'))">\n');
	popupWin.document.write('</td></tr>\n');
	popupWin.document.write('</table>\n');
	popupWin.document.write('</form></body></html>');
	popupWin.document.close();
}
function setURLText(txtField){
	urlTextValue = '[url';
	if(document.urlPopup.urlLink.value != ""){
		urlTextValue += '=' + document.urlPopup.urlLink.value;
	}
	urlTextValue += ']';
	if(document.urlPopup.urlText.value != ""){
		urlTextValue += document.urlPopup.urlText.value;
	}
	else{
		urlTextValue += document.urlPopup.urlLink.value;
	}
	window.opener.insertAtCursor(txtField, urlTextValue, '[/url]', false);
	window.close();
}
function updateCaret(){
	if(is_ie){
		txtField = window.event.srcElement;
		txtField.caretPos = document.selection.createRange().duplicate();
	}
}
function setUpdates(){
	if(is_ie){
		txtArray = document.body.getElementsByTagName("textarea");
		i=0;
		while(txtArray[i]){
			txtArray[i].attachEvent("onclick", updateCaret);
			txtArray[i].attachEvent("onselect", updateCaret);
			txtArray[i].attachEvent("onkeyup", updateCaret);
			i++;
		}

	}
}
function insertAtCursor(txtField, txtValue1, txtValue2, leaveSelection) {
	if(is_gecko || is_opera){
		var startPos = txtField.selectionStart;
		var endPos = txtField.selectionEnd;
		var tmpVar = txtField.value.substring(endPos, txtField.value.length);
		var tmpText = txtField.value.substring(startPos, endPos);
		if(txtField.value.substring(0, startPos).lastIndexOf(txtValue1) <= txtField.value.substring(0, startPos).lastIndexOf(txtValue2)){
			txtField.value = txtField.value.substring(0, startPos) + txtValue1;
			if(leaveSelection == true){
				txtField.value += tmpText;
			}
			endPos = txtField.selectionEnd;
			txtField.value += txtValue2 + tmpVar;
		}
		txtField.selectionStart = endPos;
		txtField.selectionEnd = endPos;
		txtField.focus();
	}
	else if(is_ie){
		if (txtField.caretPos) {
			var caretPos = txtField.caretPos;
			var tmpText = caretPos.text;
			caretPos.text = txtValue1;
			if(leaveSelection == true){
				caretPos.text += tmpText;
			}
			caretPos.text += txtValue2;
			caretPos.move('character', -(txtValue2.length));
			caretPos.select();
		}
		else{
			txtField.value += txtValue1 + txtValue2;
		}
	}
	else{
		txtField.value += txtValue1 + txtValue2;
	}
}

var cratesvisible = true;

function popupWin(url, width, height){
	if(!width){
		width=550;
	}
	if(!height){
		height=450;
	}
	newwindow=window.open(url, null, 'height='+ height +',width='+width+',scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popupEdit(url)
{
	newwindow=window.open(url, null, 'height=330,width=550,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

function ask_and_redir(text,link){
	if(confirm(text)){
		document.location=link;
	}
}

function setCVisibleData()
{
	document.getElementById('ChangeDataDiv').className='crvis';
}
function setCHiddenData()
{
	javascript:document.getElementById('ChangeDataDiv').className='crhid';
}

function setCVisiblePass()
{
	document.getElementById('ChangePassDiv').className='crvis';
}
function setCHiddenPass()
{
	javascript:document.getElementById('ChangePassDiv').className='crhid';
}

function setCVisibleAv()
{
	document.getElementById('ChangeAvDiv').className='crvis';
}
function setCHiddenAv()
{
	javascript:document.getElementById('ChangeAvDiv').className='crhid';
}