function switchOb(switcher,obj1,obj2,text)
{
	if (switcher.checked)
	{
		document.getElementById(obj2).name=document.getElementById(obj1).name;
		document.getElementById(obj1).name='';
		document.getElementById(obj2).style.display='block';
		document.getElementById(obj1).disabled="true";
	}
	else
	{
		document.getElementById(obj1).name=document.getElementById(obj2).name;
		document.getElementById(obj2).name='';
		document.getElementById(obj2).style.display='none';
		document.getElementById(obj1).disabled="";		
	}
}

function ConfirmDelete(url)
{
	var result = confirm('Вы уверены?\n');
	if (result == true )
	{
		window.location.href = url;
	}
}

function ConfirmCancel(url)
{
	var result = confirm('Вы уверены, что хотите аннулировать заявку?\n');
	if (result == true )
	{
		window.location.href = url;
	}
}


function getPageSizePlanet() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};		
function checkBlock(){
	
	var PS = getPageSizePlanet();
	if (PS[2]>=1300){
		//$(".block_right").css('margin-top','-365px');
		$(".block_right").css('padding-top','28px');
		$(".block_announc").width(1000);
		$(".block_proposition").width(1000);
		$(".block_country").width(1000);
		$("#wrapper").css("width",'1300px');
		$("#footer").css("width",'1300px');
		$(".hot_off:last").show();
	}else{
		var rightBlockWidth = $(".block_right").width();
		var leftBlockWidth = 1000-rightBlockWidth-30;
		//console.log(leftBlockWidth,rightBlockWidth,PS[2])
		$(".block_right").css('padding-top','0');
		$(".block_announc").width(leftBlockWidth);
		$(".block_proposition").width(leftBlockWidth);
		$(".block_country").width(leftBlockWidth);
		$("#wrapper").css("width",'1000px');
		$("#footer").css("width",'1000px');
		$(".hot_off:last").hide();
		//$(".block_right").css('margin-top','0');
	}
	
}
$(function(){
	checkBlock();
	$(".hot_off a").click(function(){
		var $parent = $(this).parent(0).parent(0);
		
		var href = $parent.find('a:first').attr('href');
		var imgSrc = $parent.find('img').attr('src');
		var imgAlt = $parent.find('img').attr('alt');
		var imgTitle = $parent.find('img').attr('title');
		var title = $parent.find('h4').find('a').text();
		var text = $parent.find('p').text();
		
		var $target = $(".block_announc");
		$("a",$target).attr('href',href);
		$("img",$target).attr({
			"src": imgSrc,
			"title": imgTitle,
			"alt": imgAlt
		});
		$("p",$target).text(text);
		$(".block_announc_text h3 a",$target).text(title);
		
		
		return false;
	})
	
})
$(window).resize(function(){
	checkBlock()
})
