//Ф-ия нужная =)
function $(id) {return document.getElementById(id); }
//Функция получения текущего времени
function GetDate()
{
    myDate = new Date();
    monthes = new Array('Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря');
    days = new Array('Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота');
    clocks = new Array();
    clocks.year = myDate.getYear();
    month = myDate.getMonth();
    clocks.month = monthes[month];
    clocks.day = myDate.getDate();
    clocks.weekday = days[myDate.getDay()];
    clocks.hours = myDate.getHours();
    clocks.minutes = myDate.getMinutes();
    clocks.seconds = myDate.getSeconds();
    return clocks;
}
//Инфа о браузере
function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
//Добавляем страницу в закладки
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}
//ссылка - <a href="javascript:void(0);" onclick="return bookmark(this);">Добавить в избранное</a>
function Timer()
{
    now = GetDate();
    $('clocks').innerHTML = "Сейчас:&#xA0;"+now.hours+"&#xA0;ч. "+now.minutes+"&#xA0;мин.";
}

function Init()
{
    
}

function SC_move(id, l, side)
{

    var offset=$(id).positionedOffset()[0];
	if(side=='Left')
	{
        //alert($(id).positionedOffset()[0]);
        if($(id).positionedOffset()[0] < 549)        
		new Effect.Move($(id), { x: l, y: 0 });
	}
    if(side=='Right')
    {
        //alert($(id).positionedOffset()[0]);
        if($(id).positionedOffset()[0] > -889)
        new Effect.Move($(id), { x: -l, y: 0 });
    }
    return false;
}

//Калькулятор метала
f = "<table>\
<tr>\
    <td colspan='2'>Марка стали</td>\
</tr>\
<tr>\
    <td colspan='2'>\
        <select name='M'>\
            <option value='7.9'>04Х18Н10</option>\
            <option value='7.7'>08Х20Н14С2</option>\
            <option value='8'>10Х17Н13М2Т</option>\
            <option value='7.9'>08Х18Н12Б</option>\
            <option value='7.95'>20Х23Н18</option>\
            <option value='7.9'>08Х18Н10Т</option>\
            <option value='7.95' selected='selected'>12Х18Н10Т</option>\
            <option value='7.9'>08Х18Н10</option>\
            <option value='7.7'>08Х17Т</option>\
            <option value='7.7'>08Х13</option>\
            <option value='7.7'>12Х13</option>\
            <option value='7.7'>12Х17</option>\
            <option value='7.6'>15Х25Т</option>\
            <option value='7.9'>12Х18Н9</option>\
        </select>\
    </td>\
</tr>";

f1 = "<tr>\
        <td>толщина (мм.)</td>\
        <td><input type='text' name='B' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>длина (метров)</td>\
        <td><input type='text' name='L' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>ширина (мм.)</td>\
        <td><input type='text' name='W' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>листов в пачке</td>\
        <td><input type='text' name='C' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><input type='button' value='посчитать' onclick='calc1(calculator.B.value * calculator.L.value * calculator.W.value * calculator.M.value * calculator.C.value);'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><div id='res'/></td>\
    </tr>\
</table>";

f2 = "<tr>\
        <td>диаметр трубы(мм.)</td>\
        <td><input type='text' name='D' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>толщина стенки (мм.)</td>\
        <td><input type='text' name='B' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>длинна (метров)</td>\
        <td><input type='text' name='L' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><input type='button' value='посчитать' onclick='calc1((calculator.D.value - calculator.B.value)*calculator.M.value*calculator.L.value*3.14);'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><div id='res'/></td>\
    </tr>\
</table>";

f3 = "<tr>\
        <td>размер стороны(мм.)</td>\
        <td><input type='text' name='O' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>толщина стенки (мм.)</td>\
        <td><input type='text' name='B' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>длинна (метров)</td>\
        <td><input type='text' name='L' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><input type='button' value='посчитать' onclick='calc1((2*calculator.O.value*calculator.B.value-calculator.B.value*calculator.B.value)*calculator.M.value*calculator.L.value);'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><div id='res'/></td>\
    </tr>\
</table>";

f4 = "<tr>\
        <td>номер</td>\
        <td><input type='text' name='N' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>длинна (метров)</td>\
        <td><input type='text' name='L' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><input type='button' value='посчитать' onclick='calc1(0.87*calculator.N.value*calculator.N.value*calculator.M.value*calculator.L.value);'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><div id='res'/></td>\
    </tr>\
</table>";

f5 = "<tr>\
        <td>диаметр мм.</td>\
        <td><input type='text' name='D' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td>длинна (метров)</td>\
        <td><input type='text' name='L' style='width: 60px'/></td>\
    </tr>\
    <tr>\
        <td colspan='2'><input type='button' value='посчитать' onclick='calc1(calculator.D.value * calculator.D.value * calculator.L.value * 3.14 * 0.25);'/></td>\
    <tr>\
    <tr>\
        <td colspan='2'><div id='res'/></td>\
    </tr>\
</table>";

function calc1(sum)
{
    res = sum/10000;
    a = Math.round(res*100)/100;
    $('res').innerHTML = "<b>"+a+" кг.<b/>";
}

function show_calc(calc)
{
    if(calc == 1)
    {
        $('calc_container').innerHTML=f+f1;
    }
    else if(calc == 2)
    {
        $('calc_container').innerHTML=f+f2;
    }
    else if(calc == 3)
    {
        $('calc_container').innerHTML=f+f3;
    }
    else if(calc == 4)
    {
        $('calc_container').innerHTML=f+f4;
    }
    else if(calc == 5)
    {
        $('calc_container').innerHTML=f+f5;
    }
    return true;
}