// JavaScript Document

function menuit(id, chto){
    if (chto == 1){
        $("#menu"+id).css('background-color','white');
    }else{
        $("#menu"+id).css('background-color','black');
    }
}

function do_gradient() {
//   var h = $('table.main_data').Height();
//   $('table.main').css('height', h);
//   $('#the_border1').css('height', h);
   $('#the_border1').gradient({
    from:      'BEC2CC',
    to:        'F0F0F0',
    direction: 'horizontal'   
   });
   $('#the_border2').gradient({
    from:      'BEC2CC',
    to:        'F0F0F0',
    direction: 'horizontal'   
   });
}

$(document).ready(function() {
    $('#td_rand').onImagesLoad(
						{
							callback: function(ref) {
								var hr = ($(ref).innerHeight() - $('#rand').outerHeight())/2.0;
								$('#rand').css('padding-top', hr+'px');
							}
						});
  
  do_gradient();  
//  $(window).resize(do_gradient);
//  $('table.main_data').resize(do_gradient);
  
  $('#hide_visible').click(function (){
    var div = $('div.left_hidden');
    if (div.css('visibility') == 'visible') {
      div.css({display: 'none', visibility: 'hidden'});
      $(this).html('+ подробней');
    } else {
      div.css({display: 'block', visibility: 'visible'});
      $(this).html('- скрыть');
    }
  });
  
  $('#city_select').change(function() {
    var s = '#' +$("#city_select option:selected").val();
    $('div.city_info').css({display: 'none', visibility: 'hidden'});
    $(s).css({display: 'block', visibility: 'visible'});
  });
  
  var s = '#' + $("#city_select option:first").val();
  $(s).css({display: 'block', visibility: 'visible'});
  
      $('img.prod_prev').mouseenter(function() {
      var rel = '#' + $(this).attr('rel');
      var pos = $(this).position();
      var x = 10;
//      alert('left:'+pos.left+'\ntop:'+pos.top);
      if ($.browser.msie) {
        $(rel).css('positon', 'static');
        x = 10;
      }
      $('div.prod_prev').css({'display': 'none', 'visibility': 'hidden'});
      $(rel).css({'display': 'block', 'visibility': 'visible', 'top': pos.top-x, 'left': pos.left-x});
    });
    $('div.prod_prev').mouseout(function() {
      $(this).css({'display': 'none', 'visibility': 'hidden'});
    });
    
  $('div.headpic').onImagesLoad({
	 callback: function(ref) {
    $('#SlideShow').slideshow({
      width: 998,
      height: 173,
      index:0,        // start from frame number N
      time:5000,      // time out beetwen slides
      title:false,     // show title
      titleshow:false,// always show title
      callback:null,  // callback function - call when slide changed - receive index and label
      panel:false,     // show controls panel
      play:true,     // play slideshow
      loop:true,      // looping
      effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
      filter:true,    // remove <br/>, empty <div>, <p> and other stuff
      nextclick:false,      // bind content click next slide
      playclick:false,      // bind content click play/stop
      playhover:false,      // bind content hover play/stop
      playhoverr:false,     // bind content hover stop/play (reverse of playhover)
      playframe:false,       // show frame "Play Now!"
      loadframe:false,       // show frame with "loading"
      fullscreen:false,     // in full window size
      imgresize:true,      // resize image to slideshow window
      imgzoom:true,         // zoom image to slideshow window (for smaller side)
      imgcenter:true,       // set image to center
      imgajax:true,         // load images from links
      imglink:true,         // go to external link by click
      linkajax:false,       // load html from links
      help: null,
      controls :{         // show/hide controls elements
        'hide':false,    // show controls bar on mouse hover
        'first':false,   // goto first frame
        'prev':false,    // goto previouse frame (if it first go to last)
        'play':true,    // play slideshow
        'next':false,    // goto next frame (if it last go to first)
        'last':false,    // goto last frame
        'help':false,    // show help message
        'counter':false  // show slide counter
      }
    }); 
    $('#MainSlideShow').slideshow({
      width: 998,
      height: 450,
      index:0,        // start from frame number N
      time:5000,      // time out beetwen slides
      title:false,     // show title
      titleshow:false,// always show title
      callback:null,  // callback function - call when slide changed - receive index and label
      panel:false,     // show controls panel
      play:true,     // play slideshow
      loop:true,      // looping
      effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
      filter:true,    // remove <br/>, empty <div>, <p> and other stuff
      nextclick:false,      // bind content click next slide
      playclick:false,      // bind content click play/stop
      playhover:false,      // bind content hover play/stop
      playhoverr:false,     // bind content hover stop/play (reverse of playhover)
      playframe:false,       // show frame "Play Now!"
      loadframe:false,       // show frame with "loading"
      fullscreen:false,     // in full window size
      imgresize:true,      // resize image to slideshow window
      imgzoom:true,         // zoom image to slideshow window (for smaller side)
      imgcenter:true,       // set image to center
      imgajax:true,         // load images from links
      imglink:true,         // go to external link by click
      linkajax:false,       // load html from links
      help: null,
      controls :{         // show/hide controls elements
        'hide':false,    // show controls bar on mouse hover
        'first':false,   // goto first frame
        'prev':false,    // goto previouse frame (if it first go to last)
        'play':true,    // play slideshow
        'next':false,    // goto next frame (if it last go to first)
        'last':false,    // goto last frame
        'help':false,    // show help message
        'counter':false  // show slide counter
      }
    }); 
    
    $('img.prod_adv').hover(function() {
      $('#prod_image').attr('src', $(this).attr('src'));
     }, function() {
      $('#prod_image').attr('src', $('#prod_image').attr('rel'));
    });
    
   }
  });      
  
  $('a.gal').imageZoom();
  
});

	function fnSubmit(act) {
		if (CheckInput()){
			document.frmfeedback.action = '';
			document.frmfeedback.send.value = 1;
			document.frmfeedback.submit();
		}
	}
	function CheckInput() {
		if (document.frmfeedback.email.value=="" && document.frmfeedback.phone.value==""){
			alert('Вы не указали контакты для связи с Вами.');
			return 0;
		}	
		if (document.frmfeedback.text.value==""){
			alert('Вы не написали сообщения');
			return 0;
		}	
		return -1;
	}
// */
