
function setCheckboxColumn(theCheckbox){
    if (document.getElementById(theCheckbox)) {
        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
        }
    } else {
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
            if (document.getElementById(theCheckbox)) {
                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
            }
        }
    }
} 

function openCloseDiv(id)
{
document.getElementById(id).style.display = document.getElementById(id).style.display == "none" ? "table-row" : "none";
}

  function setCheckboxes(the_form, do_check)
  {
      var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                    ? document.forms[the_form].elements['selected_db[]']
                    : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
            ? document.forms[the_form].elements['selected_tbl[]']
            : document.forms[the_form].elements['selected_fld[]'];
      var elts_cnt  = (typeof(elts.length) != 'undefined')
                    ? elts.length
                    : 0;
  
      if (elts_cnt) {
          for (var i = 0; i < elts_cnt; i++) {
              elts[i].checked = do_check;
          } 
      } else {
          elts.checked        = do_check;
      } 
  
      return true;
  } 
  

 
var marked_row = new Array;
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }

    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;

        }
    }

    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            
        }
    }

    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } 

    if (newColor) {
        var c = null;

        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } 
        }

        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } 

    return true;
}
function validateSearch(formu,msg) 
{ 
   if (!formu.search.value) { 
        alert(msg); 
        document.formu.elements['search'].focus();
        return false; 
    } 
      else 
   { 
        return true; 
        } 
}


function confirmDel(msg)
{
input_box=confirm(msg);
if (input_box==true)
{
return true;
}
else
{
return false;
}
}

function checkReg(form1)
{

if (document.form1.elements['reg'].value=='y')
{
document.form1.elements['reg'].value='n';
}
else
{
document.form1.elements['reg'].value='y';
}
}


function validateLogin(form_login,msg) 
{ 
   if (!form_login.login.value) { 
        alert(msg); 
        document.form_login.elements['login'].focus();
        return false; 
    } 
    else if (!form_login.pass.value)
    {
            alert(msg); 
        document.form_login.elements['pass'].focus();
        return false; 
    }
      else 
   { 
        return true; 
        } 
}

function disableIt(obj)
{
	obj.disabled = true;

}

function enableIt(obj)
{
	obj.disabled = false;
}

function disabledpay(){

   for(var i=0;i<document.formularz.shipping.length;i++)
   {
   disableIt(document.formularz.shipping[i]);
   }

}

function enabledpay(){

   for(var i=0;i<document.formularz.shipping.length;i++)
   {
   enableIt(document.formularz.shipping[i]);
   }

}
function t(v,e,t) 
{ 
  if(!v.title||!document.createElement)return 
  t=document.createElement("div") 
  t.move=function(e) 
  { 
    e=e||event 
    t.style.left=e.clientX+10+(document.documentElement.scrollLeft||document.body.scrollLeft)+"px" 
    t.style.top=e.clientY+0+(document.documentElement.scrollTop||document.body.scrollTop)+"px" 
  } 
  t.hide=function(x) 
  { 
    v.title=t.innerHTML 
    if(x=document.getElementById("tooltip")) document.body.removeChild(x) 
  } 
  t.move(e); 
  t.id="tooltip" 
  t.innerHTML=v.title;v.title="" 
  document.body.appendChild(t) 
  v.onmouseout=t.hide 
  v.onmousemove=t.move 
}
  
function addEvent(O,E,F,x){
  return(x=O.addEventListener)?x(E,F,1):(x=O.attachEvent)?x('on'+E,F):!1
}


function calcg(bry,brx,tw,hw)
{
brx=parseInt(brx);
bry=parseInt(bry);
tw=parseInt(tw);
hw=parseInt(hw);
var z=10;
if (brx<68 || brx>132 || bry< 82 || bry>156 ||hw<92 || hw>140 || tw<65 || tw>129)
{
alert ("Niepoprawne parametry!");
z="";
}
else
{
var a,b,g;
var i,g1,ix,ixt,g1t;
gr1 = new Array(70,75,80,85,90,95,100,105,110,115,120,125,130);
gr2 = new Array("A","B","C","D","E","F","G");
hw1 = new Array(92,96,99,102,105,109,113,117,121,125,129,133,137);
hw2 = new Array(95,98,101,104,108,112,116,120,124,128,132,136,140);
tw1 = new Array(65,69,74,78,82,87,91,96,103,109,115,120,125);
tw2 = new Array(68,73,77,81,86,90,95,102,108,114,119,124,129);
xg = new Array("S","S","M","M","L","L","XL","XL","XXL","XXL","XXXL","XXXL","XXXL");
a=Math.floor((brx-68)/5);
b=Math.floor((bry-82-5*a)/2);
g1="x";
for (i=0;i<=12;i++)
{
	if ((hw1[i]<=hw) && (hw2[i]>=hw))
	{
	ix=i;
	g1=i*2+36;
	}
	if ((tw1[i]<=tw) && (tw2[i]>=tw))
	{
	ixt=i;
	g1t=i*2+36;
	}
}
if (b<0) b=0;

if (!gr2[b])
{
alert ("Niepoprawne parametry!");
z="";
}
else
{
document.A.Tol2.value= "("+eval(a*5+68)+"-" +eval(a*5+72)+")";
document.A.Tol1.value="("+eval(b*2+82+a*5)+"-" +eval(b*2+84+a*5)+")";
document.A.Tol4.value="("+hw1[ix]+"-"+hw2[ix]+")";
document.A.Tol3.value="("+tw1[ixt]+"-"+tw2[ixt]+")";
	if (g1==g1t)
	{
	document.A.Aus2.value=g1;
	}
	else
	{
	document.A.Aus2.value=g1+" ("+g1t+")";
	}
document.A.Aus3.value=xg[ix];
z=gr2[b] + " " + gr1[a] ;
}
}
return z;
}

function puzzle() {

noweOkno = window.open('puzzle.html', 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=720, height=470')

}

function kolorowanka() {

noweOkno = window.open('kolorowanka.html', 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=770, height=620')

}
function snake() {

noweOkno = window.open('snake.html', 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=556, height=370')

}
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}
function inicjuj() {
var ddmx = new DropDownMenuX('menu1');
    ddmx.delay.show = 0;
    ddmx.delay.hide = 400;
    ddmx.position.levelX.left = 1;
    ddmx.init();
    }
function reklama() {
browser_width = document.body.clientWidth;
poz_x = (browser_width/2)-300;

if(document.getElementById('reklama')) {
document.getElementById('reklama').style.top = '120px';
document.getElementById('reklama').style.left = poz_x+'px';
document.getElementById('reklama').style.display = 'block';
}

}
function ukryj() {
document.getElementById('reklama').style.display = 'none';
}
addLoadEvent(inicjuj);
addLoadEvent(reklama);




$(document).ready(function(){
	InitSocialTab();
	$("div#SocialTab").css("position", "absolute");
	$("#TBP").click(function(){
		var pSzer = $("html").innerWidth()
		var xPoz = (pSzer/2)-178+'px';
		$("#tbpPopup").css({
			'left' : xPoz,
			'display' : 'block'
		})
	})
	
	$("#tbpPopup a").click(function(){
		$("#tbpPopup").css({"display":"none"});
		return false;
	})
});

$(window).scroll(function() {
    $("div#SocialTab").css("top", $(window).scrollTop() + 260 + "px");
});


function InitSocialTab() {
	$("div#SocialTab").hover(
			  function () {
			    $(this).animate({
			    	left: '0px'
			    },500);
			  }, 
			  function () {
				  $(this).animate({
				    	left: '-130px'
				    },500);
			  }
			);
}
