﻿var cookiecontent;
var menuServiceOpen = false;
var menuPricesOpen = false;
var currentBoxColor; 
var menuTimeOut = 350;
var hintShown = false;


function checkLevelOfFile(level) {
    if (level == '1') {
        fileLevel = '';
    } else if (level == '2') {
        fileLevel = '../';    
    } else {
        fileLevel = '../../';
    }
    return fileLevel;
}

function openCloseBox(boxId, parentId, imgArrow) {
    if (document.getElementById(boxId)) {
        var box = document.getElementById(boxId);
        if (box.style.display == 'none') {
            box.style.display = 'block';
            if (parentId) {
                var box = document.getElementById(parentId);
                currentBoxColor = box.style.color;
				box.style.color = '#fa5b05';
                imgArrow.src = '/_common_all_lang/imgs/bgs/arrow_up.gif';
                
            }
        } else {
            box.style.display = 'none';
            if (parentId) {
                var box = document.getElementById(parentId);
                box.style.color = currentBoxColor;
                imgArrow.src = '/_common_all_lang/imgs/bgs/arrow_down.gif';                
            }
        }
    }
}

function openBox(boxId, parentId) {
    if (document.getElementById(boxId)) {
        var box = document.getElementById(boxId);
        if (box.style.display == 'none') {
            box.style.display = 'block';
            if (parentId) {
                var box = document.getElementById(parentId);
                box.style.color = '#fa5b05';
            }
        }
    }
}

function closeBox(boxId, parentId) {
    if (document.getElementById(boxId)) {
        var box = document.getElementById(boxId);
        if (box.style.display == 'block') {
            box.style.display = 'none';
            if (parentId) {
                var box = document.getElementById(parentId);
                box.style.color = '#478800';
            }
        }
    }
}

function mouseOutOfMenu() {
    if (menuServiceOpen == true) {
        closeBox('ServiceMenuSecond', 'Service');
    }

    if (menuPricesOpen == true) {
        closeBox('pricesMenuSecond', 'Prices');
    }
    return true;
}

function openCloseTable(boxId, buttonId) {
    if (document.getElementById(boxId)) {
        var box = document.getElementById(boxId);
        if (box.style.display == 'none') {
            box.style.display = 'table';
            var button = document.getElementById(buttonId);
            button.src = '../imgs/icons/open_tab.gif';

        } else {
            box.style.display = 'none';
            var button = document.getElementById(buttonId);
            button.src = '../imgs/icons/close_tab.gif';
        }
    }
}

function writeCookie() {
    var expireDate = new Date();
    expireDate.setHours(expireDate.getHours() + 36);
    document.cookie = "ClosePromotion=closed;Expires=" + expireDate.toGMTString();
}

function writeSendOrderCookie(CookieValue) {
    var expireDate = new Date();
    expireDate.setHours(expireDate.getHours() + 12);
	document.cookie = "OrdersSent="+CookieValue.toString()+";Expires=" + expireDate.toGMTString();
}

function readCookieValue(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}


function readCookie() {
  var closed = false;
  var allcookies = document.cookie;
  cookiearray  = allcookies.split(';');
  // Now take key value pair out of this array
  for(var i=0; i<cookiearray.length; i++){
      name = cookiearray[i].split('=')[0];
      value = cookiearray[i].split('=')[1];
	  if (name ='ClosePromotion')
	  {
        if (value == "closed") {
			if(document.getElementById('discount')!=null)
			{
				document.getElementById('discount').style.display = 'none';
				closed = true;
			}			
        }
	}
}
	
    if (closed == false)
	{
		if(document.getElementById('discount')!=null)
			{
				document.getElementById('discount').style.display = 'block';
			}
    }
}

function showNote(noteId, curElem) {
	if (document.getElementById(noteId)) 
	{
		var box = document.getElementById(noteId);
		if (hintShown){
			//box.style.display = 'none';
			//hintShown = false;
		}
		else{
            box.style.display = 'block';
			curElem.style.cursor = 'auto';
			curElem.style.textDecoration = 'none'; 			
			hintShown = true ;
		}
    }
}

