function checkSignUpForm(fObj) {
	if (!checkEmail(fObj.email.value)) { alert("Please enter your valid email address.");  fObj.email.focus();   return false; }
	return true;
}
// {{{ scroll featured products
var ScrollPos = 0;
var PRODUCT_BLOCK_WIDTH = 190; // px
var enableScroll = true;
var moveFlag = true;
var timeToMove = 100;
function onMouseDownEvent(direction) {
	moveFlag = true;
	onMouseDownEventProceed(direction)
}
function onMouseDownEventProceed(direction) {
	if (moveFlag) {
		moveFlag = false;
		setTimeout("onMouseDownEventProceed(" + direction + ")", timeToMove);
		ScrollPreview(direction);
		moveFlag = true;
	}
}
document.onmouseup = function(){
	moveFlag = false;
}


function setEnableScroll() {
	enableScroll = true;
}
function ScrollPreview(direction)
{

	if (enableScroll && PRODUCTS_COUNT > 3) {
		enableScroll = false;
		ScrollPos -= direction * PRODUCT_BLOCK_WIDTH;
		if (ScrollPos > 0) {
			tb = document.getElementById("table-scroll");
			tr = document.getElementById("tr-scroll");
			tds = tr.getElementsByTagName("td");
			td = tr.removeChild(tds[tds.length - 1]);
			tr.insertBefore(td,tds[0]);
			tb.style.left = -PRODUCT_BLOCK_WIDTH + "px";
			ScrollPos = 0;
		}
		if (ScrollPos < MAX_SCROLL) {
			tb = document.getElementById("table-scroll");
			tr = document.getElementById("tr-scroll");
			tds = tr.getElementsByTagName("td");
			td = tr.removeChild(tds[0]);
			tr.appendChild(td);
			tb.style.left = parseInt(tb.style.left) + PRODUCT_BLOCK_WIDTH + "px";
			ScrollPos = MAX_SCROLL;
		}
		$("#fp-preview .scrolled-products:first").animate({ left: ScrollPos }, "slow", "", setEnableScroll);
	}
}

function onMouseDownEventTwoStr(direction) {
	moveFlag = true;
	onMouseDownEventProceedTwoStr(direction)
}
function onMouseDownEventProceedTwoStr(direction) {
	if (moveFlag) {
		moveFlag = false;
		setTimeout("onMouseDownEventProceedTwoStr(" + direction + ")", timeToMove);
		ScrollPreviewTwoStr(direction);
		moveFlag = true;
	}
}

function ScrollPreviewTwoStr(direction)
{

	if (enableScroll && PRODUCTS_COUNT > 3) {
		enableScroll = false;
		ScrollPos -= direction * PRODUCT_BLOCK_WIDTH;
		if (ScrollPos > 0) {
			tb = document.getElementById("table-scroll");
			tr1 = document.getElementById("tr-scroll1");
			tds1 = tr1.getElementsByTagName("td");
			td1 = tr1.removeChild(tds1[tds1.length - 1]);
			tr1.insertBefore(td1,tds1[0]);
			tr2 = document.getElementById("tr-scroll2");
			tds2 = tr2.getElementsByTagName("td");
			td2 = tr2.removeChild(tds2[tds2.length - 1]);
			tr2.insertBefore(td2,tds2[0]);
      tb.style.left = -PRODUCT_BLOCK_WIDTH + "px";
			ScrollPos = 0;
		}
		if (ScrollPos < MAX_SCROLL) {
			tb = document.getElementById("table-scroll");
			tr1 = document.getElementById("tr-scroll1");
			tds1 = tr1.getElementsByTagName("td");
			td1 = tr1.removeChild(tds1[0]);
			tr1.appendChild(td1);
			tr2 = document.getElementById("tr-scroll2");
			tds2 = tr2.getElementsByTagName("td");
			td2 = tr2.removeChild(tds2[0]);
			tr2.appendChild(td2);
			tb.style.left = parseInt(tb.style.left) + PRODUCT_BLOCK_WIDTH + "px";
			ScrollPos = MAX_SCROLL;
		}
		$("#fp-preview .scrolled-products:first").animate({ left: ScrollPos }, "slow", "", setEnableScroll);
	}
}
// }}}



/////////////////// {{{ equalization blocks

var eqCounter = 0;

function EqualColumns()
{
     this.eqa = 0;
     this.eqth = 0;
     this.eqtw = 0;

     var c, e, el;
    if (document.getElementById)
    {
        this.blocks = new Array();
        for (i = 0; i < arguments.length; i += 2)
        {
            el = null;
            c = document.getElementById(arguments[i]);
            if (c)
            {
                e = c.getElementsByTagName(arguments[i+1]);
                if (e)
                {
                    el = e[e.length-1];
                    if (!el.id)
                    {
                        el.id = "myeq" + (eqCounter++);
                    }
                }
            }
            if (c && el)
            {
                this.blocks.push(c);
                this.blocks.push(el);
            }
        }
          this.startCalculate();
    }
}

EqualColumns.prototype.startCalculate = function() {
    if (this.eqth != document.body.offsetHeight || this.eqtw != document.body.offsetWidth)
    {
        this._startCalculate();
    }
}

EqualColumns.prototype._startCalculate = function() {
    var i, oh, h = 0, tg, el, np, dA = this.blocks, an = this.eqa;
    if (dA && dA.length)
    {
        for (i = 0; i < dA.length; i += 2)
        {
            dA[i+1].style.paddingBottom = '';
        }
        for (i = 0; i < dA.length; i += 2)
        {
            oh = dA[i].offsetHeight;
            h = (oh > h) ? oh : h;
        }
        for (i = 0; i < dA.length; i += 2)
        {
            oh = dA[i].offsetHeight;
            if (oh < h)
            {
                np = h - oh;
                    dA[i+1].style.paddingBottom = np + "px";
            }
        }
        this.eqa = 1;
        this.eqth = document.body.offsetHeight;
        this.eqtw = document.body.offsetWidth;
    }
}
///// }}}
function verticalAlignEC(el1, el2) {
			try {
  			var h = parseInt($(el1).css('padding-bottom'));
  			$(el1).css('padding-bottom', Math.floor(h / 2));
  			$(el2).css('padding-top', Math.ceil(h / 2));
      } catch (e) {
        return;
      }
      return;
}
function equa() {
  try {
    new EqualColumns("bg-block", "div", "psl-block", "div");
  } catch (e) {}
  try {
    new EqualColumns("pr-block", "div", "fd-block", "div");
  } catch (e) {}
 	verticalAlignEC("#fd-block > div[id*='myeq']", "#fd-block > div.va");
}
function initDHTML(){
  try {
    new EqualColumns('tab1', 'div', 'tab2', 'div', 'tab3', 'div', 'tab4', 'div', 'tab5', 'div',  'tab6', 'div', 'tab7', 'div');
  } catch(e){}
  try {
		document.getElementById("tabs-mess").style.display = "none";
		document.getElementById("tabs-hide").style.visibility = "visible";
		document.getElementById("tabs-hide").style.height = "auto";
  } catch(e){}
  try {
		document.getElementById("tab1").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab2").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab3").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab4").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab5").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab6").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab7").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("tab" + active_tab).style.display = "block";
  } catch(e){}
  try {
    var tabs = document.getElementById("tabs").getElementsByTagName("A");
    var selectedTab = active_tab;
    for (var i = 0, len = tabs.length; i < len; i++) {
		  tabs[i].onclick = function() {
		    var clickedTab = Number(this.getAttribute("rel").replace(/tab/, ""));
		    if (clickedTab !== selectedTab) {
				  tabs[selectedTab - 1].className = "";
				  tabs[clickedTab - 1].className = "active";
				  document.getElementById("tab" + selectedTab).style.display = "none";
				  document.getElementById("tab" + clickedTab).style.display = "block";
				  selectedTab = clickedTab;
        }
        return false;
      }
  	}
  } catch(e){}
}
addLoadEvent(equa);
addLoadEvent(initDHTML);

