///////////////////////////////////////////////////////////////////////////////////////////////////////
//	addresses
///////////////////////////////////////////////////////////////////////////////////////////////////////
var addressess = 0;
var curritem = 0;
function tickAddresses() {
    $("div#addresses > address:eq("+curritem+")").hide();
    curritem = ++curritem % addressess;
    $("div#addresses > address:eq("+curritem+")").show();
}


jQuery(document).ready(function(){
    jQuery(".expand").click(
		function(e) {
			if ( jQuery(this).next().hasClass("expanded") )
				jQuery(this).next().removeClass("expanded");
			else
				jQuery(this).next().addClass("expanded");
			if (jQuery(this).attr("href") == "#empty")
				return false;
		}
	);
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	s3Slider
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	if ( jQuery('.header_banner').length != 0 )
	{
		jQuery('.header_banner').s3Slider({
			timeOut: 6000
		});
	}
	
	if ( jQuery('.top_banner').length != 0 )
	{
		jQuery('.top_banner').s3Slider({
			timeOut: 5000
		});
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	superfish menu
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery("ul.sf-menu").superfish().find('ul').bgIframe({
		opacity:true,
		delay:       200,								// half second delay on mouseout 
		animation:   {opacity:'show',height:'show'},	// fade-in and slide-down animation 
		speed:       'fast',                        	// faster animation speed 
		autoArrows:  false,                           	// disable generation of arrow mark-up 
		dropShadows: true                            	// disable drop shadows
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	form điđemiđe
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery("div.form > input, div.form > textarea").focus(function(){
		jQuery(this).parent().css("background-color", "#999");
		jQuery(this).parent().css("color", "#fff");
	});
	jQuery("div.form input, div.form textarea").blur(function(){
		jQuery(this).parent().css("background-color", "");
		jQuery(this).parent().css("color", "");
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	poll điđemiđe
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery("div#poll > input").focus(function(){
		jQuery(this).parent().addClass("active");
	});
	jQuery("div#poll > input").blur(function(){
		jQuery(this).parent().removeClass("active");
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	thickbox close
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery(".close").click(function(){
		window.parent.tb_remove();
	});
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	print
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery(".print").click(function()
	{
		window.print();
	});
	
	var state = jQuery.cookie("compare_list");
	
	if ( state == null)
	{
		hide_compare_list();
	}
	if(state == "open")
	{
		show_compare_list();
	}
	if(state == "close")
	{
		hide_compare_list();
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	compare products
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	jQuery("a.compare_product").click().toggle(
		show_compare_list,
		hide_compare_list		
	);
	
	jQuery(".compare_product > a").click(show_compare_list);
	
	function hide_compare_list()
	{
		jQuery("div#compare_list").slideUp();
		jQuery.cookie("compare_list")
		jQuery.cookie("compare_list", "close");
	}
	function show_compare_list()
	{
		jQuery("div#compare_list").slideDown();
		jQuery.cookie("compare_list", "open");

	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	//	addresses
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	addressess = jQuery("div#addresses > address").hide().size();
	jQuery("div#addresses > address:eq("+curritem+")").show();
	setInterval(tickAddresses, 5000); //time in milliseconds 
	
});

/*****************************************************************************
 * jQuery Headline Scroll
 * Version: 1.0 released 2007-12-08
 * Author: Dave Ross <dave@csixty4.com>
 * License: BSD
 * Requires: jQuery 1.2.1 or higher (may work with others, not tested)
 *
 * To make an element scroll automatically, assign it a height through CSS
 * and give it the class "autoscroll".
 *
 * To control scroll speed, give new values to these global variables:
 *   scrollerIntervalMs = {how often to scroll, in milliseconds, default 200}
 *   scrollerStep       = {# of pixels to scroll each interval, default 1}
 *
 * Copyright (c) 2007, Dave Ross <dave@csixty4.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Dave Ross ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

var scrollerStep = 1;
var scrollerIntervalMs = 100;

function initScroller()
{
	$('.autoscroll').each( function() {

		$(this).mouseover(function() { doPause(this); });

		$(this).mouseout(function() { doPause(this); });

		$(this).css('overflow', 'hidden');

	});

	setInterval("doScroll()", scrollerIntervalMs);	
}

function doScroll()
{
	$('.autoscroll').filter(':not(".paused")').each( function() {

		var x = this.scrollTop;

		// The height of the div, as defined by CSS
		var divHeight = parseInt($(this).css('height'));

		// The height of the div's contents
		var contentHeight = this.scrollHeight;

		// Increment the position we're scrolling to by 1px
		x += scrollerStep;

		// Start over if we've scrolled too far
		if(x > (contentHeight - divHeight)) x = 0;

		// Scroll!
		this.scrollTop = x;

	});
}

function doPause(el)
{
	$(el).toggleClass('paused');
}

$(document).ready(function() {
   initScroller();
});

///////////////////////////////////////////////////////////////////////////////////////////////////////
//	radio commercial
///////////////////////////////////////////////////////////////////////////////////////////////////////
/*
jQuery(document).ready(function()
	{
		playComertial("_Upload/Documents/Bitechnique_mp3_player.swf");
	}
)
// "_Upload/Documents/Bitechnique_mp3_player.swf"
function playComertial( commertialPath )
{
	var isCommertialPlayed = jQuery.cookie("isCommertialPlayed");
	if (isCommertialPlayed == null)
	{
		var div = "<div id=\"radio_commercial\" style=\"width:1px; heigth:1px; position:absolute; top:0; left:0; overflow;hidden;\"><div id=\"player\"></div></div>";
		jQuery("body").append(div);
		swfobject.embedSWF(commertialPath, "player", "1", "1", "9.0.0", "_assets/_flash/expressInstall.swf", null, null);
		jQuery.cookie("isCommertialPlayed", true);
	}
}
*/