function zakazSubmit() {
 var url='http://rayban.ru/count.html';
 var a=$('<iframe></iframe>');
 a.attr('src',url);
 a.load(function(){ document.forms['makeOrder'].submit(); }); //отправляем форму после загрузки фрейма
 a.css({width:'1px',height:'1px'});
 $('body').append(a);
}

function show_menu(sid) {
 var tt=(document.body.clientWidth-document.getElementById("nav").offsetWidth)/2-1;
 if(navigator.appName=="Netscape" || navigator.appName=="Opera") tt=0;

 if(document.getElementById('s'+sid)) {
  document.getElementById('s'+sid).style.display='block';
  document.getElementById('s'+sid).style.left=(document.getElementById(sid).offsetLeft+tt)+'px';
  document.getElementById('s'+sid).style.top=top;
  document.getElementById('s'+sid).style.width=(document.getElementById(sid).offsetWidth-4)+'px';
  document.getElementById('s'+sid).style.visibility='visible';
 } 
}

function hide_menu(sid) {
 if(document.getElementById('s'+sid)) document.getElementById('s'+sid).style.visibility='hidden';
}

function hosm(oid) {
 if(document.getElementById(oid).style.display=="none") {
  document.getElementById(oid).style.display="block";
 }
 else {
  document.getElementById(oid).style.display="none";
 }
}

// Вывод дива посередине экрана
function Trans() {
	var map=this;
	$divShad=jQuery('<div></div>');
  	$divShad.css({ background:'#000000', opacity:'0.7', position:'absolute', top:'0', left:'0', zIndex:'1000', width:'100%' }).hide().click(function(){ map.closeMap(); });
	jQuery('body').append($divShad);
	this.initMap();
} 

Trans.prototype.initMap=function() {
	var map=this;
	$ShadCont=jQuery('<div class=basketwind></div>');
	$ShadCont.css({ position:'absolute',  zIndex:'1001', textAlign:'center', display:'none' }).attr('id','contShad').hide();
	
	//$closeMap=jQuery('<img>');
	//$closeMap.attr('id','closeMenu').attr('width','10').attr('height','10').attr('src','/img/map/close.png').attr('title','close map').attr('alt','close map').css({ position:'absolute', bottom:'0', right:'0', padding:'10px', cursor:'pointer' }).click(function(){ map.closeMap(); })
	//$ShadCont.append($closeMap);
	$('.closeLink').live('click', function() {
		map.closeMap(); 
	});
	


	$('.add2basket').live('click', function() { 
			var var_id = $(this).attr('rel');
			var section = $('.parentName').text();
			var nameof = $(this).attr('alt');
			var successAdd = '<b>Вы добавили в корзину</b><br><b>'+ section +' '+ nameof +'</b> <br clear="all"><img src="/system/resize.php?file=/sysfiles/546_'+ var_id +'.jpg&y=130&format=jpg" alt="" /><br> <input type="button" value="" class="makeOrderBtn" onClick="document.location=\'/basket/\'" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="" class="closeLink">';				
			var size = $(this).parent().find('option:selected').text();
			if (size=='выбрать размер'){
				size = '';
			}
			var data = 'var_id=' + var_id + '&size=' + size;
			$.post('/scripts/adder.php', data, function(msg) {
				cart = msg.split(' ');
				$('.totalCount').text(cart[0]);
				$('.totalPrice').text(cart[1]);
				if (cart[2]==1) {
					successAdd = 'Невозможно добавить товар в коризну.';
				}	
			});
			$mapText="<table align='center' cellpadding='0' cellspacing='5' border='0' width='100%' height='100%'><tr><td valign='middle' align='center' style='color:#000000;'>"+ successAdd +"</td></tr></table>";
			$ShadCont.html($mapText);
			map.showMap(); 			
	});

	jQuery('body').append($ShadCont);
}


Trans.prototype.showMap=function() {
	var so = 'abra';
	$divShad.css({ height:jQuery(document).height() }).show();
	coords=this.getPage();
   	hei=$ShadCont.outerHeight();
	marg=coords[2]+(coords[0]-hei)/2;
    if (hei>=coords[0]) marg=coords[2];
	if ((hei+marg)>=coords[1]) $divShad.css({ height:hei+marg+50+'px' });
   	$ShadCont.css({ left:(jQuery(document).width()-$ShadCont.outerWidth())/2+'px', top:-hei+'px' }).show().animate ({ top:marg+'px' }, { queue: false, duration: 900 });
}

Trans.prototype.closeMap=function() {
	$ShadCont.hide();
	$divShad.hide();
}

Trans.prototype.getPage=function () {
  var coords = [0, 0, 0]; // height of window, document, scroll pos
  // all except IE
  if (window.innerHeight) { coords[0] = window.innerHeight; coords[2] = window.pageYOffset; }
  // IE 6 Strict
  else if (document.documentElement && document.documentElement.clientHeight != 0) { coords[0] = document.documentElement.clientHeight; coords[2] = document.documentElement.scrollTop; }
  else if (document.body) { coords[0] = document.body.clientHeight; coords[2] = document.body.scrollTop; }
  var test1 = document.body.scrollHeight; 
  var test2 = document.body.offsetHeight;
  if (test1 > test2) { coords[1] = document.body.scrollHeight; }
  else { coords[1] = document.body.offsetHeight; }
  if (coords[1] < coords[0]) coords[1] = coords[0];
  return coords;
} 




$(document).ready(function() { 
my_map=new Trans();

$('.f_city').change( function(){
	if ($(this).val()=='other'){
		$('.other-city-tr').show();
	}
	else {
		$('.other-city-tr').hide();
	}

});

$('#scroll-cont').jScrollPane({showArrows:true, scrollbarWidth: 17}); 
$('#text-content').jScrollPane({showArrows:true, scrollbarWidth: 17}); 
$('.color-variants').jScrollPane({showArrows:true, scrollbarWidth: 17}); 
$('#text-content').click(function(){ setTimeout(function(){ $('#text-content').jScrollPane({showArrows:true, scrollbarWidth: 17});},100) });
});	
