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.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($){
	$("#zip").mask("999999");
	
	//$(".news img[align=left]").css("width",150);
	//$(".news img[align=left]").css("height","auto");
	
	$("#content div.news img[align=left]").css("margin","0px 20px 20px 0px");
	$("#content div.news img[align=right]").css("margin","0px 0px 20px 20px");
	$("#content div.news 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/i)<0) {
			$(this).css("width","120");
		}
		else {
			if ($(this).attr("width") < 600) { $(this).css("width","auto"); } 
			else { 
				var src=$(this).attr("src");
				$(this).attr("title","Увеличить");
				$(this).wrap("<a class=highslide onclick='return hs.expand(this)' href='"+src+"'></a>");
				if(jQuery.browser.msie) { $(this).css("width",$(document).width()*0.6); }
				else { $(this).css("width","100%"); }
				}
		}
	});
	if(document.location.href.search(/cd/i)>0) {
		$("span[id]").css("margin","10px 0px 0px 50px");
		$("span[id]").css("padding","10px");
		$("span[id]").css("font-size","0.85em");
		$("span[id]").css("border-left","1px solid #5f6c9a");
	}
});

$(document).ready(function(){
	$("#f").validate();
});