function setCookie(c_name,value,exdays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}

function getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function deleteCookie(name) {
   if (getCookie(name)) document.cookie = name + "=" +
   ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

window.addEvent('domready', function(){            
	var mySlide = new Fx.Slide('menu_top_toggle').hide();
	$('menutop_toggle').addEvent('click', function(e){
	
	mySlide.toggle();
	
	});

        jQuery('img.center-picmenu-m-item-price').qtip({ 
            style: {
                name: 'dark',
                tip: true,
                background: 'black',
                border: {color: 'black'}
            },
            show: { delay: 0 },
            hide: { delay: 150 },
            position: {
                corner: {
                    target: 'topRight',
                    tooltip: 'bottomLeft'
                }
            }
        });

        jQuery('div.center-picmenu-m-item set-left a img').each( function (i) {
            var obj = jQuery(this);
            obj.hover( function () {
                jQuery('a.title', obj).css('text-decoration', 'underline');
            },  function () {
                jQuery('a.title', obj).css('text-decoration', 'none');
            })
        });
});




var scroll;
var curPos;
var itemSize= 322;
var maxLength;
var news_timer;

window.addEvent("load",function(){
	
        
        if(jQuery('.modal-box-bg')) {
            var cookie = getCookie('modal-box');
            
            if(cookie != 1) {
                setTimeout(function(){
                    jQuery('.modal-box-bg').fadeIn('900');
                }, '1000');        

                if(closeBtn = jQuery('.modal-box-bg .close')) {
                    closeBtn.click(function() {
                        jQuery('.modal-box-bg').fadeOut('2000');
                    });
                }
                setCookie('modal-box', 1, 3);
            }            
        }
        
	tape = document.getElementById("linkTape");
	itemsCount = $$('div.header-content-window-text-tape-item').length;
	
	scroll = new Fx.Scroll("linkTape");
	curPos = 0;
	maxLength = itemsCount*itemSize;//($("linkTape").getSize()).scrollSize.y;

	$('headWindowCurPos').set('html',curPos+1);
	$('headWindowMaxPos').set('html',itemsCount);
	
	clearTimeout(news_timer);
	setTimeout("moveright()", 4000);

});

function moveleft(){
	if((curPos*itemSize-322) >= 0){
		curPos -= 1;  
		scroll.start(curPos*itemSize,0); 
		$('headWindowCurPos').set('html',curPos+1);
	}
	else
	{
		curPos = itemsCount-1;  
		scroll.start(curPos*itemSize,0); 
		$('headWindowCurPos').set('html',curPos+1);
	}
	
	clearTimeout(news_timer);
	news_timer = setTimeout("moveright()", 4000);

}

function moveright(){
	if((curPos*itemSize+itemSize) < maxLength){
		curPos += 1;  
		scroll.start(curPos*itemSize,0); 
		$('headWindowCurPos').set('html',curPos+1);
	}
	else
	{
		curPos = 0;  
		scroll.start(curPos*itemSize,0); 
		$('headWindowCurPos').set('html',curPos+1);
	}
	
	clearTimeout(news_timer);
	news_timer = setTimeout("moveright()", 4000);

}

/*function fav() {
    if (window.sidebar) {
    window.sidebar.addPanel(document.title,self.location,'')
    } else if (window.external) {
    window.external.AddFavorite(self.location,document.title)
    } else if (window.opera) {
         var e = document.getElementById('fav');
         e.setAttribute('href',self.location);
         e.setAttribute('title',document.title);
         e.setAttribute('rel','sidebar');
         e.click();
    }
}*/

/*
* Copyright 2010 by GlamThumbs Team.
*
* How To Use The Script:
* add to your page this code between inside head tags
* <script type="text/javascript" src="ATBookmarkApp.js"></script>
* add anchor with void href like this:
* <a href="javascript:void(0)" onClick="return BookmarkApp.addBookmark(this)">bookmark us</a>
*
*/

ATBookmarkApp = function () {
    var isIEmac = false; /*@cc_on @if(@_jscript&&!(@_win32||@_win16)&&
(@_jscript_version<5.5)) isIEmac=true; @end @*/
    var isMSIE = (-[1,]) ? false : true;
    var cjTitle = document.title;
    var cjHref = location.href;

    function hotKeys() {
        var ua = navigator.userAgent.toLowerCase();
        var str = '';
        var isWebkit = (ua.indexOf('webkit') != - 1);
        var isMac = (ua.indexOf('mac') != - 1);

        if (ua.indexOf('konqueror') != - 1) {
            str = 'CTRL + B'; // Konqueror
        } else if (window.home || isWebkit || isIEmac || isMac) {
            str = (isMac ? 'Command/Cmd' : 'CTRL') + ' + D'; // Netscape, Safari, iCab, IE5/Mac
        }
        return ((str) ? 'Press ' + str + ' to bookmark this page.' : str);
    }

    function isIE8() {
        var rv = -1;
        if (navigator.appName == 'Microsoft Internet Explorer') {
            var ua = navigator.userAgent;
            var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
            if (re.exec(ua) != null) {
                rv = parseFloat(RegExp.$1);
            }
        }
        if (rv > - 1) {
            if (rv >= 8.0) {
                return true;
            }
        }
        return false;
    }

    function addBookmark(a) {
        try {
            if (typeof a == "object" && a.tagName.toLowerCase() == "a") {
                a.style.cursor = 'pointer';
                if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {
                    window.sidebar.addPanel(cjTitle, cjHref, ""); // Gecko
                    return false;
                } else if (isMSIE && typeof window.external == "object") {
                    if (isIE8()) {
                        window.external.AddToFavoritesBar(cjHref, cjTitle); // IE 8
                    } else {
                        window.external.AddFavorite(cjHref, cjTitle); // IE <=7
                    }
                    return false;
                } else if (window.opera) {
                    a.href = cjHref;
                    a.title = cjTitle;
                    a.rel = 'sidebar'; // Opera 7+
                    return true;
                } else {
                    alert(hotKeys());
                }
            } else {
                throw "Error occured.\r\nNote, only A tagname is allowed!";
            }
        } catch (err) {
            alert(err);
        }

    }

    return {
        addBookmark : addBookmark
    }
}();
