	var ua = navigator.userAgent;
	var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	var isMSIE5 = isMSIE && (ua.indexOf('MSIE 5') != -1);
	var isMSIE5_0 = isMSIE && (ua.indexOf('MSIE 5.0') != -1);
	var isMSIE7 = isMSIE && (ua.indexOf('MSIE 7') != -1);
	var isGecko = ua.indexOf('Gecko') != -1;
	var isSafari = ua.indexOf('Safari') != -1;
	var isOpera = ua.indexOf('Opera') != -1;
	var isMac = ua.indexOf('Mac') != -1;
	var isNS7 = ua.indexOf('Netscape/7') != -1;
	var isNS71 = ua.indexOf('Netscape/7.1') != -1;




///Menu
 navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);
///

function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}


function SetAllCB(nval)
	{
	re = new RegExp("cb_\\d*$")
	for(i = 0; i < document.forms[0].elements.length; i++) {
			elm = document.forms[0].elements[i]
		if (elm.type == 'checkbox') {
				if (re.test(elm.name)) {
					if (nval == true)
							elm.checked = true;
					else
					if (nval == false)
						elm.checked = false;
					else
					if (nval == "not")
						elm.checked =! elm.checked;
				}
			}
		}
	}
  function PL_licz(n,t1,t2,tn )
	{
        if(n == 1)
          return t1;
        else if (n> 1 && n<5)
          return t2;
        else  if (n>4)
          return tn;
	}
  function HideById(Id)
	{
        var Obj=document.getElementById(Id);
        Obj.style.display='none';
	}
	 function ShowById(Id)
	{
        var Obj=document.getElementById(Id);
        //Obj.style.display='table-row';
        //alert(Obj.tagName);
        if(Obj.tagName.toUpperCase()=='TR')
          ShowById_tr(Id);
        else
          Obj.style.display='inline';
	}
	function ShowById_tr(Id)
	{
        var Obj=document.getElementById(Id);
        try
        {
             Obj.style.display='table-row';
        }
       catch (e)
        {
            Obj.style.display='inline';
        }
	}
function ajaxSub(Req)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
/*  For debug
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
            alert(xmlHttp.responseText);
        }
      }
    xmlHttp.open("GET","index.php5?act=ajax&actajax=" + Req,true); */
    xmlHttp.open("GET","index.php5?act=ajax&actajax=" + Req,false);
    xmlHttp.send(null);
  }

function clearForm(formName)
{
  var form, elements, i, elm;
    form = document.forms[formName];
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")
			{
				elm.value ='';
			}
			if (elm.type == "radio")
			{
				elm.checked =false;
			}
		}
}
function ShowNonEmpty(formName,elId)
{
  var form, elements, i, elm,Show;
    Show=false;
    form = document.forms[formName];
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text" | elm.type == "hidden"  )
			{
				if(elm.value !='')
				{
          Show=true;
        }
      }
  	}
		if(Show)
       ShowById(elId);
}
function xmlMicoxLoader(url){
  //by Micox: micoxjcg@yahoo.com.br.
  //http://elmicoxcodes.blogspot.com
    if(window.XMLHttpRequest){
        var Loader = new XMLHttpRequest();
        //assyncronous mode to load before the 'return' line
        Loader.open("GET", url ,false);
        Loader.send(null);
        return Loader.responseXML;
    }else if(window.ActiveXObject){
        var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0");
        //assyncronous mode to load before the 'return' line
        Loader.async = false;
        Loader.load(url);
        return Loader;
    }
}

//

function xmlMicoxLoaderAsync(url,fun,par1,par2){
  //by Micox: micoxjcg@yahoo.com.br.
  //http://elmicoxcodes.blogspot.com
    if(window.XMLHttpRequest){
        var Loader = new XMLHttpRequest();
        //assyncronous mode to load before the 'return' line
        Loader.onreadystatechange=function(){
            if (Loader.readyState == 4)
                fun(Loader.responseXML,par1,par2)
        };
        Loader.open("GET", url ,true);
        Loader.send(null);
        return ;
    }else if(window.ActiveXObject){
        var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0");
        //assyncronous mode to load before the 'return' line
        Loader.onreadystatechange=function(){
           if (Loader.readyState == 4) {
                       fun(Loader,par1,par2);

          }
        };
        Loader.async = true;
        Loader.load(url);
        return ;
    }
}


function LoadDiv_Async_handle(loader,div_id,par2)
{
    alert(div_id);
    var elm = document.getElementById(div_i);
    elm.innerHTML = loader;
}
function LoadDiv_Async(url,div_id)
{
  advAJAX.get({
    url: url,
          onSuccess : function(obj) { document.getElementById( div_id ).innerHTML=obj.responseText;},
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}

// Usage
// <SELECT id=a NAME=browser  OnChange="Related_Combobox(this,'cb');">
//  ...
//  <OPTION  LABEL="AAAAA1:BBBB:CCCC:DDDD">AAAA</OPTION>
//  ...
//   <SELECT id='cb' NAME=aaa>
function Related_Combobox(cb_src,cb_destid)
{
   var cb_dest=document.getElementById(cb_destid);
    var  options=cb_dest.options;
    for (var i = options.length - 1; i>= 0; i--)
            options[i] = null;
   var sel_el=cb_src.options[cb_src.selectedIndex];
   var optArr=sel_el.title.toString().split(":")
    options[0]=new Option('wybierz ...', "")
   for (var i = 0; i<optArr.length; i++)
       options[i+1] =new Option(optArr[i],optArr[i])
 }
function DYN_SubmitForm(frmid)
{

   advAJAX.submit(document.getElementById(frmid),{
          onSuccess : function(obj) { alert(obj.responseText);},
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}

//CAT_{$pid}
function DIV_LoadContent(www_get,ContentId) {
advAJAX.get({
url: www_get,
onSuccess : function(obj) { document.getElementById(ContentId).innerHTML=obj.responseText; }
});
}
function HideShow(eHide,eShow)
{
  document.getElementById(eHide).style.display='none';
  document.getElementById(eShow).style.display='block';
}

function TextEdit_Seve(eDivText,eDivInput,eInput,Adr)
{
    document.getElementById(eDivText).innerHTML='Zapisuje ...';
    var Val=encodeURIComponent(document.getElementById(eInput).value);
    HideShow(eDivInput,eDivText);
    LoadDiv_Async(Adr+Val,eDivText);
}

function TextEdit_Save(eDivText,eDivInput,Adr)
{
    document.getElementById("txt" + eDivText).innerHTML='Zapisuje ...';
    var Val=encodeURIComponent(document.getElementById("txt" +eDivInput).value);
    HideShow(eDivInput,eDivText);
    LoadDiv_Async(Adr+Val,"txt" + eDivText);
}


///// DSMP1
function  DSMP1_RefreshMenu()
{
  var  www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid
        advAJAX.get({
              url: www_get,
              onSuccess : function(obj) { document.getElementById('Cont.c'+DSMP1_cid).innerHTML=obj.responseText; }
          });
}
function DSMP1_EditMenu_Action(Action,ArtID,RefreshMenu)
{
    var  www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid+"&" + DSMP1_Act+"=" +Action
    if(ArtID)
        www_get+= "&" + DSMP1_ArtIDSel + "="+ArtID;

    advAJAX.get({
        url: www_get,
        onSuccess : function(obj) {
            document.getElementById('DSMP1_EditMenu_popup_html').innerHTML=obj.responseText;
            if(RefreshMenu)
                      DSMP1_RefreshMenu();
          }
      });


}
function DSMP1_ItemEditName(Id)
{
    var val=document.getElementById('Nazwa_'+ Id).innerHTML;
    document.getElementById('Nazwa_'+ Id).innerHTML="<Input id='Input_"+ Id +
    "' value ='" + val + "'/> ";
    document.getElementById('EButton_'+ Id).style.display='none';
    document.getElementById('SButton_'+ Id).style.display='block';
}
function DSMP1_ItemEditName_Save(Id)
{
    var www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid+"&" +DSMP1_ArtIDSel+"="+Id+"&" +DSMP1_Act+"=ItemEditNameSave";
      www_get+="&Title=" +encodeURIComponent(document.getElementById('Input_'+ Id).value);
      document.getElementById('Nazwa_'+ Id).innerHTML="Zapisywanie ....."
    advAJAX.get({
    url: www_get,
     onSuccess : function(obj) {
        document.getElementById('Nazwa_'+ Id).innerHTML=obj.responseText;
        document.getElementById('EButton_'+ Id).style.display='block';
        document.getElementById('SButton_'+ Id).style.display='none';
        DSMP1_RefreshMenu();
        }
    });
}
function DSMP1_ItemEditArt(Id)
{
   var www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid+"&" +DSMP1_ArtIDSel+"="+Id+"&" +DSMP1_Act+"=GetHTML";
  //  document.getElementById("Cont.root_c" +DSMP1_Target_cid).innerHTML=www_get;
  //  alert(www_get);
  DSMP1_aid=Id;
  advAJAX.get({
    url: www_get,
    onSuccess : function(obj) {
        document.getElementById('Cont.c'+DSMP1_Target_cid).innerHTML=obj.responseText;

          DSMP1_Edit();
        }
    });




}

function DSMP1_EditMenu()
{
    ShowBkEffect();
    document.getElementById('DSMP1_EditMenu_popup').style.display='block';
    DSMP1_EditMenu_Action("EditMenu");

}
function DSMP1_Edit()
{
  var PopUp=document.getElementById('edit_popup');
  PopUp.style.display='block';

  var SrcHtml=document.getElementById('Cont.c1').innerHTML;
  var elm = document.getElementById('EditArea');
  if (tinyMCE.getInstanceById('EditArea') == null)
       tinyMCE.execCommand('mceAddControl', true, 'EditArea');

  var inst = tinyMCE.getInstanceById('EditArea');
	inst.setHTML(SrcHtml);
	
}
function HideDiv(id)
{
   document.getElementById(id).style.display='none';
}
function DSMP1_Save()
{
    var inst = tinyMCE.getInstanceById('EditArea');
    var www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid+"&" +DSMP1_ArtIDSel+"="+DSMP1_aid+"&" +DSMP1_Act+"=SaveHTML";

    advAJAX.post({
    url: www_get,
    parameters : {
      "html" :inst.getHTML()
      

    },
    onSuccess : function(obj) { document.getElementById('Cont.c'+DSMP1_Target_cid).innerHTML=obj.responseText;  },
    onError : function(obj) { alert("Błąd: " + obj.status); },
    timeout : 3000,
    retry: 5,
    retryDelay: 2000
});
    HideDiv('edit_popup');
   // alert(www_get);
}
function DSMP1_LoadContent(art_id) {
    var www_get=DSMP1_WWW+"?rq=DYN&id="+DSMP1_pid+"&cid="+DSMP1_cid+"&" +DSMP1_ArtIDSel+"="+art_id+"&" +DSMP1_Act+"=GetHTML";
    DSMP1_aid=art_id;
    MCT_Show('DSMP1',www_get,'DSMP1_Edit()');
  /*
  advAJAX.get({
    url: www_get,
        onInitialization : function() {document.getElementById( 'Cont.c'+DSMP1_Target_cid ).innerHTML=Wait_HTML(316,316);},
    onSuccess : function(obj) { document.getElementById('Cont.c'+DSMP1_Target_cid).innerHTML=obj.responseText; }
    });

    DSMP1_aid=art_id;
    if (IsRoot)
      document.getElementById("Cont.root_c" +DSMP1_Target_cid).innerHTML='<a href="javascript:DSMP1_Edit();"><img src="img/edit.gif" border="0"/></a>'*/
}
//////////////////////////////////
//    CAT



var   CAT_brand="";
var   CAT_series="";
var   CAT_subseries="";
var   CAT_type="";
var   CAT_page="";
var   CAT_pagePC="";
var   CAT_search="";
var   CAT_price="";
var   CAT_novelty="1";
var   CAT_list2="";

function CAT_ShowList2()
{
	var cbvalue=document.getElementById('SelList2').checked;
	if(cbvalue)
	{
	  CAT_list2='t';
	  RozwinTM();
	}
	else
	 CAT_list2='f';
	CAT_Refresh();
}

function SetTop(n) {
   var obj = new Object();
    	var ie=document.all && !window.opera
    	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
    	obj.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
    	obj.scroll_top=(ie)? obj.standardbody.scrollTop : window.pageYOffset
    
     var uni=document.getElementById(n);
     uni.style.top=obj.scroll_top+10+"px"
 
}
function Uni_H() {
  SetTop('UNI_popup');
}
function CAT_Edit(ReadGet)
{
  Uni_H() ;
  var PopUp=document.getElementById('UNI_popup');
  PopUp.style.display='block';
  advAJAX.get({
    url: ReadGet,
     onInitialization : function()
      {
            document.getElementById('UNI_title').innerHTML ='Edycja produktów';
            ShowBkEffect();
            Uni_H() ;
            document.getElementById('UNI_popup').style.display='block';
            document.getElementById('UNI_html').innerHTML=Wait_HTML(700,500);
            },
            onSuccess : function(obj) { document.getElementById( 'UNI_html' ).innerHTML=obj.responseText;  },
            onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function CAT_SaveProd(frmid)
{

   advAJAX.submit(document.getElementById(frmid),{
          onSuccess : function(obj) { 
          document.getElementById( 'CAT_EditArea' ).innerHTML=obj.responseText; 
          CAT_Refresh();HideDiv('UNI_popup');HideBkEffect(); },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function Wait_HTML(w,h)
{
     return '<div  style="width: '+w+'px; height: '+h+'px; background-repeat:no-repeat ; background-image: url(img/loading.gif);background-position: center center; ">&nbsp;</div>'
}
function CAT_Iframe_onload(iframe,typ,pid,get_ext)
//'ico','{$product.id}','{$imgsrc_ico}')
{
  advAJAX.get({
    url: get_ext,
      onSuccess : function(obj) {
                var file=obj.responseText;
                document.getElementById( 'img_Upload_'+typ).src=file +"?r="+Math.floor(Math.random() * 99999);
            },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });


}
function CAT_PIX_sub(frmid,pid,type,get_ext)
{
//('{$iprefix}_PIX_org2big','{$product.id}','big','{$imgsrc_big}')
    advAJAX.submit(document.getElementById(frmid),{
        onSuccess : function(obj) {
              if (obj.responseText=='OK')
                  CAT_Iframe_onload(null,type,pid,get_ext);
              else
                  alert(obj.responseText);
          },
          onError : function(obj) {
              alert("Błąd: " + obj.status);
           }
    });
}
function CAT_AddNew(get)
{
 advAJAX.get({
    url: get,
       onInitialization : function()
      {
          document.getElementById('UNI_html').innerHTML=Wait_HTML(700,500);
            },
      onSuccess : function(obj) {
                var file=document.getElementById( 'UNI_html' ).innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });

}
function CAT_Refresh()
{
    //var gBrand= CAT_Pref+"product_brand" ;
    var txt="<a class='link2' href='javascript:CAT_All()'>Sklep kaligraf</a> ";
    if(CAT_brand)
      txt+=">> <a class='link2' href='javascript:CAT_SetCond(\""+CAT_brand+"\",\"\",\"\",\"\")'>"+CAT_brand+"</a> ";

    if(CAT_series)
      txt+=">> <a class='link2' href='javascript:CAT_SetCond(\"\",\"\",\""+CAT_series+"\",\"\")'>"+CAT_series+"</a> ";

    if(CAT_type)
      txt+=">> <a class='link2'  href='javascript:CAT_SetCond(\"\",\""+CAT_type+"\",\"\",\"\")'>"+CAT_type+"</a> ";
	if(CAT_novelty)
      txt+=">> <a class='link2'  href='javascript:CAT_Set_novelty();'>Nowości</a>";
      
    if(CAT_search)
        txt+=">> Szukanie : " + CAT_search;
    document.getElementById('sklep_lab').innerHTML=txt;
advAJAX.get({
    url: CAT_Get,
     parameters : {
             "product_brand":CAT_brand,
             "product_series":CAT_series ,
             "product_subseries":CAT_subseries ,
             "product_type":CAT_type,
             "product_search":CAT_search,
             "set_P":CAT_page,
             "set_PC":CAT_pagePC,
             'price':CAT_price,
             'novelty':CAT_novelty,
             'list2':CAT_list2
          },
         onInitialization : function() {document.getElementById( CAT_Content ).innerHTML=Wait_HTML(316,316);},
         onSuccess : function(obj) {
            document.getElementById( CAT_Content ).innerHTML=obj.responseText;
            setshop_height();
            },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function onSuwakChange(amt)
{
    CAT_price=amt;
    CAT_Refresh();
}
function CAT_Set_novelty()
{
    CAT_brand="";
    CAT_series="";
    CAT_type="";
    CAT_novelty='1';
    CAT_Refresh();
}
function CAT_Serch(id)
{
    CAT_search=document.getElementById( id ).value;
    CAT_Refresh();
}
function CAT_All()
{
    CAT_brand="";
    CAT_series="";
    CAT_subseries="";
    CAT_type="";
    CAT_page="";
    CAT_pagePC="";
    CAT_search="";
    CAT_novelty='';
    CAT_Refresh();
}
function CAT_SetCond(brand,type,series,subseries)
{
    CAT_novelty='';
    CAT_brand=brand;
    CAT_series=series;
    CAT_subseries=subseries;
    CAT_type=type;
    CAT_Refresh();

}
function CAT_SetPage(page)
{
    CAT_page=page;
    CAT_Refresh();
}
function CAT_SetPagePC(page)
{
    CAT_pagePC=pagePC;
    CAT_Refresh();
}
function CAT_GetMore(get,editget)
{
    ZwinTM();
    MCT_Show('CAT',get,"CAT_Edit('"+editget+"')");
}

////
function   ShowBkEffect()
{    document.getElementById('BkEffect').style.display='block';
     document.getElementById('BkEffect').style.height= "2000px" ;//
    // alert(document.body.clientHeight) większe ale ...;
    // alert(document.documentElement.clientHeight);

 }
function   HideBkEffect()
{    document.getElementById('BkEffect').style.display='none'; }


///// HTML
var HTML_Save_Get;
var HTML_Save_Content_Id;
function HTML_Save()
{
    var inst = tinyMCE.getInstanceById('UEditArea');
    advAJAX.post({
    url: HTML_Save_Get,
    parameters : {
      "html" :inst.getHTML()
      

    },
    onSuccess : function(obj) { document.getElementById( HTML_Save_Content_Id ).innerHTML=obj.responseText;  },
    onError : function(obj) { alert("Błąd: " + obj.status); },
    timeout : 3000,
    retry: 5,
    retryDelay: 2000
});
    HideDiv('uedit_popup');
   // alert(www_get);
}
function HTML_Edit(SrcId,SaveGet,iWidth,iHeight)
{
  HTML_Save_Get=SaveGet;
  HTML_Save_Content_Id=SrcId;
  var PopUp=document.getElementById('uedit_popup');

  PopUp.style.width=iWidth+"px";
  PopUp.style.height=iHeight+"px";
  PopUp.style.display='block';

  var SrcHtml=document.getElementById(SrcId).innerHTML;
  var elm = document.getElementById('UEditArea');
  if (tinyMCE.getInstanceById('UEditArea') == null)
       tinyMCE.execCommand('mceAddControl', true, 'UEditArea');

  var inst = tinyMCE.getInstanceById('UEditArea');
	inst.setHTML(SrcHtml);
}

///LM

 function LM_LoadDiv_Async(url,div_id)
{
  advAJAX.get({
    url: url,
            onInitialization : function() {
                document.getElementById(div_id).innerHTML=Wait_HTML(450,300);

          },
          onSuccess : function(obj) { document.getElementById( div_id ).innerHTML=obj.responseText;},
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function LM_Series(www,brand)
{
    document.getElementById('tabber_main').tabber.tabShow(2);
    LM_LoadDiv_Async(www+'?rq=DYN&id=1&cid=5&actLM_1_5=Edit_series&actLM_1_5_S=Load&brand_name_1_5='+encodeURIComponent(brand),'LM_1_5_S');
  }
function LM_Edit(ReadGet)
{
  advAJAX.get({
    url: ReadGet,
          onInitialization : function() {
            ShowBkEffect();
            document.getElementById('lm_edit_popup_html').innerHTML=Wait_HTML(480,300);
            document.getElementById('lm_edit_popup').style.display='block';
          },
          onSuccess : function(obj) { document.getElementById( 'lm_edit_popup_html' ).innerHTML=obj.responseText; tabberAutomatic(); },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function LM_Refresh()
{
  advAJAX.get({
    url:LM_RefreshPath,
          onSuccess : function(obj) {
            document.getElementById( 'Cont.c5' ).innerHTML=obj.responseText;
            ddtreemenu.createTree('treemenu1', false);
            },
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
////////// User
var USR_cid;
function USR_Login(frmid,cid)
{
   advAJAX.submit(document.getElementById(frmid),{
          onInitialization : function() {
            document.getElementById(cid).innerHTML=Wait_HTML(246,110);
          },
          onSuccess : function(obj) {
              if (obj.responseText=='root')
                     document.getElementById('refresh_123').submit();
              else
              {
                  document.getElementById( cid ).innerHTML=obj.responseText;
                  SCH_RefreshCartIco();
               }
          },
          onError : function(obj) {
              alert("Błąd: " + obj.status);
           }
    });
}
function USR_SendPasswd (get,loginId)
{
   if(! document.getElementById(loginId).value || document.getElementById(loginId).value=='')
      alert('Wprowadź login = email')
  else
  {
    advAJAX.get({
    url: get+encodeURIComponent(document.getElementById(loginId).value),
          onSuccess : function(obj) {
                  alert(obj.responseText);
            },
          onError : function(obj) { alert("Błąd niepoprawny login" ); }
    });
  }
}
function USR_Register(get)
{
ShowBkEffect();
SetTop('USR_Register_popup');
 if( document.getElementById( 'USR_Register_popup_html' ).innerHTML =="" ||
      document.getElementById('USR_Register_popup_title').innerHTML!='Rejestracja'
   )
 {

   document.getElementById('USR_Register_popup_title').innerHTML ='Rejestracja';
  advAJAX.get({
    url: get,
          onSuccess : function(obj) {
                 
                 document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;
                 document.getElementById('USR_Register_popup').style.display='block';
            },
          onError : function(obj) { alert("Błąd" ); }
    });
  }
  else
    document.getElementById('USR_Register_popup').style.display='block';
}

function USR_CHData(get){

  document.getElementById('USR_Register_popup_title').innerHTML ='Aktualizacja danych';
  ShowBkEffect();
   advAJAX.get({
    url: get,
          onInitialization : function() {
            SetTop('USR_Register_popup');
            document.getElementById('USR_Register_popup_html').innerHTML=Wait_HTML(510,340);
            document.getElementById('USR_Register_popup').style.display='block';
          },
          onSuccess : function(obj) {
                 document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;

            },
          onError : function(obj) { alert("Błąd" ); }
    });


}
function USR_CHData_Save(frmid,base)
{
   advAJAX.submit(document.getElementById(frmid),{
          onSuccess : function(obj) {
                alert(obj.responseText);
                HideDiv('USR_Register_popup');HideBkEffect();

            },
          onError : function(obj) {
             if(obj.status == 506 )
            {
              alert("Niepoprawne dane !!!");
            }else
                alert("Błąd: " + obj.status);
          }
    });

}
function USR_CHPasswd(get)
{
document.getElementById('USR_Register_popup_title').innerHTML ='Zmiana hasła';
  ShowBkEffect();
   advAJAX.get({
    url: get,
          onInitialization : function() {
            SetTop('USR_Register_popup');
            document.getElementById('USR_Register_popup_html').innerHTML=Wait_HTML(510,100);
            document.getElementById('USR_Register_popup').style.display='block';
          },
          onSuccess : function(obj) {
                 document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;

            },
          onError : function(obj) { alert("Błąd" ); }
    });

}

function USR_CHPasswd_Save(frmid){
  var IsOK=true;
  var ErrMsg="";

  var p=document.getElementById(frmid+"_passwd").value;
  if(p !=document.getElementById(frmid+"_passwd_eg").value)
  {
      ErrMsg+="Hasła się różnią." ;
      IsOK=false;
  }
  if(p.length <6)
   {
      ErrMsg+="\nHasło jest za krótkie(przynajmniej 6 znaków)." ;
      IsOK=false;
  }
  if(! IsOK)
  {
      alert(ErrMsg);
      return ;
  }
 advAJAX.submit(document.getElementById(frmid),{
          onSuccess : function(obj) {
                alert(obj.responseText);
                //alert("Hasło zostało zmienione");
                HideDiv('USR_Register_popup');HideBkEffect();
            },
          onError : function(obj) {
             if(obj.status == 506 )
            {
              alert("Niepoprawne stare hasło !!!");
            }else
                alert("Błąd: " + obj.status);
          }
    });
}

function USR_RegAuth( act,kod,cid)
{

advAJAX.get({
    url: act,
    parameters : {
            kod : document.getElementById(kod).value
          },
          onSuccess : function(obj) {
                 document.getElementById(cid).innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd" ); }
    });

}



function USR_RegisterData(frmid,divid,baseptah,cid)
{
// test
//
  var IsOK=true;
  var ErrMsg="";

  if (! isEMailAddr(document.getElementById(frmid+"_login") ))
  {
     document.getElementById(frmid+"_login").className='text_reg_err';
      ErrMsg+="Niepoprawny e-mail." ;
      IsOK=false;
  }
  else
    document.getElementById(frmid+"_login").className='text_reg';

  var p=document.getElementById(frmid+"_passwd").value;
   document.getElementById(frmid+"_passwd").className='text_reg';
  document.getElementById(frmid+"_passwd_eg").className='text_reg';
 if(p !=document.getElementById(frmid+"_passwd_eg").value)
  {
      document.getElementById(frmid+"_passwd").className='text_reg_err';
      document.getElementById(frmid+"_passwd_eg").className='text_reg_err';
      ErrMsg+="\nHasła się różnią." ;
      IsOK=false;
  }
  if(p.length <6)
   {
      document.getElementById(frmid+"_passwd").className='text_reg_err';
      document.getElementById(frmid+"_passwd_eg").className='text_reg_err';
      ErrMsg+="\nHasło jest za krótkie(przynajmniej 6 znaków)." ;
      IsOK=false;
  }
   var p=document.getElementById(frmid+"_tel").value;
   document.getElementById(frmid+"_tel").className='text_reg';
  if(p.length <6)
   {
      document.getElementById(frmid+"_tel").className='text_reg_err';
      ErrMsg+="\nTelefon kontaktowy jest wymagany." ;
      IsOK=false;
  }
  
  
  if (! document.getElementById(frmid+"_accept_reg").checked )
  {
     document.getElementById(frmid+"_accept_reg").className='text_reg_err';
      ErrMsg+="\nProszę zaakceptować regulamin." ;
      IsOK=false;
  }
  else
    document.getElementById(frmid+"_accept_reg").className='text_reg';
  if (! document.getElementById(frmid+"_accept_giodo").checked)
  {
     document.getElementById(frmid+"_accept_giodo").className='text_reg_err';
      ErrMsg+="\nProszę zaakceptować zgodę na przetwarzanie danych osobowych." ;
      IsOK=false;
  }
  else
    document.getElementById(frmid+"_accept_giodo").className='text_reg';

  if(!IsOK)
  {
      alert(ErrMsg);
        return;
  }
  advAJAX.submit(document.getElementById(frmid),{
            onSuccess : function(obj) {
              document.getElementById( divid ).innerHTML=obj.responseText;
              USR_Refresh(baseptah,cid);
              },
          onError : function(obj) {
            if(obj.status == 505 )
            {
              alert("niepoprawne dane");
            }
            else
            if(obj.status == 506 )
            {
              alert("Taki login/email jest już zarejestrowany w systemie");
            }
            else
              alert("Błąd: " + obj.status); }
    });

}
function USR_Refresh(path,cid)
{
   advAJAX.get({
    url: path,
          onSuccess : function(obj) {
            document.getElementById(cid ).innerHTML=obj.responseText;
            },
          onError : function(obj) {
              alert("Błąd: " + obj.status);
          }
    });
}
function USR_Logout(get,cid)
{
  advAJAX.get({
    url: get,
          onSuccess : function(obj) {
            if(obj.responseText == 'root')
                document.getElementById('refresh_123').submit();
             else
              document.getElementById(cid ).innerHTML=obj.responseText;
            },
          onError : function(obj) {
              alert("Błąd: " + obj.status);
          }
    });
}

///ROOT
var USR_Adm_BasePath;
var USR_Idx;
var USR_BasePath;


function USR_root_CHData(id){

  var get= USR_BasePath;
  get+="&act_"+USR_Idx+"=root_CHData";
  get+="&id_"+USR_Idx+"="+id;
  document.getElementById('UNI1_title').innerHTML ='Aktualizacja danych';

   advAJAX.get({
    url: get,
          onInitialization : function() {
            document.getElementById('UNI1_html').innerHTML=Wait_HTML(700,500);
            document.getElementById('UNI1_popup').style.display='block';
          },
          onSuccess : function(obj) {
                 document.getElementById('UNI1_html').innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd" ); }
    });
}
function USR_root_CHData_Save(frmid)
{
   advAJAX.submit(document.getElementById(frmid),{
          onSuccess : function(obj) {
                document.getElementById('UNI_html').innerHTML=obj.responseText;
                HideDiv('UNI1_popup');
            },
          onError : function(obj) {
             if(obj.status == 506 )
            {
              alert("Niepoprawne dane !!!");
            }else
                alert("Błąd: " + obj.status);
          }
    });

}


function USR_Adm_send(addget,fp)
{
  var get=USR_Adm_BasePath;
  if(addget)
      get+=addget;
  if(fp)
  
  ShowBkEffect();
    document.getElementById('UNI_title').innerHTML ='Zarządzanie użytkownikami';
  advAJAX.get({
    url: get,
          onInitialization : function() {
          Uni_H() ;
           document.getElementById('UNI_popup').style.display='block';
          document.getElementById('UNI_html').innerHTML=Wait_HTML(700,500);},
          onSuccess : function(obj) {
                 document.getElementById('UNI_html').innerHTML=obj.responseText;

            },
          onError : function(obj) { alert("Błąd" ); }
    });
}
function USR_UsrSetField(id,field,val)
{
  var get=USR_BasePath;
  get+="&act_"+USR_Idx+"=admsetfield";
  get+="&id_"+USR_Idx+"="+id;
  get+="&field_"+USR_Idx+"="+field;
  get+="&val_"+USR_Idx+"="+val;
   advAJAX.get({
    url: get,
          onInitialization :USR_Adm_onInitialization,
          onSuccess : USR_Adm_onSuccess,
          onError : function(obj) { alert("Błąd" ); }
    });

}
function USR_Adm_onInitialization()
{
    Uni_H() ;
   document.getElementById('UNI_popup').style.display='block';
   document.getElementById('UNI_html').innerHTML=Wait_HTML(700,500);
}
function USR_Adm_onSuccess(obj)
{
   document.getElementById('UNI_html').innerHTML=obj.responseText;
}


function USR_Adm(Idx,BasePath,AdmBasePath)
{
  USR_Hl.Init(AdmBasePath,USR_Adm_onInitialization,USR_Adm_onSuccess);
  USR_Adm_BasePath=AdmBasePath;
  USR_Idx=Idx;
  USR_BasePath=BasePath;
  
  USR_Adm_send();
}

function HTML_List() {

    var obj = new Object();
    var onInitialization=null;
    var onSuccess=null;
    var BasePath=null;
    
    
    obj.Init = function(bp,init,succ) {
      obj.BasePath=bp;
      obj.onInitialization=init;
      obj.onSuccess=succ;
    };
    obj.RefreshFunction = function(addget) {
      var get=obj.BasePath;
       if(addget)
          get+=addget;
          advAJAX.get({
                url: get,
                onInitialization : obj.onInitialization,
                onSuccess : obj.onSuccess,
                onError : function(obj) { alert("Błąd" ); }
          });
    };
    obj.SubmitFunction = function(fid) {
           advAJAX.submit(document.getElementById(fid),{
                onInitialization : obj.onInitialization,
                onSuccess : obj.onSuccess,
                onError : function(obj) { alert("Błąd" ); }
          });
    };
     obj.Set_Sort =  function (tag)
      {
        var get="&set_SO=" +tag;
        obj.RefreshFunction(get);
      };
      obj.Set_Page =  function (tag)
      {
        var get="&set_P=" +tag;
        obj.RefreshFunction(get);
      };
      obj.Set_PagePos =  function (tag)
      {
        var get="&set_PC=" +tag;
        obj.RefreshFunction(get);
      };
      obj.DoFiltr=function (formid)
      {
           obj.SubmitFunction(formid);
      }

  return obj;
};
var USR_Hl=HTML_List();

/// Zwiń - rozwiń
var w=575;

function RozwinTM()
{

   w+=50;
   //925
   if(w>1000)
  {
    clearTimeout()
    document.getElementById('Rozwin').innerHTML='<a href="javascript:Zwin();"><img src="img/shop_button2.gif" border="0"></a>'
  }
  else
  {
      document.getElementById('shopContent').style.width=w+"px";
      setshop_height();
      self.setTimeout("RozwinTM()", 100);
  }
}

function Rozwin()
{
  w=575;
  self.setTimeout("RozwinTM()", 100);

}
function ZwinTM()
{

    w-=25;
  if(w<570)
  {
    clearTimeout()
    document.getElementById('Rozwin').innerHTML='<a href="javascript:Rozwin();"><img src="img/shop_button1.gif" border="0"></a>'
  }
  else
  {
      document.getElementById('shopContent').style.width=w+"px";
       self.setTimeout("ZwinTM()", 100);
       setshop_height();
  }
}
function Zwin()
{
	var cbvalue=document.getElementById('SelList2').checked;
	if(cbvalue)
	{
		document.getElementById('SelList2').checked=false;	
		CAT_ShowList2();
	}
	//925
	w=1000;
  self.setTimeout("ZwinTM()", 100);
}

function ZwinNow()
{
	document.getElementById('shopContent').style.width="570px";
	document.getElementById('Rozwin').innerHTML='<a href="javascript:Rozwin();"><img src="img/shop_button1.gif" border="0"></a>';
}

/// Multicont

var MCT_cid='Cont.c1'
var MCT_crid='Cont.root_c1'
var MCT_type='DSMP1'
function MCT_Show(type,path,admfun,postfun)
{
   MCT_type= type;
   if(  IsRoot)
			document.getElementById(MCT_crid).innerHTML='';
   advAJAX.get({
    url: path,
    onInitialization : function() {document.getElementById(MCT_cid).innerHTML=Wait_HTML(316,316);},
    onSuccess : function(obj) {
      document.getElementById( MCT_cid).innerHTML=obj.responseText;
      if(admfun &&  IsRoot)
        document.getElementById(MCT_crid).innerHTML='<a href="javascript:' + admfun +';"><img src="img/edit.gif" border="0"/></a>';
       
      if(postfun)
        postfun();
      setshop_height();
     },
    onError : function(obj) { alert("Błąd: " + obj.status); }
    });

}



/////Shop Cart
//SHC
var SCH_ContentId;
var SCH_BContentId;
var SCH_BasePath;
var SCH_Idx;
var SCH_Adm_BasePath;
function SCH_Init(cid,cidb,bp,idx,abp)
{
  SCH_ContentId=cid;
  SCH_BContentId=cidb;
  SCH_BasePath =bp;
  SCH_Idx      =idx;
  SCH_Adm_BasePath=abp;

}

function SCH_RefreshCartIco()
{
    advAJAX.get({
    url: SCH_BasePath,
    onInitialization : function() { document.getElementById(SCH_ContentId).innerHTML=Wait_HTML(50,50);},
    onSuccess : function(obj) {
      document.getElementById( SCH_ContentId).innerHTML=obj.responseText;
    },
    onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}

function SCH_AddCart(pid)
{
    var act="act_"+SCH_Idx;
    var id="id_"+SCH_Idx;
    var path=SCH_BasePath+"&"+act+"=prodadd&"+id+"="+pid;
    advAJAX.get({
    url: path,
    onInitialization : function() { document.getElementById(SCH_ContentId).innerHTML=Wait_HTML(50,50);},
    onSuccess : function(obj) {
      document.getElementById( SCH_ContentId).innerHTML=obj.responseText;
      SCH_RefreshCart(); },
    onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function SCH_ClsCart()
{

    var act="act_"+SCH_Idx;
    var path=SCH_BasePath+"&"+act+"=clscart";
    advAJAX.get({
    url: path,
    onInitialization : function() { document.getElementById(SCH_ContentId).innerHTML=Wait_HTML(50,50);},
    onSuccess : function(obj) {
      document.getElementById( SCH_ContentId).innerHTML=obj.responseText;
      SCH_RefreshCart();
      },
    onError : function(obj) { alert("Błąd: " + obj.status); }
    });
}
function SCH_RefreshCart()
{
    if (MCT_type=='SCH')
    {
          var act="act_"+SCH_Idx;
          var path=SCH_BasePath+"&"+act+"=show_cart";
          MCT_Show('SCH',path);
    }
}
function SCH_ShowCart()
{
    ZwinTM();
    var act="act_"+SCH_Idx;
    var path=SCH_BasePath+"&"+act+"=show_cart";
    MCT_Show('SCH',path);
}
function SCH_ShowCart_Delete(id)
{

    var act="act_"+SCH_Idx;
    var actid="id_"+SCH_Idx;
    var path=SCH_BasePath+"&"+act+"=show_cart_delete&"+actid +'='+id;
    MCT_Show('SCH',path,null,SCH_RefreshCartIco);
}

function SCH_ShowCart_SaveNum(eDivText,eDivInput,id)
{
     var Val=document.getElementById("txt" +eDivInput).value;
     pv=parseInt(Val);
     if( isNaN(pv)|| pv<0 || pv.toString() != Val)
     {
        alert('Niepoprawna wartość');
     }
     else
     {
            HideShow(eDivInput,eDivText);
            var act="act_"+SCH_Idx;
            var actid="id_"+SCH_Idx;
            var path=SCH_BasePath+"&"+act+"=savenum&"+actid +'='+id+"&nnum_"+SCH_Idx+"="+ Val;
            ;
            advAJAX.get({
            url: path,
              onInitialization : function() { document.getElementById('txt' +eDivText).innerHTML='...';},
            onSuccess : function(obj) {
              document.getElementById('txt' +eDivText).innerHTML=obj.responseText;
              SCH_RefreshCartIco();

              },
            onError : function(obj) { alert("Błąd: " + obj.status); }
            });
    }
}


function SCH_Zamowienie()
{
ShowBkEffect();
  var act="act_"+SCH_Idx;
  var path=SCH_BasePath+"&"+act+"=zamowienie";
  advAJAX.get({
    url: path,
          onInitialization : function() {
          SetTop('USR_Register_popup');
          document.getElementById('USR_Register_popup').style.display='block';
          document.getElementById('USR_Register_popup_title').innerHTML='Zamówienie';
          document.getElementById('USR_Register_popup_html').innerHTML=Wait_HTML(510,510);
          },
          onSuccess : function(obj) {
                 document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd" ); }
    });
}
function SCH_Zam_SetDefAdr(name,adress,zip,city,tel)
{
//dzf_{$IDX}_name
  if(name)
    document.getElementById("dzf_"+SCH_Idx+'_name').value=name;
  if(adress)
  document.getElementById("dzf_"+SCH_Idx+'_adress').value=adress;
  if(zip)
  document.getElementById("dzf_"+SCH_Idx+'_zip').value=zip;
  if(city)
  document.getElementById("dzf_"+SCH_Idx+'_city').value=city;
  if(tel)
  document.getElementById("dzf_"+SCH_Idx+'_tel').value=tel;

}
function SCH_Zam_SetDefInv(name,adress,zip,city,nip)
{
//dzf_{$IDX}_name
  if(name)
    document.getElementById("fzf_"+SCH_Idx+'_name').value=name;
  if(adress)
    document.getElementById("fzf_"+SCH_Idx+'_adress').value=adress;
  if(zip)
    document.getElementById("fzf_"+SCH_Idx+'_zip').value=zip;
  if(city)
    document.getElementById("fzf_"+SCH_Idx+'_city').value=city;
  if(nip)
    document.getElementById("fzf_"+SCH_Idx+'_nip').value=nip;

}
function SCH_Zam_Submit()
{
    var Msg="";
    var IsOk=true;
      if( document.getElementById("zf_"+SCH_Idx+'_trans').value==''){
        Msg="Proszę wybrać formę dostarczenia.";
        IsOk=false;
    }
     if( document.getElementById("dzf_"+SCH_Idx+'_name').value==''){
        Msg+="\nProszę wpisać imię i nazwisko lub nazwę firmy.";
        IsOk=false;
    }
    if( document.getElementById("dzf_"+SCH_Idx+'_adress').value==''){
        Msg+="\nProszę wpisać adres.";
        IsOk=false;
    }
    if( document.getElementById("dzf_"+SCH_Idx+'_zip').value==''){
        Msg+="\nProszę wpisać kod pocztowy.";
        IsOk=false;
    }
    if( document.getElementById("dzf_"+SCH_Idx+'_city').value==''){
        Msg+="\nProszę wpisać miasto.";
        IsOk=false;
    }
    if( document.getElementById("dzf_"+SCH_Idx+'_tel').value==''){
        Msg+="\nProszę wpisać numer telefonu.";
        IsOk=false;
    }
    if( document.getElementById("zf_"+SCH_Idx+'_tr_hour').value==''){
        Msg+="\nProszę wpisać preferowaną godzinę dostarczenia.";
        IsOk=false;
    }
    /*
    if( document.getElementById("fzf_"+SCH_Idx+'_name').value==''){
        Msg+="\nFaktura: pole 'Imię i nazwisko lub nazwę firmy' musi być wprowadzone!";
        IsOk=false;
    }
    if( document.getElementById("fzf_"+SCH_Idx+'_adress').value==''){
        Msg+="\nFaktura: pole adres musi być wprowadzone!";
        IsOk=false;
    }
    if( document.getElementById("fzf_"+SCH_Idx+'_city').value==''){
        Msg+="\nFaktura: pole miasto musi być wprowadzone!";
        IsOk=false;
    }*/

    if(!IsOk)
    {
      alert(Msg);
      return
    }


    advAJAX.submit(document.getElementById('zf_' +SCH_Idx),{
    //document.getElementById('USR_Register_popup_html').innerHTML
          onSuccess : function(obj) { document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;SCH_ClsCart();},
          onError : function(obj) { alert("Błąd: " + obj.status); }
    });


}
function SCH_OrdersList()
{
    ZwinTM()
    var act="act_"+SCH_Idx;
    var path=SCH_BasePath+"&"+act+"=orderslist";
    MCT_Show('SCH_O',path);
}

function SCH_Order_Delete(zid)
{
   var act="act_"+SCH_Idx;
   var id="id_"+SCH_Idx;
   var path=SCH_BasePath+"&"+act+"=orderdelete&"+id+"="+zid;
   MCT_Show('SCH_O',path);
}
function SCH_Order_AccRec(zid)
{
   var act="act_"+SCH_Idx;
   var id="id_"+SCH_Idx;
   var path=SCH_BasePath+"&"+act+"=orderaccrec&"+id+"="+zid;
   MCT_Show('SCH_O',path);
}


///ROOT
function SCH_Adm()
{
    SCH_Hl.Init(SCH_Adm_BasePath,SCH_Adm_onInitialization,SCH_Adm_onSuccess);
    SCH_Hl.RefreshFunction();
}
var SCH_Hl=HTML_List();
//var SCH_Adm_BasePath;
function SCH_Adm_onInitialization()
{
   Uni_H() ;
   document.getElementById('UNI_title').innerHTML ='Zarządzanie zmówieniami';
   ShowBkEffect();
   document.getElementById('UNI_popup').style.display='block';
   document.getElementById('UNI_html').innerHTML=Wait_HTML(700,500);
}
function SCH_Adm_onSuccess(obj)
{
   document.getElementById('UNI_html').innerHTML=obj.responseText;

}
function SCH_Order_SS(stat,zid)
{
   var act="act_"+SCH_Idx;
   var id="id_"+SCH_Idx;
   var path=SCH_BasePath+"&"+act+"="+stat+"&"+id+"="+zid;
    advAJAX.get({
    url: path,
          onInitialization :SCH_Adm_onInitialization,
          onSuccess :SCH_Adm_onSuccess,
          onError : function(obj) { alert("Błąd" ); }
    });
}

function SCH_Order_Detail(zid)
{
   var act="act_"+SCH_Idx;
   var id="id_"+SCH_Idx;
   var path=SCH_BasePath+"&"+act+"=orderdetail&"+id+"="+zid;
  document.getElementById( "sel" +SCH_Idx ).style.display='none';
   advAJAX.get({
    url: path,
          onInitialization : function() {
            document.getElementById('UNI1_title').innerHTML="Szczegóły zamówienia";
            document.getElementById('UNI1_html').innerHTML=Wait_HTML(600,500);
            document.getElementById('UNI1_popup').style.display='block';
          },
          onSuccess : function(obj) {
                 document.getElementById('UNI1_html').innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd" ); }
    });
}

function SCH_AllPay(zid)
{
   var act="act_"+SCH_Idx;
   var id="id_"+SCH_Idx;
   var path=SCH_BasePath+"&"+act+"=allpay&"+id+"="+zid;

   advAJAX.get({
    url: path,
          onInitialization : function() {
            document.getElementById('USR_Register_popup_title').innerHTML="Płatności";
            document.getElementById('USR_Register_popup_html').innerHTML=Wait_HTML(500,200);
            document.getElementById('USR_Register_popup').style.display='block';
          },
          onSuccess : function(obj) {
                 document.getElementById('USR_Register_popup_html').innerHTML=obj.responseText;
            },
          onError : function(obj) { alert("Błąd" ); }
    });
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
 function trace(txt)
    {
        try
        {
           document.getElementById('debug').innerHTML+="<BR>"+txt;
        
        }catch(e){};
    }

function setshop_height()
{
  var obj=document.getElementById('Cont.c1_down')
  var t=findPos(obj);
  var h1=t[1];
   obj=document.getElementById('Cont.c4_down')
   t=findPos(obj);
  var h2=t[1];  
    obj=document.getElementById('Cont.c5_down')
   t=findPos(obj);
  var h3=t[1];  
  var h;
  if(h1>=h2 && h1>=h3)
      h=h1;
   if(h2>=h1 && h2>=h3)
      h=h2;
   if(h3>=h2 && h3>=h1)
      h=h3;
    h=h-80;
   document.getElementById('page').style.height=h+ "px"; 
}
function setshop_height_old()
{
		  var ch=document.getElementById('shopContent').clientHeight;
		  var ch2=document.getElementById('Cont.c6').clientHeight;
		  
		  var ar1=document.getElementById('Cont.c1_down').offsetTop
		  
		  if(ar1>250)
			document.getElementById('Cont.c1_down').style.height="2px";
		  else
			document.getElementById('Cont.c1_down').style.height=(250 - ar1)+"px";
		  
		  document.getElementById('shop').style.height=document.getElementById('shopContent').clientHeight+"px";
		  

    //      if(isMSIE7)
    //      {
			if( (ch+ch2+12) < ar1)
				document.getElementById('page').style.height=ar1 + "px";
			else
				document.getElementById('page').style.height=(ch+ch2+12)+"px";
    //      }
                  
          if( ar1 >  (document.getElementById('shopContent').offsetTop + document.getElementById('shopContent').style.height))
			document.getElementById('shopContent').style.height=(ar1-document.getElementById('shopContent').offsetTop)+"px";
          
          //alert(document.getElementById('Cont.c1').clientHeight);
          //alert(document.getElementById('Cont.c1_down').offsetTop);
         // a();
}

function PopUp_ShowImage(src,title)
{
  Uni_H() ;
  document.getElementById('UNI_html').innerHTML="<IMG alt='*' src='"+src+"'width=700 />"
  var PopUp=document.getElementById('UNI_popup');
  if(title)
   document.getElementById('UNI_title').innerHTML =title;
  else
   document.getElementById('UNI_title').innerHTML ="Powiększenie";	
  PopUp.style.display='block';
  
}

function MainPage()
{
		CAT_search="";
		CAT_Set_novelty()
		DSMP1_LoadContent(''); 
		ddtreemenu.flatten("treemenu1", 'contact');
		document.title="KALIGRAF";
		ZwinNow();
}

