$(document).ready(
  function()
  {    
		// раскрашиваем строки таблиц
		$(".contentTable .pad table.ctd tr:nth-child(odd)").addClass("odd");
		
		//запускаем  функцию смены фоток в витрине
		if(typeof(TOP_VITRINA_UPD)!='undefined') {
			if(top_vitrina_length.left > 1)
				l_intervalId = setInterval('changeTopVitrina("left")', TOP_VITRINA_UPD.LEFT);
			if(top_vitrina_length.right > 1)
				r_intervalId = setInterval('changeTopVitrina("right")', TOP_VITRINA_UPD.RIGHT);
		}
  }
);
function OpenBan() {
     var tmp = document.getElementById("ban_form_cont");
     checkWideScreen();     
     tmp.style.top = (myHeight/2+myTop-200) + "px";
     tmp.style.display = "block";
     return false;
}

function openAskForm() {
     var tmp = document.getElementById("send_form_cont");
     checkWideScreen();     
     tmp.style.top = (myHeight/2+myTop-200) + "px";
     tmp.style.display = "block";
     return false;
}
function checkWideScreen(){
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    myTop = window.pageYOffset;
    myLeft = window.pageXOffset;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    myTop = document.documentElement.scrollTop;
    myLeft = document.documentElement.scrollLeft;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    myTop = document.body.scrollTop;
    myLeft = document.body.scrollLeft;
  }
}
	function CheckForm(){	
	  var error=0;
	  var mf=document.forms['zakaz'];		
	    if (mf.fio.value=='' && error==0) {
	      alert('Заполните, пожалуйста, поле \"ФИО\"');
		  mf.fio.focus();
		  error=1;
	    }
		if ((mf.phone.value=='' && mf.email.value=='') && error==0) {
	      alert('Укажите, пожалуйста, поле \"Телефон\" или \"e-mail\"');
		  mf.phone.focus();
		  error=1;
	    }
		if (mf.about.value=='' && error==0) {
	      alert('Введите, пожалуйста, текст сообщения');
		  mf.about.focus();
		  error=1;
	    }
		if (!mf.code.value.match(/^\d{4}$/) && error==0) {
	    alert('Введите, пожалуйста, четыре цифры кода');
		  mf.code.focus();
		  error=1;
	    }
	    if (error==0) {
	       //mf.submit();
				script = document.createElement("script");
				script.src = "/sendmail.phtml?fio="+mf.fio.value+"&email="+mf.email.value+"&ref="+escape(location.href)+"&code="+mf.code.value+"&phone="+mf.phone.value+"&about="+mf.about.value;			
				document.body.appendChild(script);				 
	    }			
	 }
function closeMe() {
	document.getElementById("ban_form_cont").style.display = "none";
}

var prev = {'left':0, 'right':0};
var next = {'left':1, 'right':1};
function changeTopVitrina(id) {
	
	$($("#vitrina_"+id+" > li")[prev[id]]).fadeOut(800);
	$($("#vitrina_"+id+" > li")[next[id]]).fadeIn(800);

	prev[id]++;

	if(prev[id]==(top_vitrina_length[id]-1))
		next[id]=0;
	else
		next[id] = prev[id]+1;
	
	if(prev[id]==top_vitrina_length[id]) {
		prev[id]=0;
		next[id]=1;
	}
	
	
}
