var crazy = true;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function showBig(img_path, img_alt)
{
    var str, StrBody;

    if (!img_alt) {
        img_alt = document.title;
    }

	str = 'resizable=no,width=100,height=100,screenX=100,screenY=100,left=100,top=100';

	StrBody = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White"" onresize="self.window.location.reload();">';

	var win_op = window.open('', 'show', str);
	win_op.document.open();
	win_op.document.writeln('<html>');
	win_op.document.writeln('<head>');
	win_op.document.writeln('<title>' + img_alt + '</title>');
	win_op.document.writeln('<script>');
	win_op.document.writeln('function resize_img() {');
	win_op.document.writeln('var width = document.image.width + 15;');
	win_op.document.writeln('var height = document.image.height + 59;');
	win_op.document.writeln('self.resizeTo(width,height);');
	win_op.document.writeln('}');
	win_op.document.writeln('</scr' + 'ipt>');
	win_op.document.writeln('</he' + 'ad>');
	win_op.document.writeln(StrBody);
	win_op.document.writeln('<img name="image" src='+ img_path + ' border=0 alt="'+img_alt+'" onload="resize_img();">');
	win_op.document.writeln('</body>');
	win_op.document.writeln('</html>');
	win_op.document.close();
}



function setOrder(result)
{
    var order;
    items = new Array();

   for (i = 0; i < result.length; ++i) {
        items[i] = result[i]['id'] + '|'
                + result[i]['amount'] + '|'
                + result[i]['price'] + '|'
                + result[i]['name'] + '|'
                + result[i]['image'] + '|'
                + result[i]['imagebig'] + '|'
                + result[i]['tpodarok'];

        if ( result[i]['contID'] != undefined) items[i] += '|' + result[i]['contID'];

    }

    order = items.join('#');
    document.cookie = "order=" + encodeURI(order);

}

function getOrder()
{
    var result = new Array();
    var resultIndex = 0;
    var i = 0;
    cookies = document.cookie.split(';');

    for (i = 0; i < cookies.length; ++i) {
        tmp = cookies[i].split('=');

        regEmpty = /\s+/;
        cookieName  = tmp[0].replace(regEmpty, '');
        cookieValue = tmp[1];
        if ('order' == cookieName && cookieValue) {

            cookieValue = decodeURI(cookieValue);
            items = cookieValue.split('#');

            for (ii = 0; ii < items.length; ++ii) {
                props = items[ii].split('|');
                if (props.length == 7 && props[0] != '') {

                    result[resultIndex] = new Array();
                    result[resultIndex]['id']       = props[0];
                    result[resultIndex]['amount']   = props[1];
                    result[resultIndex]['price']    = props[2];
                    result[resultIndex]['name']     = props[3];
                    result[resultIndex]['image']    = props[4];
                    result[resultIndex]['imagebig'] = props[5];
                    result[resultIndex]['tpodarok'] = props[6];
                    result[resultIndex]['contID'] = '';
                    ++resultIndex;
                }
                    if (props.length == 8 && props[0] != '') {

                    result[resultIndex] = new Array();
                    result[resultIndex]['id']       = props[0];
                    result[resultIndex]['amount']   = props[1];
                    result[resultIndex]['price']    = props[2];
                    result[resultIndex]['name']     = props[3];
                    result[resultIndex]['image']    = props[4];
                    result[resultIndex]['imagebig'] = props[5];
                    result[resultIndex]['tpodarok'] = props[6];
                    result[resultIndex]['contID'] =   props[7];
                    ++resultIndex;
                }
            }
        }
    }

    return result;
}
function clearOrder()
{
    order = getOrder();

    for (i = 0; i < order.length; ++i)
      {
        if (document.getElementById('coltovar' + order[i]['id']))
          document.getElementById('coltovar' + order[i]['id']).innerHTML = "0";
      }

    document.cookie = "order=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
    drawOrder();
}


function removeFromOrder(id)
{
    order = getOrder();
    var j = 0;
    var newOrder = new Array();

    for (i = 0; i < order.length; ++i) {
        if (order[i]['id'] != id) {
            newOrder[j] = order[i];
            ++j;

        }
    }

    setOrder(newOrder);

}

function removeFromOrderCont(id, contID)
{
  var k = 0;
  var i = 0;
  var newOrder = new Array();
  var order = getOrder();
  var child = isSupertovarCK(id, contID);
  if(child)
  {
   for(i=0; i < order.length; i++){
     for( j = 0; j < child.length; j++)
      if((order[i]['id']==child[j]) && (order[i]['contID'] == contID)) order[i]['amount']=0;
     if((order[i]['id']==id) && (order[i]['contID'] == contID)) order[i]['amount']=0;
     if(order[i]['amount'] > 0) newOrder[k++] = order[i];
    }
  }
  setOrder(newOrder);
}


function plustovar1(id)
  {
    var allprice = 0;
    var col_podarki = 0;
    salepodarok_col = 2;
    order = getOrder();
    if (order.length != 0)
      for (i = 0; i < order.length; ++i)
       {
         allprice = allprice + order[i]['amount'] * order[i]['price'];
         nsT = ncH = true;
         if(isSupertovarCK(order[i]['id'],order[i]['contID'])) nsT = false;
         if(isChildCK(order[i]['id'], order[i]['contID'])) ncH = false;
         if(order[i]['price'] == 0 && ncH && nsT) col_podarki = col_podarki + order[i]['amount'];
       }

     if (tovars[id]['price']==0)            // gift
      {
       if(allprice < 1200) {alert("Вы сможете добавить этот ролл, когда сумма заказа в корзине будет более 1200руб."); return 0;};
       if(allprice < 2500 && col_podarki > 0 ) { alert("Мы с удовольствием подарим Вам второй ролл при заказе в корзине более 2500руб."); return 0;};
       if(allprice > 2500 && col_podarki > 1 ) {alert( "Сегодня мы дарим только 2 ролла"); return 0;};
      }
    else {                                  //nongift

    if ((tovars[id]['tpodarok'] == 1) && crazy)
      {
        if ((all_salepodarok_col >= salepodarok_col)||(all_salepodaroki[id] > 1))
          {
            if (all_salepodarok_col >= salepodarok_col)
              alert("Вы можете выбрать не более 2х акционных роллов филадельфия в одном заказе\r\nПодробнее об акции читайте раздел \"Скидки\"");
            else
              {
                if (all_salepodaroki[id] >= 4)
                  alert("Вы можете выбрать не более 2х одинаковых \"крэйзи\" товаров в одном заказе\r\nПодробнее об акции читайте раздел \"Скидки\"");
              }

            return 0;
          }
      }
    }
    var j = 0;
    var newOrder = new Array();


    for (i = 0; i < order.length; ++i) {
        if (order[i]['id'] == id)
          order[i]['amount']++;
        newOrder[i] = order[i];
    }

    setOrder(newOrder);

    drawOrder();
  }

function minustovar1(id)
  {
    order = getOrder();
    var j = 0;
    var newOrder = new Array();
    var all_price = 0;
    var col_podarki = 0;
    var del_podarki = 0;
    var podarki = 2;
    var all_price_new = 0;

    for (i = 0; i < order.length; ++i) {
      all_price = all_price + order[i]['price']*order[i]['amount'];
      all_price_new = all_price_new + order[i]['price']*order[i]['amount'];
     if (order[i]['id'] == id) {
       all_price_new = all_price_new - order[i]['price'];
      }
     nsT = ncH = true;
     if(isSupertovarCK(order[i]['id'],order[i]['contID'])) nsT = false;
     if(isChildCK(order[i]['id'], order[i]['contID'])) ncH = false;
     if ((order[i]['price'] == 0) && ncH && nsT) {
     col_podarki = col_podarki + order[i]['amount']*1;
      }
    }

    if((all_price >1200) && (all_price_new <1200)) del_podarki = 1;
    if((all_price > 2500) && (all_price_new < 2500)) del_podarki = col_podarki - 1;
    if((all_price > 2500) && (all_price_new < 1200)) del_podarki = 2;

    for (i = 0; i < order.length; ++i) {
      if ((del_podarki > 0) && (order[i]['price'] == 0)){
        order[i]['amount']--;
        del_podarki--;
        if ((document.getElementById('coltovar' + order[i]['id']))&&(order[i]['amount'] == 0))
              document.getElementById('coltovar' + order[i]['id']).innerHTML = "0";
       }
      if (order[i]['id'] == id)
          {
            order[i]['amount']--;
            if ((document.getElementById('coltovar' + order[i]['id']))&&(order[i]['amount'] == 0))
              document.getElementById('coltovar' + order[i]['id']).innerHTML = "0";
          }
        if (order[i]['amount'] > 0)
          newOrder[j++] = order[i];
    }



    setOrder(newOrder);

    drawOrder();
  }

function plusvrazd(id, razdid)
{   var ictsel = cnt;
   var selid;
   var first = true;
   txt = "Выберите ";
   document.getElementById('imgrazd'+razdid).innerHTML = '<img src="'+tovars[id]["image"]+'" border=0>';
   document.getElementById('checkrazd'+razdid).innerHTML = '<img src="/upload/image/check.gif" border = 0>';

   document.getElementById('txtrazd'+razdid).innerHTML = tovars[id]['anons'];
   tovars[razdid]['select'] = id;

   for( i = 0; i < cnt; i++){   	selid = razdels[i];
    if(tovars[selid]['select']!='') ictsel--;
     else{     	 if(!first) txt += ', ';
     	 first = false;
     	 txt += tovars[razdels[i]]['name'];
     	 }
   }
   txt += '.';
   if(ictsel ==0) txt = "Добавить в корзину";
   document.getElementById('addrazdel').innerHTML = "<a>" + txt + "</a>";
   if(ictsel ==0) document.getElementById('addrazdel').bgColor="#5f1c01";
   //document.getElementById('cntsel').innerHTML = '<b>' + ictsel + '</b>';
   selleft = ictsel;
}

function addToOrder()
{}

function pluskompl(id)
{   var i,idr,idt;
   var j = 0;
   if( selleft > 0) return;
   tovars[id]['contID'] = '';
      for ( i = 0; i < cnt; i++)
   {
    idr = razdels[i];
    idt = tovars[idr]['select'];
    tovars[id]['contID'] += (tovars[idt]['id']+'8109');
   }
   addToOrder(id, 1);
   for ( i = 0; i < cnt; i++)
   {    idr = razdels[i];
    idt = tovars[idr]['select'];
    tovars[idt]['contID'] = tovars[id]['contID'];
    addToOrder(idt, 1);
   }
   drawOrder();
}

function isSupertovar(id)
{  if(tovars[id]['id']==supertovar) return true;
  if(tovars[id]['id']['podarok_ver'] > 300 ) return true;
  return false;
}

function getSTchild(id)
{  if( !isSupertovar(id)) return false;
  tmp = tovars[id]['contID'];
  child = tmp.split('8109');
  return child;
}


function isChild(id)
{ if(isSupertovar[id]) return false;
 if(!tovars[id]['contID']) return false;
  return true;
}

function isSupertovarCK(id, contID)
{
 if(contID == '') return false;
 var ord = getOrder();
 var i;
 var j;
 if(ord.length ==0) return false;
 for(i=0; i<ord.length; i++)
  if(ord[i]['id']==id)
  {
   tmp = ord[i]['contID'];
   if(tmp == contID)
   {
    child = tmp.split('8109');
    for(j = 0; j< child.length; j++)
     if(child[j] == id) return false;
  }
  }
return child;
}

function isChildCK(id, contID)
{

 var ord = getOrder();
 var i = 0;
 var j = 0;
// alert(id + "cont=" + contID);
 if(ord.length ==0) return false;
 for(i=0; i<ord.length; i++)
  if(ord[i]['id']==id)
  {
   tmp = ord[i]['contID'];
   if(tmp == '') return false;
   if(tmp == contID){
   child = tmp.split('8109');
   for( j = 0; j< child.length; j++)
     if(child[j] == id) return true;
  }
  }
return false;
}

function isContCK()
{ var order = getOrder();
 var i;
 if(order.length == 0) return false;
 for( i=0; i < order.length; i++)  if(isSupertovarCK(order[i]['id'],order[i]['contID'])) return true;
 return false;
}

function pluscont(id, contID)
{
   var j;
   var i;
   var order = getOrder();
   var child = isSupertovarCK(id, contID);
   if(child)
   {
    for(i=0; i < order.length; i++){
     for(j = 0; j < child.length; j++)
      if((order[i]['id']==child[j]) && (order[i]['contID'] == contID))
        order[i]['amount']++;
     if((order[i]['id']==id) && (order[i]['contID'] == contID)) order[i]['amount']++;
    }
   }
   setOrder(order);
   drawOrder();
}


function minuskompl(id, contID)
{
  var k = 0;
  var i = 0;
  var newOrder = new Array();
  var order = getOrder();
  var child = isSupertovarCK(id, contID);
  if(child)
  {
   for(i=0; i < order.length; i++){
     for( j = 0; j < child.length; j++)
      if((order[i]['id']==child[j]) && (order[i]['contID'] == contID))
        order[i]['amount']--;
     if((order[i]['id']==id) && (order[i]['contID'] == contID)) order[i]['amount']--;
     if(order[i]['amount'] > 0) newOrder[k++] = order[i];
    }
  }
  setOrder(newOrder);
  drawOrder();
}

function calcBox(form)
{ var i;
 var ndlch = false;
 var sauch = false;
 var favch = false;
 var k = 0;
 var lapel = document.getElementsByName("lapsha");
 var falbl = document.getElementsByName("favlbl");
 var favel = document.getElementsByName("favorite");
 var savel = document.getElementsByName("sauce");
 var salbl = document.getElementsByName("saulbl");


 for(i = 0; i< lapel.length; i++)
 {  tovars[lapel[i].value]['contID']= '';
  if(lapel[i].checked){    ndlch = true;
    ndlID = tovars[lapel[i].value]['id'];
//    alert(ndlID);
    document.getElementById("ndlhd").style.color = "white";
    document.getElementById("favhd").style.color = "red";
    k += (tovars[lapel[i].value]['price'] - 0);
    document.getElementById("total").innerHTML = tovars[lapel[i].value]['name'] + ", ";
  }
 }

for(i = 0; i< favel.length; i++)
{
  if(ndlch){  	 favel[i].disabled = false;
     falbl[i].style.color = "white";
  }
  if(favel[i].checked){   favch = true;
   if(ndlch){    tovars[ndlID]['contID'] += tovars[favel[i].value]['id'] + '8109';
   }
   document.getElementById("favhd").style.color = "white";
   document.getElementById("sauhd").style.color = "red";
   k += (tovars[favel[i].value]['price'] - 0);
    document.getElementById("total").innerHTML += tovars[favel[i].value]['name'].toLowerCase() + ", ";
  }
  }
for(i = 0; i< savel.length; i++)
 {
  if(favch){  	 savel[i].disabled = false;
     salbl[i].style.color = "white";
  }
  if(savel[i].checked){   sauch = true;
   if(ndlch) tovars[ndlID]['contID'] += tovars[savel[i].value]['id'] + '8109';
   document.getElementById("sauhd").style.color = "white";
   k += (tovars[savel[i].value]['price'] - 0);
    document.getElementById("total").innerHTML += tovars[savel[i].value]['name'].toLowerCase() + " соус.";
  }
  }

 if(ndlch && favch && sauch){ 	 selleft = 1;
 	 document.getElementById("addrazdel").style.backgroundColor = "#5f1c01";
 }
 document.getElementById("total").innerHTML += " <br>Цена: " + k + "руб.";
}

function cleanPage()
{ var lapel = document.getElementsByName("lapsha");
 var falbl = document.getElementsByName("favlbl");
 var favel = document.getElementsByName("favorite");
 var savel = document.getElementsByName("sauce");
 var salbl = document.getElementsByName("saulbl");

  document.getElementById("ndlhd").style.color = "red";
  document.getElementById("favhd").style.color = "white";
  document.getElementById("sauhd").style.color = "white";

   for(i = 0; i< lapel.length; i++) lapel[i].checked = false;

  for(i = 0; i< favel.length; i++)
  {
  	favel[i].disabled = true;
  	favel[i].checked = false;
    falbl[i].style.color = "grey";
  }

    for(i = 0; i< savel.length; i++)
  {
  	savel[i].disabled = true;
  	savel[i].checked = false;
    salbl[i].style.color = "grey";
  }
  document.getElementById("total").innerHTML = 'Пока ничего не выбрано.';
}

function addBox()
{ cleanPage();
 plustovar1(ndlID);
}

// uniTip - written by Nathan Ford for Unit Interactive
//
// uniTip is based on qTip:
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com

var uniTipTag = "a,img"; //Which tag do you want to uniTip-ize? Keep it lowercase. No spaces around commas.//
var uniTipClass = "tip"; //Which classes do you want to uniTip-ize? If you leave this blank, then all the tags designated above will get uniTip-ized. Match case. No spaces around commas.

var uniTipX = -10; // X offset from cursor//
var uniTipY = -7; // Y offset from cursor//

//______________________________________________There's no need to edit anything below this line//

var offsetX = uniTipX, offsetY = uniTipY, elewidth = null, eleheight = null, tipid = null, tiptop = null, tipbot = null, tipcapin=null, tippointin=null, altText=false;

var x=0, y=0, WinWidth=0, WinHeight=0, TipWidth=0, TipHeight=0, CapHeight=0, PointHeight=0;

// first, find all the correct elements
init = function () {
	var elementList = uniTipTag.split(",");
	for(var j = 0; j < elementList.length; j++) {
		var elements = document.getElementsByTagName(elementList[j]);

		if(elements) {
			for (var i = 0; i < elements.length; i ++) {
				if (uniTipClass != '') {

					var elClass = elements[i].className;
					var elClassList = uniTipClass.split(",");

					for (var h=0; h < elClassList.length; h++) { if (elClass.match(elClassList[h])) unitipize(elements[i]); }

				} else unitipize(elements[i]);
			}
		}
	}
}

// next, add the tooltip function to those elements
unitipize = function (element) {
	var a = element;
	altText = (a.alt && a.getAttribute("alt") != '' ) ? true : false;
	var sTitle = (altText == true) ? a.getAttribute("alt") : a.getAttribute("title");
	if(sTitle) {
		a.onmouseover = function() {build(a, sTitle);};
		a.onmouseout = function() {hide(a, sTitle);};
	}
}

// now, we build the tooltip
build = function (a) {
	tipid = a;
	var ii = document.getElementById(tipid);

	document.onmousemove = function (evt) {move (evt)};
        ii.style.display = 'block';
}

// now, we track the mouse and make the tooltip follow
move = function (evt) {
	var ii = document.getElementById(tipid);

	if (window.event) {
		x = window.event.clientX;
		y = window.event.clientY;

		if (document.documentElement.scrollLeft) ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + document.documentElement.scrollLeft) + "px" :  (x + offsetX + document.documentElement.scrollLeft) + "px";
		else ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + document.body.scrollLeft) + "px" :  (x + offsetX + document.body.scrollLeft) + "px";

		if (document.documentElement.scrollTop) ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + document.documentElement.scrollTop) + "px" : (y + offsetY + document.documentElement.scrollTop) + "px";
		else ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + document.body.scrollTop) + "px" : (y + offsetY + document.body.scrollTop) + "px";

	} else {
		x = evt.clientX;
		y = evt.clientY;

		ii.style.left = (TipWidth >= WinWidth ) ? ((x - offsetX - elewidth) + window.scrollX) + "px" :  (x + offsetX + window.scrollX) + "px";
		ii.style.top = (TipHeight >= WinHeight) ? ((y - offsetY - eleheight) + window.scrollY) + "px" : (y + offsetY + window.scrollY) + "px";
	}

	TipWidth = x + elewidth + 20;
	TipHeight = y + eleheight + 20;

}

// lastly, hide the tooltip
hide = function (a) {
        if (a == tipid)
          {
  	    var ii = document.getElementById(tipid);
	    ii.style.display = "none";
	  }
}

// add the event to the page
if (window.addEventListener) window.addEventListener("load", init, false);
if (window.attachEvent) window.attachEvent("onload", init);





function n_GetX(pid)
{
var X = 0;
do { X += pid.offsetLeft } while ((pid = pid.offsetParent) != null);
return X;
}

function n_GetY(pid)//Cлужебная функция, определяет позицию TOP родительского элемента

{
var Y = 0;
do { Y += pid.offsetTop } while ((pid = pid.offsetParent) != null);
return Y;
}

function build2(a)
  {
    var ii = document.getElementById(a);
    if (ii.style.display != 'block')
      {
        ii.style.display = 'block';
        ii.style.left = n_GetX(ii) - 100;
        ii.style.top = n_GetY(ii) - 170;
      }
  }
function hide2(a)
  {
    var ii = document.getElementById(a);
    if (ii.style.display != 'none')
      {
        ii.style.left = parseInt(n_GetX(ii)) + 100;
        ii.style.top = parseInt(n_GetY(ii)) + 170;
        ii.style.display = 'none';
      }
  }

    var popupStatus = 0;
    var t = 2500;
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

    function loadPopup() {    	var pop = getCookie('pop');
    	if(pop) return;
    	setCookie('pop', '1');
        if (popupStatus == 0) {
            $("#backgroundPopup").css({
                "opacity": "0.8"
            });

            if (window.navigator.userAgent.indexOf("MSIE") >= 0 || window.navigator.userAgent.indexOf("Opera") >= 0){            	$("#popupContact").css({
                    "position": "absolute",
                    "width": "450px",
                    "height": "350px",
                    "background": "#666633",
                    "border": "2px solid #cecece",
                    "z-index": 2,
                    "padding": "12px",
                    "font-size": "13px",
                    "top": (document.body.scrollTop + 200) + "px",
                    "left": ($(window).width() / 2 - 200)
                });
                $("#popupContact h1").css({
                    "text-align": "center",
                    "color": "#FF6600",
                    "font-size": "16px",
                    "font-weight": "bold",
                    "padding-bottom": "2px",
                    "margin-bottom": "20px",
                    "font-family": "Arial, Helvetica, sans-serif"
                });
                $("#popupContactClose").css({
                    "font-size":"14px",
					"line-height":"14px",
					"right":"6px",
					"top":"4px",
					"position":"absolute",
					"color":"#6fa5fd",
					"font-weight":"700",
					"display":"block"
				});            }
             else $("#backgroundPopup").delay(t).fadeIn("slow");
            $("#popupContact").delay(t).fadeIn("slow");
            popupStatus = 1;
        }
    }
    function disablePopup() {
        if (popupStatus == 1) {
            $("#backgroundPopup").fadeOut("slow");
            $("#popupContact").fadeOut("slow");
            popupStatus = 0;
            setCookie('pop', '1');
        }
    }
    function centerPopup() {
        if (window.navigator.userAgent.indexOf("MSIE") >= 0  || window.navigator.userAgent.indexOf("Opera") >= 0) {
             $(window).scroll(function () {
             //   alert(document.clientWdth);
                $("#popupContact").css({
                    "position": "absolute",
                    "width": "450px",
                    "height": "350px",
                    "background": "#666633",
                    "border": "2px solid #cecece",
                    "z-index": 2,
                    "padding": "12px",
                    "font-size": "13px",
                    "top": (document.body.scrollTop + 200) + "px",
                    "left": ($(window).width() / 2 - 200)
                });
                $("#backgroundPopup").css({
                    "position" : "absolute",
                    "top": document.body.scrollTop + "px",
                    "width": "100%",
                    "height": "100%",
                    "left": 0,
                    "top":  0,
                    "left": 0,
                    "background": "#000000",
          //          "border":1px solid #cecece;
                    "z-index": 1

                });

            });

            $("#popupContact").css({
                "width": "100%",
                "height": "100%",
                "top": (document.body.scrollTop + 200) + "px",
                "left": ($(window).width() / 2 - $("#popupContact").width() / 2)
            });
            $("#backgroundPopup").css({
                "top": document.body.scrollTop + "px",
                "left": 0
            });
        }
        else {
            var windowWidth = document.documentElement.clientWidth;
            var windowHeight = document.documentElement.clientHeight;
            var popupHeight = $("#popupContact").height(350);
            var popupWidth = $("#popupContact").width(400);
            $("#popupContact").css({
                "position": "fixed",
                "top": 200,
                "left": $(window).width() / 2 -200
            });
            $("#backgroundPopup").css({            	"width" : "100%",
                "height": windowHeight
            });
        }
}
