var ie=navigator.userAgent;
var k=navigator.userAgent.indexOf('MSIE');
var ver=parseInt(ie.substring(k+5, ie.indexOf('.',k) ));

if(ver>=4 || isNaN(ver)) {
but1=new Image();	but1.src='/i/logo_kotord.gif'
but2=new Image();	but2.src='/i/logo_kotor2d.gif'
but3=new Image();	but3.src='/i/logo_kotor3d.gif'
temp=new Image();
}

function mover(nn)
{
if(ver>=4 || isNaN(ver)) {
eval("temp.src=document."+nn+".src")
eval("document."+nn+".src="+nn+".src")
}
}

function mout(nn)
{
if(ver>=4 || isNaN(ver)) {
eval("document."+nn+".src=temp.src")	}
}

function setHome(o) { 
o.style.behavior='url(#default#homepage)'; 
o.setHomePage('http://www.swkotor.ru/');
}

function winopen(name,w,h) {
if(k>0) { h>document.body.clientHeight ? h2=document.body.clientHeight : h2=h; }
else { h>document.body.clientHeight-60 ? h2=document.body.clientHeight-60 : h2=h-30; }
w>screen.width-18 ? w2=screen.width-80 : w2=w+18;
eval("window.open('/winopen.shtml?"+name+"','','status=no, location=yes, toolbar=no, resizable=1, scrollbars=1, top=30, width="+w2+", height="+h2+", left="+(screen.width/2-w2/2)+"');");
}

function helpon() {
document.cookie="help=on;expires=Sat, 22 Jun 2005 07:44:26 UTC"
location.reload(); 
}

function helpoff() {
document.cookie="help=off;expires=Sat, 22 Jun 2005 07:44:26 UTC"
location.reload(); 
}

function onoff(div) {
	$(div).slideToggle("normal");
	//div.style.display = (div.style.display == 'none')?'block':'none';
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function CookieSaveComment(fio,mail) {
alert(fio,mail);
document.cookie="CommentFio="+escape(fio);
document.cookie="CommentMail="+mail;
}

// -------- ushki -------- 

function DrawUshki() {
//alert(UshkiArray[1][1]);
var PicSize = 115;
var space = 5;
var width = (window.innerWidth||window.document.body.clientWidth) - 318;
//var width = 770;
var count = parseInt(width/(PicSize+space));
var spacer = parseInt(100/(count-1));
var UshkiArrayUse = new Array;

var html = '<center><table border=0 cellpadding=0 cellspacing=0 width=100%><tr>';
for (var i=0;i<count;i++) {
	if (i) html += '<td width='+spacer+'%><img src=/i/1dot_empty.gif width=1 height=1></td>';
	var k = Math.round(Math.random()*(UshkiArray.length-1));
	u = k;
	//UshkiArrayUse[i] = k;
	html += '<td width='+PicSize+' align=center><a href='+UshkiArray[u][0]+'><img src='+UshkiArray[u][1]+' width='+PicSize+' height=60 border=0 alt='+UshkiArray[u][2]+'></a></td>';
}
html += '</tr></table><small class=button style="font-family:Tahoma; position:relative; top:-1;"><a href=/reklama.html>реклама на сайте</a></small></center>';
return html;
}

function ResizeDrawUshki() {
var html = DrawUshki();
if (document.all) {
	document.all('ushki').innerHTML = html;
} else {
	document.layers['ushki'].document.write (html);
}
}

/* jQuery */

jQuery(function($){
	$("#tabs").tabs();
	$("#zip").mask("999999");
	$("#regButMenuText").hide();
	$("#recentTheme").hide();
	//$("#forumR2").hide();
	//$("#forumR3").hide();
	$("#tabs-2-hide").hide();
	$("#tabs-3-hide").hide();
	
	//$(".news img[align=left]").css("width",150);
	//$(".news img[align=left]").css("height","auto");
	
	$("#content img[align=left]").css("margin","0px 20px 20px 0px");
	$("#content img[align=right]").css("margin","0px 0px 20px 20px");
	$("#content img[hspace]").attr("hspace","0");
	
	$("#content div.news img").each(function (i) {
		if(document.location.pathname=="/" || document.location.pathname=="/index.html" 
		|| document.location.href.search(/news\/?action\=archive/i)<0
		) {
			//$(this).css("width","120");
			$("#content div.news img[align=left]").css("width","120");
		}
		else {
			$("#content div.news img[align=left]").css("width","30%");
		}
		
		if ($(this).attr("width") < 600) { $(this).css("width","auto"); } 
		else { 
			var src=$(this).attr("src");
			$(this).attr("title","Увеличить");
			$(this).wrap("<a class=highslide style='border:2px #eeeeee !important;' onclick='return hs.expand(this)' href='"+src+"'></a>");
			if(jQuery.browser.msie) { $(this).css("width",$(document).width()*0.6); }
			else { $(this).css("width","100%"); }
			$(this).css("max-width","800px");
			$(this).css("height","auto");
		}
	});
	if(document.location.href.search(/dvd/i)>0) {
		$("span[id]").css("margin","10px 0px 0px 30px");
		$("span[id]").css("padding","10px");
		$("span[id]").css("font-size","0.85em");
		$("span[id]").css("line-height","1.1em");
		$("span[id]").css("border-left","1px solid #5f6c9a");
	}
	/* forumTop */
	if(document.location.search.indexOf("?f=16")!=-1) { $("table#forumTop").css("background","url('/i/title_bg14.jpg') #325D8A"); $("body").css("background","#F7DB7D"); }
	if(document.location.search.indexOf("?f=17")!=-1) { $("table#forumTop").css("background","url('/i/title_bg13.jpg') #325D8A"); $("body").css("background","#bbbbbb"); }
	if(document.location.search.indexOf("?f=2")!=-1) { $("table#forumTop").css("background","url('/i/title_bg20.jpg') #325D8A"); $("body").css("background","#F1DFC5"); }
	if(document.location.search.indexOf("?f=24")!=-1) { $("table#forumTop").css("background","url('/i/title_bg27.jpg') #325D8A"); $("body").css("background","#f0f0f0"); }
	if(document.location.search.indexOf("?f=8382")!=-1) { $("table#forumTop").css("background","url('/i/title_bg22.jpg') #325D8A"); }
	if(document.location.search.indexOf("?f=8887")!=-1) { $("table#forumTop").css("background","url('/i/title_bg23.jpg') #325D8A"); }
	
});

$(document).ready(function(){
$("#f").validate();
$("#tabs-2").html($("#tabs-2-hide").html());
$("#tabs-2-hide").html("");
$("#tabs-2").show();
$("#tabs-3").html($("#tabs-3-hide").html());
$("#tabs-3-hide").html("");
$("#tabs-3").show();
$("#tabs-4").show();
	
$("#regButMenu").hover(
	function () {
		$("#regButMenuText").slideToggle("normal");
      	}, 
      	function () {
        	$("#regButMenuText").slideToggle("slow");
	}        
);
	
$("#recentHref").click(function() { // раскрытие тем форума
	$("#recentTheme").slideToggle("slow");
	return false;
});

$("#forumRecentList div a").click(function() { // раскрытие посл. сообщений
	$s=$(this).attr("rel");
	$("#forumR1").hide();
	$("#forumR2").hide();
	$("#forumR3").hide();
	eval("$('#"+$s+"')").slideToggle();
	return false;
});

});