$(document).ready(function(){

if (location.href == "http://consul.su/spb/"){
$('#phone h2:first-child').text('(812) 640-95-21');
$('#phone h2:last-child').remove();}

    $(".table_bot table tr").hover(
	function(){
	        $(this).addClass("odd")
	},
	function () {
    		 $(this).removeClass("odd");  	 
    });
});

var map=new Array(); // regular array (add an optional integer
    map[8]="8b";       // argument to control array's size)
    map[9]="9b";
    map[10]="10b";
    map[11]="11b";
var activ=0;
$(document).ready(function(){
	 
    
    $(".table_bot table tr").hover(
	function(){
	        $(this).addClass("odd")
	},
	function () {
    		 $(this).removeClass("odd");  	 
    });
    $('#next').live('click', function() {
    	tmp=activ+1;
        if(map[tmp]!==undefined){
        	elem=$("#b"+tmp);
        }else{
        	elem=$("#b8");
        }        
    	show(elem[0]);
    });
    $('#prev').live('click', function() {
        tmp=activ-1;
        if(map[tmp]!==undefined){
        	elem=$("#b"+tmp);
        }else{
        	elem=$("#b11");
        }
    	show(elem[0]);
    });
    //$('.menu').mouseover(function() {
    //    show(this);
    //});
    //$('.menu').mouseout(function() {
    //    hide(this);
    //});
    //alert($("#banerin").css("background-image"));
    if (activ==0){
       // alert($("#banerin").css("background-image"));
       show($("#b8")[0]);
       //show(document.getElementById("#b9"));
    }
    //if(banerin)
    $.each(map, function(key, value) { 
      // alert(key + ': ' + value); 
    });
});




	function isset(obj){return (typeof(obj)!='undefined')&&(obj!=null);};
	function byid(obj){return document.getElementById(obj);}
	function ce(el){return document.createElement(el);}
	function in_array(needle, haystack, strict) {
	    var found = false, key, strict = !!strict;
	    for (key in haystack) {
	        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
	            found = true;
	            break;
	        }
	    }
	    return found;
	}
	function count_of(needle,haystack,strict){
		cnt=0;strict = !!strict;
		for(key in haystack){
	        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {cnt++}
		}
		return cnt;
	}
	String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
	function myajax2(url,dattt,object,p_callback,return_xml,met) {
	   var http_request = false;

	    if (window.XMLHttpRequest) { // Mozilla, Safari, Others..
	        http_request = new XMLHttpRequest();
	        if (http_request.overrideMimeType) {
	            http_request.overrideMimeType('text/xml');
	        }
	    } else if (window.ActiveXObject) { // IE
	        try {
	            http_request = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	            try {
	            http_request = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {}
	        }
	    }

	    if (!http_request) {
	        alert('Giving up :( Cannot create an XMLHTTP instance');
	        return false;
	    }
	    http_request.onreadystatechange = function() {
	       if (http_request.readyState == 4) {
	           if (http_request.status == 200) {
	             if (return_xml) {
	                   p_callback(http_request.responseXML,object);
	               } else {
	                   p_callback(http_request.responseText,object);
	               }
	           } else {
	           		object.requestHandler(http_request.status);
	           }
	       }
	   }
	    http_request.open(met, url, true);
	    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	    http_request.send(dattt);

	}

// JavaScript Document





function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	changeOpac(0, imageid);

	document.getElementById(imageid).src = imagefile;

	for(i = 0; i <= 100; i++) {
		a = setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}





function show(elem){
	$.each(map, function(key, value) { 
           if(value!==undefined){
                      $("#b"+key+" a").css("z-index","1");
           $("#b"+key+" a").css("background","url('/images/"+key+"s.gif') no-repeat");
           } 
    });
    
    num=$(elem).attr('id').replace(/b/g, "");
    activ=parseInt(num,10);
    $(elem).children("a").css("z-index","2");
    $(elem).children("a").css("background","url('/images/"+num+"k.gif') no-repeat ");
    
        pic="/images/"+num+"b.jpg";
        //alert(pic);
        //pic=elem.getElementsByTagName('input').item(0).value;
        blendimage('banerin','banerimg',pic,400);
        $(".text_promo").css("display","none");
        $(elem).find(".text_promo a").css("z-index","5");
        $(elem).find(".text_promo").css("display","block");
        $(elem).find(".text_promo a").css("background","url(/images/text_promo.gif) repeat-x 0 269px");
        return;
        
	/*
	











	blendimage('banerin','banerimg',pic,400);
	elem.className = "show";
	*/
}

function hide(elem){
	return;
	clearInterval(a);

	changeOpac(0, 'banerimg');
	elem.className = "";
}
