function ShowMail(user, domain1, domain2) {
	var email = user+'&#64;'+domain1+'&#46;'+domain2;
	if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
	else name = email;
	document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}

function SendLink(link_name) {
	window.open("/send/?link="+link_name, "SendLink", "scrollbars=0, resizable=1, width=370, height=230").focus();
}


function MM_findObj(n, d) {
  	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById)
		x=d.getElementById(n);
	return x;
}



function openImage(image) {
	/*if (image) window.open("/popup.php?img="+image, "popupimage", "scrollbars=1, resizable=1, width=750, height=500").focus();*/
	return false;
}

function preload() {
	b=preload.arguments;
	preload_images = new Array();
	for(i=0; i<b.length; i++) {
		preload_image = new Image;
		preload_image.src=b[i];
		preload_images[i]=preload_image;
	}
}



function menu_sw(x,name,turn) {
	td2=x.parentElement;
	tr=td2.parentElement;
	td1=tr.children(0);
	img=td1.children(0);
	img.src='/images/smenu/'+name+'_ico'+turn+'.gif';
}

function mout(myId,ext){
		s = document.getElementById('img'+myId).src;
		l = s.length;
		s = s.substr(0,l-5);

		document.getElementById('img'+myId).src = s+'.' + ext;

}
function mout_menu(myId){
	document.getElementById('smenu'+myId).style.backgroundColor = '#489442';
}
function mover_menu(myId){
	document.getElementById('smenu'+myId).style.backgroundColor = '#6DA968';
}
//____________________________________________________________________________

function menu_show(id){
	if (document.getElementById('submenu'+id).style.display == 'block') {
		document.getElementById('submenu'+id).style.display = 'none';
		document.getElementById('arr'+id).src = 'images/arr.gif';
	}
	else {
		document.getElementById('submenu'+id).style.display = 'block';
		document.getElementById('arr'+id).src = 'images/arr_act.gif';
	}


}
pics = new Array();
var objCount = 1;
var tm_id;
function preload(img) {
	pics[objCount] = new Image();
	pics[objCount].src = img;
	objCount++;
}

function OpenVtour(vtour) {
	window.open('/vtour/vtour.php?vtour=' + vtour, 'Vtour', 'toolbar=no,location=no,status=no,menubar=no,resizable=no,directories=no,scrollbars=no,width=520,height=400').focus();
	return false;
}


function msieversion() {
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf("MSIE ");
	if (msie>0)
		return parseInt(ua.substring(msie+5,ua.indexOf(".", msie)));
	else
		return 0;
}

function RollOver(id) {
	if (document.images['ROver'].filters && msieversion()>=5.5) {
		document.images['ROver'].filters.item(0).Apply();
		document.images['ROver'].src = '/images/top_' + id + '.jpg';
		document.images['ROver'].filters.item(0).Play();
	} else 	document.images['ROver'].src = '/images/top_' + id + '.jpg';
}


function rusoft() {
  window.open('http://www.rusoft.ru');
}
// --------------------------------------------------
// ---- Отображение галереи  ------------------------
// --------------------------------------------------
var i=0; // текущий индекс смещения
var selected_num = 0; // выбранное фото
// --- Клик на кнопку Вперед/Назад
function showGallery(count, mode, rotate){
	var all_count = 4;
	i=i+mode;
	if (i>(count-all_count)) i=count-all_count;
	if (i<0) i=0;
	if (i>=0 && (i+(all_count-1))<count) {
		for (j=0; j<all_count; j++) {
			if (document.getElementById('gal_div'+j)) {
				document.getElementById('gal_div'+j).innerHTML = par_small[i+j];
				document.getElementById('gal_div'+j).className = (i+j == selected_num) ? 'active' : '';
			}
		}
	}
	return false;
}
// --- Клик на превью
function SelectImage(num, count){
	if (document.getElementById('object_image') && par_big[num]) {
		document.getElementById('object_image').innerHTML = par_big[num];

		var ul = document.getElementById('gal_ul');
		var _count = ul.childNodes.length;
		for (j=0; j<_count; j++) {
			var node = ul.childNodes[j];
			if (node && node.nodeName=='LI') {
				node.className = '';
			}
		}

		document.getElementById('gal_div'+(num-this.i)).className = 'active';
		selected_num = num;
	}
}


// min width ie6
function minWidth() {
	var winWidth = window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth;

	if (winWidth < 1000) {
		$('div.wrap, div.footer').css('width', '1000px');
	}
	else {
		$('div.wrap, div.footer').css('width', 'auto');
	}
}

// min & max width ie6
function maxMinWidth() {
	var winWidth = window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth;

	if (winWidth < 1000) {
		$('div.wrap, div.footer').css('width', '1000px');
	}

	if (winWidth > 1265) {
		$('div.wrap, div.footer').css('width', '1265px');
	}

	if (winWidth < 1265 && winWidth > 1000) {
		$('div.wrap, div.footer').css('width', 'auto');
	}
}

// file input
function fileInput() {
	var $file = $('div.elemBox.file input[type="file"]');

	$file.change(function () {
		var $inputText = $(this).parent().next().children('input[type="text"]');
		var $fileVal = $(this).val();
		$inputText.attr('value', $fileVal);
	});
}

function albums() {
	$('.albums.norm li').first().addClass('first');
	$('.albums.norm li:nth-child(3n)').next('li').addClass('four');
}

// add hover class
function hover() {
	$('.testBlock').hover(
		function () {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	);
}

// add last class
function lastClass() {
	$('.test li').last().addClass('last');
}

// add first class
function firstClass() {
	$('.test li').first().addClass('first');
}
