function windowHeight() {
	var de = document.documentElement;
	return self.innerHeight || ( de && de.clientHeight ) || document.body.clientHeight;
}

function setFixed(){
	w = $("body").width();
	w2 = $("#wrappermain").width();
	if (w < 1000) w = 1000;
	if (w2>w) w = w2;
	// alert(w);
	$('.i_find').css("width", w - 450);
	t = Math.round(windowHeight() / 2 - $(".tip").height() / 2);
	iePad = 0;
	if (!($.browser.msie && $.browser.version == 6)) {
		$(".tip").css("top", t);
	} else iePad = 20;
	t = Math.round(windowHeight() / 2 - $(".cart").height() / 2);
	if (t < 320) t = 320;
	
	if ((windowHeight() - $(".cart").height()) > 320) 
		t = 320;
	else t = windowHeight() - $(".cart").height() + 0; //менять тут
	if (!($.browser.msie && $.browser.version == 6)) {
		$(".cart").css("top", t);
	}
	$('.cart').css("right", iePad + 10);	// и тут
	
	$(".call_l").css("width", $(".call").width() - 350);
	$(".call").css("height", $(".call_l").height() + 10);
	$(".call_r").css("margin-top", $(".call").height() - 98);
	
	$(".news").css("width", $(".maintext").width() - 10);
}
$(document).ready(function(){
	setFixed();
});
$(document).resize(function(){
	setFixed();
});
window.onresize = setFixed;

var xmlHttp = false;
try {
	xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (othermicrosoft) {
	    try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (failed) {
		    xmlHttp = false;
	    }
	}
}

function loadURL(){
	var url = location.href;
	var pos = url.lastIndexOf('#');
	url = url.substring(pos+1,url.length);
	if (pos!=-1) callServer('server.php','main','type='+url);
	else callServer('server.php','main','type=news');
}

function callServer(serverFileName,outName,inName,num) {
	var input = document.getElementById(inName).value;
	
	document.getElementById(outName).innerHTML = '<div onClick="document.location="http://ru.wikipedia.org";return false" title="Загрузка..." class="divquest"></div><select style="margin-top:70px;"><option>Загрузка...</option></select>';
	var url = serverFileName+"?id="+input+"&num="+num+"&"+Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
		    var response = xmlHttp.responseText;
			document.getElementById(outName).innerHTML = response;
		}
	}
	xmlHttp.send(null);
}
function callServer2(serverFileName,outName,inName,num,nowData) {
	var input = document.getElementById(inName).value;

	document.getElementById(outName).innerHTML = '<select class="reginputche"><option>Загрузка...</option></select>';
	var url = serverFileName+"?id="+input+"&type="+num+"&userData="+nowData+"&"+Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
		    var response = xmlHttp.responseText;
			document.getElementById(outName).innerHTML = response;
		}
	}
	xmlHttp.send(null);
}
function callServer3(serverFileName,outName,inName,num) {
	var input = document.getElementById(inName).value;
	
	document.getElementById(outName).innerHTML = '<select><option>Загрузка...</option></select>';
	var url = serverFileName+"?id="+input+"&num="+num+"&"+Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
		    var response = xmlHttp.responseText;
			document.getElementById(outName).innerHTML = response;
		}
	}
	xmlHttp.send(null);
}
function callServer4(serverFileName,outName) {
	var url = serverFileName+Math.random();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function() {
		if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
		    var response = xmlHttp.responseText;
			document.getElementById(outName).innerHTML = response;
		}
	}
	xmlHttp.send(null);
}
function showSeaGood(idGood,inName) {
	var input = document.getElementById(inName).value;
	var idGood = document.getElementById('sel5').value;
	// document.location='catalog/'+idGood+"/"+input;
	document.location='catalog/'+idGood;
}
