function ShowMail(user, domain1, domain2) {
    var email = user+'&#64;'+domain1+'&#46;'+domain2;
    if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
    else name = email;
    document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}

$(document).ready(function(){


$('#top-menu ul.sf-menu').superfish({
        delay: 200,
        animation: {width:'show', height:'show'},
        speed: 'fast',
        autoArrows: false,
        dropShadows: true
    });


if($("#script-main img").length == 0){$(".pager, #script-main").css("height","0px");}



$("#skype, #icq, #mail").mouseover(function(){
    $(".skype_inn, .icq_inn, .mail_inn").hide();
    $(this).next().show();
});

$("#contacts-gray, #top-menu, #header, #mainmenu, h1, .h1").mouseover(function(){
    $(".skype_inn, .icq_inn, .mail_inn").hide();
});

$("#skype, #icq, #mail").click(function(){
    return false;
});

if($("#flag").length > 0){
$(".h1 h1").css({"padding-bottom":"0px", "padding-left":"7px", "border-left":"7px solid #000"});
}

$(".catTovInn").each(function(){
    if($(this).children(".tovar").length == 0){
    $(this).remove();
}
});


$("a.selected").attr("href", "");
$("a.selected").css("cursor", "default");
$("a.selected").css("color", "#8a8a8a");
$("a.selected").css("text-decoration", "none");

$("a.selected").click(function(){
    return false;
});

if(window.location.href.indexOf('?city') != -1){

$.cookie('city', window.location.href.split('=')[1], {expires: 7, path: "/"});

window.location.href = window.location.href.split('?')[0];
}

if(!$.cookie('city')){

    $("#city_change").toggle();

} else if($.cookie('city') != 'moscow' && $.cookie('city') != $("#clickCity").attr('rev')){
//alert($.cookie('city'));
    url = 'http://www.' + $.cookie('city') + '.stf-dvt.ru?city=' + $.cookie('city');
    window.location.href = url;
}

$("#city_change a").click(function(){

    city = $(this).attr('rev');
    href = $(this).attr('href');
    href += '?city=' + city;

$.cookie('city', city, {path: "/"});

    window.location.href = href;

return false;
});

//Постановка кука

$("#clickCity, .cityarr, #city").click(function(){
    $("#city_change").toggle();

//$.cookie('city', 'moscow', {path: "/"});
$.cookie('city', $("#clickCity").attr('rev'), {expires: 7, path: "/"});


    return false;
});


$(".butInn").click(function(){
    $(".player, .playerA").hide(10);
});

$("#cboxOverlay, #cboxClose").click(function(){
     $(".player, .playerA").show(10);
});

$(window).load(function(){

$(".tovar img").each(function(){
wid = $(this).width()*1;
hgt = $(this).height()*1;

if(hgt > wid){

newWid = Math.round(wid / (hgt / 110));
    $(this).css('height', 110);
    $(this).css('width', newWid);
}


});

});



bannerFlag = $("#script-main");
if(bannerFlag.length > 0){
        $('#script-main').cycle({ 
        fx:      'scrollHorz', 
        speed:    1000, 
        timeout:  7000,
        pager: '.pagerInn',
        pause: 1,
        before: onBefore,        
        activePagerClass: 'active', 
        pagerAnchorBuilder: function(idx, slide) { 
            // return selector string for existing anchor 
            return '.pagerInn li:eq(' + idx + ')'; 
        }
});
}

function onBefore(){
//alert($(this).index());
ids = $(this).index();
$(".slideLink").removeClass('activeS');
$(".slideLink:eq(" + ids + ")").addClass('activeS');
}


$(".spec tr:odd").addClass("tr-second");

if($(".activeLink").size() > 6){
$(".scroll").scrollable(
{
horizontal:true,
items:".scrollInn",
size:6,
next:'.rightarrow',
prev:'.leftarrow',
speed:1000

}
);
}
else
{
$(".rightarrow").hide();
$(".leftarrow").hide();
$(".scrollInn li:last-child").css("background", "none");
$(".scrollInn").css("margin-left", "35px");
}




/*форма добавления комментария*/

$(".commentAdd").colorbox({
    iframe:true,
    width:"420px", 
    height:"560px",
returnFocus:false
  });


/*форма регистрации*/

$(".regAdd").colorbox({
    iframe:true,
    width:"420px", 
    height:"1050px",
returnFocus:false
});


/*форма изменения данных*/

$(".changeAdd").colorbox({
    iframe:true,
    width:"420px", 
    height:"1000px",
returnFocus:false
});

/*форма напоминания пароля*/

$(".remAdd").colorbox({
    iframe:true,
    width:"420px", 
    height:"315px",
returnFocus:false
  });

/*форма заявки*/

$(".makeorder, .makeorder2").colorbox({
    iframe:true,
    width:"420px", 
    height:"650px",
returnFocus:false
  });

/*Форма заказа звонка*/

$(".button").colorbox({
    iframe:true,
    width:"420px", 
    height:"650px",
returnFocus:false
  });

$(".glossymenu li:first-child").css("border", "none");

$(".choise").click(function(){
    $(".dateF").hide();
    $(this).next().show();
return false;
});

$(".closeB").click(function(){
    $(".dateF").hide();
return false;
});



if($(".slideLink").size() > 5){
$(".pager").scrollable(
{
horizontal:true,
items:".pagerInn",
size:5,
next:'.next_but',
prev:'.prev_but',
speed:1000,
activeClass:'activeS'
}

);
$(".pagerInn li").css("border-left", "none");
}
else
{
$(".next_but").hide();
$(".prev_but").hide();
}



$(".pagerInn li:first-child").addClass('activeS');


var flagSys = $(".dialog").text();

if (flagSys != ''){
    if ($.browser.msie && $.browser.version == 6) $("select").show();
        $(".dialog").dialog({
            bgiframe: true,
            modal: true,
            draggable: true,
            resizable: false,
            title: 'Сообщение',
            width:450,
            zIndex: 9999,
            dialogClass: 'toLeft',
            buttons: {
            'Закрыть': function() {
            $(this).dialog('close');
            $(this).dialog("destroy");
            if ($.browser.msie && $.browser.version == 6) $("select").show();
        }
    }
});
return false;
}


});
