var agent = navigator.userAgent.toLowerCase();
var major = parseInt(navigator.appVersion);
var minor = parseFloat(navigator.appVersion);

var isNN = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
var isNN4 = (isNN && (major == 4));
var isNN6 = (isNN && (major >= 5));

var isOPERA = agent.indexOf("opera")>-1 && window.opera;
var isIE4 = (agent.indexOf("msie") != -1 && !isOPERA);

var flash_version = 0; // Версия флеш-проигрывателя
var fz=0;
if (isIE4){
	ie = 1;
	for (var i=3; i<7; i++){
		try {
			if (eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+i+"')")) flash_version = i;
		}
		catch (e) {}
	}
}
if ((isOPERA || isNN || isNN4 || isNN6) && (navigator.plugins)){
	for (var i=0; i<navigator.plugins.length; i++){
		if (navigator.plugins[i].name.indexOf("Flash")> -1){
			fz = parseInt(navigator.plugins[i].description.charAt(16));
			if (fz > flash_version) flash_version=fz;
		}
	}
}
	
//-------------------------------------------------------------------//
function rusoft() {
  window.open('http://www.rusoft.ru');
}

function ShowHTTP(href, display, target, style, title) {
	if (display == '') display = href;
	if (target == '') target = '_blank';
	document.writeln('<a href="'+href+'" target="'+target+'" title="'+title+'" style="'+style+'">'+display+'</a>');
}

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 openImage(image) {
	if (image) window.open("/popup.php?img="+image, "popupimage", "scrollbars=no, resizable=1, width=100, height=100").focus();
	return false;
}

function openPhoto(id) {
	if (id) window.open("/popupf?id="+id, "popup", "scrollbars=1, resizable=1, width=700, height=450").focus();
}

function imgOpen(imgURL,imgWidth,imgHeight,Title) {
	var imgWndw=window.open('','_blank','width='+imgWidth+',height='+
	imgHeight+',toolbar=no,menubar=no,location=no,status=no,'+
	'resizable=yes,scrollbars=no');
	var imgTitle=(Title)?Title:imgURL+": "+imgWidth+'x'+imgHeight;
	with (imgWndw.document){
		open();
		write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+
		'</he'+'ad><bo'+'dy leftmargin="0" '+
		' topmargin="0" '+
		'rightmargin="0" bottommargin="0" marginwidth="0" '+
		'marginheight="0"><img src="'+imgURL+'" width="'+imgWidth+
		'" height="'+imgHeight+'" border="0" alt="'+imgTitle+
		'"></bo'+'dy></ht'+'ml>');
		close();
	}
	return false
}

function OpenPopup(src) {
	if (arguments[1]) popup_name = arguments[1];
	else popup_name = 'popup';
	if (arguments[2]) popup_width = arguments[2];
	else popup_width = 500;
	if (arguments[3]) popup_height = arguments[3];
	else popup_height = 400;
	window.open(src, popup_name, 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,directories=no,scrollbars=yes,width='+popup_width+',height='+popup_height).focus();
	return false
}

function SetCookie(sName, sValue){
	document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2070 23:59:59 GMT; path=/;";
}

function changeImage(id, img) {
	document.getElementById(id).src = img;
}

function insertFlash(v, fl, gif, lnk, w, h, id){
	if (flash_version >= v) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '" id="flash' +  id + '" align="center"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + fl + '"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="' + fl + '" wmode="transparent" quality="high" width="' + w + '" height="' + h + '"></embed></object>');
	} else if (gif != '') {
		document.write("<a href='"+lnk+"'><img src='"+gif+"' width='" + w + "' height='" + h + "' border=0></a>");
	}
}

var i=0;
function showGallery(count, mode){
	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[i+j];	
		}
	}
	if (i==0) document.getElementById('prev').src = "/images/object_arrow_l_g.gif";	
	else document.getElementById('prev').src = "/images/object_arrow_l.gif";	

	if ((i+all_count)>=count) document.getElementById('next').src = "images/object_arrow_r_g.gif";	
	else document.getElementById('next').src = "images/object_arrow_r.gif";	

	return false;
}


