/* **************************************** */
/*  ALIEN  redesigned Javascript functions  */
/*   Copyright 2009, ALIEN Consulting LLC.  */
/*                                          */
/* **************************************** */



/*
General notes:  change document.write tags to document.getElementById("dddd").innerHTML=
*/

/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
function sack(file) { this.xmlhttp = null; this.resetData = function() { this.method = "POST"; this.queryStringSeparator = "?"; this.argumentSeparator = "&"; this.URLString = ""; this.encodeURIString = true; this.execute = false; this.element = null; this.elementObj = null; this.requestFile = file; this.vars = new Object(); this.responseStatus = new Array(2);}; this.resetFunctions = function() { this.onLoading = function() { }; this.onLoaded = function() { }; this.onInteractive = function() { }; this.onCompletion = function() { }; this.onError = function() { }; this.onFail = function() { };}; this.reset = function() { this.resetFunctions(); this.resetData();}; this.createAJAX = function() { try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e1) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e2) { this.xmlhttp = null;}
}
if (! this.xmlhttp) { if (typeof XMLHttpRequest != "undefined") { this.xmlhttp = new XMLHttpRequest();} else { this.failed = true;}
}
}; this.setVar = function(name, value){ this.vars[name] = Array(value, false);}; this.encVar = function(name, value, returnvars) { if (true == returnvars) { return Array(encodeURIComponent(name), encodeURIComponent(value));} else { this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);}
}
this.processURLString = function(string, encode) { encoded = encodeURIComponent(this.argumentSeparator); regexp = new RegExp(this.argumentSeparator + "|" + encoded); varArray = string.split(regexp); for (i = 0; i < varArray.length; i++){ urlVars = varArray[i].split("="); if (true == encode){ this.encVar(urlVars[0], urlVars[1]);} else { this.setVar(urlVars[0], urlVars[1]);}
}
}
this.createURLString = function(urlstring) { if (this.encodeURIString && this.URLString.length) { this.processURLString(this.URLString, true);}
if (urlstring) { if (this.URLString.length) { this.URLString += this.argumentSeparator + urlstring;} else { this.URLString = urlstring;}
}
this.setVar("rndval", new Date().getTime()); urlstringtemp = new Array(); for (key in this.vars) { if (false == this.vars[key][1] && true == this.encodeURIString) { encoded = this.encVar(key, this.vars[key][0], true); delete this.vars[key]; this.vars[encoded[0]] = Array(encoded[1], true); key = encoded[0];}
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];}
if (urlstring){ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);} else { this.URLString += urlstringtemp.join(this.argumentSeparator);}
}
this.runResponse = function() { eval(this.response);}
this.runAJAX = function(urlstring) { if (this.failed) { this.onFail();} else { this.createURLString(urlstring); if (this.element) { this.elementObj = document.getElementById(this.element);}
if (this.xmlhttp) { var self = this; if (this.method == "GET") { totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString; this.xmlhttp.open(this.method, totalurlstring, true);} else { this.xmlhttp.open(this.method, this.requestFile, true); try { this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
}
this.xmlhttp.onreadystatechange = function() { switch (self.xmlhttp.readyState) { case 1:
self.onLoading(); break; case 2:
self.onLoaded(); break; case 3:
self.onInteractive(); break; case 4:
self.response = self.xmlhttp.responseText; self.responseXML = self.xmlhttp.responseXML; self.responseStatus[0] = self.xmlhttp.status; self.responseStatus[1] = self.xmlhttp.statusText; if (self.execute) { self.runResponse();}
if (self.elementObj) { elemNodeName = self.elementObj.nodeName; elemNodeName.toLowerCase(); if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") { self.elementObj.value = self.response;} else { self.elementObj.innerHTML = self.response;}
}
if (self.responseStatus[0] == "200") { self.onCompletion();} else { self.onError();}
self.URLString = ""; break;}
}; this.xmlhttp.send(this.URLString);}
}
}; this.reset(); this.createAJAX();}




/*        crossbrowser load function        */

/*  eg. addEvent(window, "load", function); */

function addEvent(elm, evType, fn, useCapture)

{
if (elm.addEventListener){
 elm.addEventListener(evType, fn, useCapture);
return true;
}
  else if (elm.attachEvent){
var r = elm.attachEvent("on"+evType, fn);
return r;
}
   else {
alert("Please upgrade your browser to use full functionality on this page");
}

}




/* ********************
	ACCESSIBILITY
  Set Global font size
  Change active stylesheet
  
  must: addEvent(window, "load", function(){AC_setActiveStyleSheet('basic');});


 **********************  */

var ACCESSIBILITY=
{
toggle: function()
 { var acs=this.getActiveStyleSheet();  var AC="off";
   if (acs=="acss"){this.setActiveStyleSheet("basic");}else{this.setActiveStyleSheet("acss");AC="on";}
   setCookie2("access_ck","acss:"+AC);
 },
setFontSize: function(DS)
{var a= document.getElementsByTagName("body");var FS=a[0].style.fontSize;if (FS==''){FS="85%";}
 var FSV=1*FS.substring(0,FS.length-1);
 if (!isNaN(FSV))
  {if (DS=="+"){FSV+=(FSV<300)?25:0;}
     else {if(DS=="-"){FSV-=(FSV>25)?25:0;}else{FSV=DS;}} 
     document.body.style.fontSize="5em"; //String(FSV)+"%";
    //document.body.style.zoom=String(FSV)+"%";
    // store in cookie
  }
},
setActiveStyleSheet: function(title)
{var a= document.getElementsByTagName("link");  // it's a must to define here
 for(var i=0;i<a.length; i++) {if(a[i].getAttribute("rel").indexOf("style") != -1 && a[i].getAttribute("title"))
   {a[i].disabled = true;
      a[i].disabled = (a[i].getAttribute("title") != title);}}
},
getActiveStyleSheet: function()
{ var a= document.getElementsByTagName("link");  // it's a must to define here
 for(var i=0;i<a.length; i++) {
    if(a[i].getAttribute("rel").indexOf("style") != -1 && !a[i].disabled) return a[i].getAttribute("title");
  }
},
setOpenState:function()
 {var ck=getCookie2("access_ck");
  if (ck)
   {if(ck.indexOf("acss:on")>-1){ACCESSIBILITY.setActiveStyleSheet("acss");}
    // font size
   }
 }
} //AC_setActiveStyleSheet('basic');
addEvent(window, "load", ACCESSIBILITY.setOpenState);



/* ********************
        MARQUEE

 ********************** */
var marqContainer=new Array();marqScroller=new Array();
function ConstructMarquee(obj,nest)
{nest_orig=nest; nest=(!nest) ? '':'document.'+nest+'.';
this.el=document.getElementById(obj);
this.css=document.getElementById(obj).style;
this.scrollHeight=this.el.offsetHeight;
this.clipHeight=this.el.offsetHeight;
this.down=MoveAreaDown;
this.timer=null;this.initialised=null;
this.p_clipHeight;
if (nest_orig){this.p_clipHeight=marqContainer[nest_orig].clipHeight;}
this.MoveArea=MoveArea; this.x; this.y;
this.obj = obj + "Object";
eval(this.obj + "=this");
return this;
}
function MoveArea(x,y){this.x=x;this.y=y; this.css.left=this.x; this.css.top=this.y + 'px';}
function MoveAreaDown(move){if(this.y>-this.scrollHeight){this.MoveArea(0,this.y-move);}else{this.MoveArea(0,this.p_clipHeight);}}
function MoveAreaDown(move)
{clearTimeout(this.timer);if(this.y>-this.scrollHeight){this.MoveArea(0,this.y-move);this.timer=setTimeout(this.obj+".down("+move+")",this.speed);}else{this.MoveArea(0,this.p_clipHeight);this.timer=setTimeout(this.obj+".down("+move+")",this.speed);}}
function startScroll(xcontainer,xcontent,step)
{if(!marqScroller[xcontainer]){InitialiseScrollableArea(xcontainer,xcontent);}
 if(marqScroller[xcontainer].initialised){marqScroller[xcontainer].down(step);}
}
function stopScroll(xcontainer){if(marqScroller[xcontainer].timer)clearTimeout(marqScroller[xcontainer].timer);} 
function InitialiseScrollableArea(xcontainer,xcontent)
{el=document.getElementById(xcontainer);
if (el!=null)
{marqContainer[xcontainer]=new ConstructMarquee(xcontainer);
marqContainer[xcontainer].css.visibility='visible';
marqScroller[xcontainer]=new ConstructMarquee(xcontent,xcontainer);
marqScroller[xcontainer].MoveArea(0,0);
marqScroller[xcontainer].speed=15;
marqScroller[xcontainer].timer=null; 
marqScroller[xcontainer].initialised=true; 
}}


/* *********************
   advanced search abdb. 
   need templates & def.
   ********************* */

function changeFLD(fieldN,opersN,valsN,CNTR)
{var ss=getHTMLVar(fieldN);
var otype= hDef[ss].optype; 
var vtype= hDef[ss].valtype;
var oldVAL=getHTMLVar("op_"+CNTR);
var tmX=getHTMLVar("optype"+otype);
tmX=tmX.replace(eval("/optype"+otype+"X/g"), "op_"+CNTR);
setHTMLVar(opersN,tmX);setHTMLVar("op_"+CNTR,oldVAL);
oldVAL=getHTMLVar("val_"+CNTR);
tmX=getHTMLVar("valtype"+vtype);tmX=tmX.replace(eval("/valtype"+vtype+"X/g"),"val_"+CNTR);setHTMLVar(valsN,tmX);
setHTMLVar("val_"+CNTR,oldVAL);
}


function decodeSQL(typeN,TSEQ)
{ var CNS="abcdefghijklmnopqrstuvwzxyABCDEFGHIJKLMNOPQRSTUVWZXY_0123456789.";
  TSEQ=ox64decode(TSEQ);
for(var o in hDef){
if(hDef[o].dbseq!=null)
 {var x1=hDef[o].dbseq;var px=x1.indexOf("[TAG]");var x1a=x1.substring(0,px);
  var tmpR=TSEQ.split(x1a);
  if(tmpR.length>1){TSEQ=tmpR.join("and");}
 }
}
  var ME=TSEQ.split("and");
  for (var j=1;j<ME.length;j++)  // 1-tol indul, mert az elso tetel ures a kezdeti and miatt
   {var ME2=ME[j].split(")or(");
    var MES=ME2[0];
    var pzf0=1;
    var pzf=1;// (-vel kezdodik
    if(ME2.length>1){MES=ME2[1];pzf0=0;pzf=0;}
    while((pzf<MES.length)&&(CNS.indexOf(MES.charAt(pzf))>-1)){pzf++;}
    var FLN=MES.substring(pzf0,pzf);
    if(ME2.length>1){FLN="fulltext";}  //present of or indicates fulltext
    var pza=MES.indexOf("'",pzf);  // mindent '-olnunk kell emiatt
    var OPN=MES.substring(pzf,pza);
    var pzb=MES.lastIndexOf("'");
    var VAL=MES.substring(pza+1,pzb);
    VAL=VAL.replace(/''/g,"'");
    var DCD="[f]"+OPN+"'"+((VAL.charAt(0)=="%")?"%":"")+"[v]"+((VAL.charAt(VAL.length-1)=="%")?"%":"")+"'";
    VAL=VAL.substring((VAL.charAt(0)=="%")?1:0,(VAL.charAt(VAL.length-1)=="%")?(VAL.length-1):VAL.length);
    var cj=addRepeatedField('qTemplate', 'q');
    setHTMLVar("dbfield_"+cj,hDef2[FLN]);
    changeFLD("dbfield_"+cj,'opers_'+cj,'vals_'+cj,cj);
    setHTMLVar("op_"+cj,DCD);
    setHTMLVar("val_"+cj,VAL);
   }
}
function codeSQL(typeN)
{var mxn=counters[typeN];
var FIN="";
for (var i=1;i<=mxn;i++)
{var FLN=getHTMLVar("dbfield_"+i,null);
if(FLN!=null) //process
 {var tmA=(hDef[FLN].dbfield).split(",");
  var tFLN="";
  for (var i2=0;i2<tmA.length;i2++)
   { var OPN=getHTMLVar("op_"+i); var VAL=trim(getHTMLVar("val_"+i)); OPN=OPN.replace("[f]",tmA[i2]); //hDef[FLN].dbfield  
     VAL=VAL.replace(/'/g,"''");
     tFLN+=((i2>0)?"or(":"(")+OPN.replace("[v]",VAL)+")";
   }
  var DBS=hDef[FLN].dbseq;
 if(DBS!=null){FIN=FIN+DBS.replace("[TAG]",tFLN);}
   else {if (tmA.length>1){FIN=FIN+"and("+tFLN+")";}else{FIN=FIN+"and"+tFLN;}}
 }
}
return ox64encode(FIN);
}

function decodeFLD(fldN){var pz=fldN.indexOf(".");return((pz>-1)?fldN.substring(pz+1,fldN.length):fldN)}

function fillUpSelect(SelID)
{var sO=document.getElementById(SelID);sO.options.length=0;var ci=0;
for (var j in hDef){sO.options[ci]=new Option(hDef[j].label,j);hDef2[hDef[j].dbfield]=j;ci++;}
}

function setupFRM(boxID,rpp,list)
{fillUpSelect("dbfield_COUNTER");
setHTMLVar("rpp"+boxID,rpp);
setHTMLVar("list"+boxID,list);
var b64c=getHTMLVar("b64sql"+boxID);
if(b64c.length>1){decodeSQL("q",b64c);}else{addRepeatedField('qTemplate','q');}
}



/* *********************
       alienSELECT 
     used in dakstra
   ********************* */

function alienSELECT(selfName,extFUNC,DDnameX,DDtextX,DDlistX)
 {var inV=new Array(); var inT=new Array(); this.extFUNC=extFUNC;
  var DDname="dropdn"; var DDtext="ddtext"; var DDlist="ddlist"; var selfNAME=selfName;
  if(DDnameX){this.DDname=DDnameX;}
  if(DDtextX){this.DDtext=DDtextX;}
  if(DDlistX){this.DDlist=DDlistX;}
  function addItem(xval,xtext){inV.push(xval);inT.push(xtext);}
  function showSelect(loc,iniPos,iniVAL)
   {var SS="<div id='"+DDname+"' onclick='javascript:"+selfNAME+".sdropdown(2)'><div id='"+DDtext+"'></div><div id='"+DDlist+"' style='display:none;' onmouseover='javascript:"+selfNAME+".sdropdown(1)' onmouseout='javascript:"+selfNAME+".sdropdown(0)'><ul>";
    for (var j=0;j<inV.length;j++)
	{SS+="<li onclick=\"javascript:"+selfNAME+".clicked('"+j+"');\" onmouseover=\"this.className='hvr'\" onmouseout=\"this.className='nhvr'\">"+inT[j]+"</li>";
	 if (iniVAL){if(iniVAL==inV[j]){iniPos=j;}}
	}
    document.getElementById(loc).innerHTML=SS;
    if(iniPos!=null){document.getElementById(DDtext).innerHTML=inT[iniPos];}
   }
  function clicked(j){document.getElementById(DDtext).innerHTML=inT[j];this.extFUNC(inV[j]);}
  function sdropdown(type)
  {var dvl="none";if(type=="1"){dvl="block";} else if(type=="2") if(document.getElementById(DDlist).style.display=="none"){dvl="block";}
   document.getElementById(DDlist).style.display=dvl;
  }
  this.addItem=addItem; this.showSelect=showSelect; this.sdropdown=sdropdown; this.clicked=clicked;
}



/* ********************
  Photo display fenstro
 ********************** */
function photoClick(selfVAR,linkHolder,imgHolder,imgHolderCode,linkbaseimg,linkoverimg,popups)
{this.popups=popups;
 this.selfVAR=selfVAR;
 this.linkHolder=linkHolder;
 this.imgHolder=imgHolder;
 this.linkbaseimg=linkbaseimg;
 this.linkoverimg=linkoverimg;
 this.imgHCode=imgHolderCode;   // "<img src='"+popups[i]+"' vspace='0' hspace='0' align='right' alt=''/>"

 var prevP="";
var s0="";
for (var i=0;i<popups.length;i++){s0+="<span id='ppu"+i+"' onclick='javascript:"+selfVAR+".clckp("+i+")'><img src='"+linkbaseimg+"' alt='' vspace='0' hspace='0' border='0' /></span>";}
setHTMLVar(linkHolder,s0);
function clckp(i)
{document.getElementById(imgHolder).innerHTML=this.imgHCode.replace(/FILE/g, popups[i]);
 if (prevP!=""){ document.getElementById("ppu"+prevP).innerHTML="<img src='"+linkbaseimg+"' alt='' vspace='0' hspace='0' border='0' />";}
 document.getElementById("ppu"+i).innerHTML="<img src='"+linkoverimg+"' alt='' vspace='0' hspace='0' border='0' />";
 prevP=""+i;
}
this.clckp=clckp;
}


/* ********************
       AJAX OWN
 ********************** */
function GetXmlHttpObject() {var xmlHttp=null; try{xmlHttp=new XMLHttpRequest();} catch (e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
if(xmlHttp==null)alert ("Your browser does not support AJAX!"); return xmlHttp;}
function showMSGBox(id,msg,className)
{var XEL=document.getElementById(id);XEL.innerHTML="<div align=\"right\"><a href=\"javascript:closeMSGBox('"+id+"')\"><b><font size='1'>X</font></b></a>&nbsp;</div>"+msg;
XEL.style.display="block";   // xELM.style.top="90px";// xELM.style.bottom="90px";xELM.style.left="90px";xELM.style.right="90px"; //xELM.style.width="90%";xELM.style.height="600px";xELM.style.margin="auto";
if (className)XEL.className=className;
}
function closeMSGBox(id){document.getElementById(id).style.display ="none";}

function ajaxHELP(pgurl,dispPanel)
{if (jumppoint.length>0){pgurl+="#"+jumppoint;}
  window.open(pgurl,"","width=500,height=300,right=10,resizable=1,fullscreen=0,scrollbars=1,address=0");
}


// OXCHECK ???
//dispTag=1:show,=0:hide, null:toggle
function xSH(ID,dispTag)
{var spI=document.getElementById(ID);
 if(spI)
  {if (!dispTag){var dispTag="none";if(spI.style.display=="none")dispTag="block";}
   spI.style.display=dispTag;
  }
}

function CHANGEr(inS,oldv,newv)
{var pz0=0; var newvl=newv.length; var outS="";
 var pz1=inS.indexOf(oldv,pz0);
 while(pz1>-1)
  {if(inS.substring(pz1,pz1+newvl)!=newv){inS=inS.substring(0,pz1)+newv+inS.substring(pz1+1,inS.length); pz0=pz1+newvl;}
	else{pz0=pz1+newvl;}
    pz1=inS.indexOf(oldv,pz0);
  }
return inS;
}
// **********************************






/* ***********************
  BASIC DATA MANIPULATION

 ************************* */

function getHTMLVar(varName,errRetVal)
{var element = document.getElementById(varName);
if (element==null){var a1=document.getElementsByName(varName);if (a1==null){return errRetVal;} if(a1.length<1){return errRetVal;} element=a1[0];}
var res= "";
if(element.type)
switch(element.type){
case "checkbox": if(element.checked)res=element.value;break;
case "radio":var a1=document.getElementsByName(varName);for(var ii=0;ii<a1.length;ii++){if(a1[ii].checked)res=a1[ii].value;};break;
case "select-one":var si=element.selectedIndex;res=element.options[si].value;break;
case "select-multiple":for(var jj=0;jj<element.options.length;jj++){if(element.options[jj].selected)res+=element.options[jj].value+",";};break;
default:res=element.value;break;}
else{res=element.innerHTML;}
return res;
}

function setHTMLVar(varName,Value)
{var element = document.getElementById(varName);
if (element==null)
 {var a1=document.getElementsByName(varName); if (a1==null){return false;} 
  if(a1.length<1){return false;} element=a1[0];
 }
var ii=0;
if(element.type)
switch(element.type){
case "checkbox": if(element.value==Value){element.checked=true;};break;
case "radio":var a1=document.getElementsByName(varName);for(ii=0;ii<a1.length;ii++) {if(a1[ii].value==Value){a1[ii].checked=true;}}break;
case "select-one":for(ii=0;ii<element.options.length;ii++){if(element.options[ii].value==Value){element.selectedIndex=ii;}}break;
case "select-multiple":for(ii=0;ii<element.options.length;ii++){element.options[ii].selected=((Value.indexOf(element.options[ii].value)>-1)&&(element.options[ii].value.length>0));}break;
default:element.value=Value;break;}
else{element.innerHTML=Value;}
return true;
}



/* disable/enable html elements */
/* ---------------------------- */
function disableELEMENTS(elementIDS,disAble)
{var DE=elementIDS.split(",");
 for (var j=0;j<DE.length;j++){document.getElementById(DE[j]).disabled=disAble;}
}



/* removes paramater from location */
/* ------------------------------- */
function removePAR(txtFROM,txtPAR)
{var pz1=txtFROM.indexOf("&"+txtPAR);if (pz1<0){pz1=txtFROM.indexOf("?"+txtPAR);}
if (pz1>-1)
{pz1++; var pz2=txtFROM.indexOf("&",pz1);if (pz2<0){pz2=txtFROM.length;}
if(txtFROM.substring(pz1-1,pz1)=="?"){txtFROM=txtFROM.substring(0,pz1)+txtFROM.substring(pz2+1,txtFROM.length);}else{txtFROM=txtFROM.substring(0,pz1-1)+txtFROM.substring(pz2,txtFROM.length);}
}
return txtFROM;
}


/* String functions */
/* ---------------- */
function ltrim(xval){var il=xval.length;if (il>0){var cc=0;while((cc<il)&&(xval.charAt(cc)==" ")){cc++;}if (cc>0){xval=xval.substring(cc,xval.length);}}return xval;}
function rtrim(xval){var il=xval.length;if (il>0){il--;var cc=il;while((cc>-1)&&(xval.charAt(cc)==" ")){cc--;}if (cc>-1){xval=xval.substring(0,cc+1);}else{xval="";}}return xval;}
function trim(xval){return ltrim(rtrim(xval));}
function isEmpty(xval,minlen){if (minlen==null){minlen=1;} var result=false;xval=trim(xval);if (xval.length<minlen){result=true;}return result;}


/* Number functions */
/* ---------------- */

/* converts numbers to given decimal format */
function convNum(xnum,decplace){var kit=Math.pow(10,decplace);xnum=Math.round(xnum*kit);xnum=xnum/kit;var res=""+xnum;
var inn=res.indexOf(".");if (inn<0){ inn=res.length; res+=".0000000000";} else {res+="0000000000";}
res=res.substring(0,inn+decplace+1);return res;}


/* reFactored UNIPortal */

function writeProtect(cpc,lcode){var pcds_0="everybody";var pcds_1="registered users";var pcds_2="certfied users";return eval("pcds_"+cpc);}
function ow(trgs,ww,hh,target){if(target==null){target="Info";}if(target==""){document.location.href=trgs;}else{var p1=((ww!=null)?"width="+ww+",":"")+((hh!=null)?"height="+hh+",":"")+"resizable=1,fullscreen=0,scrollbars=1,address=1";window.open(trgs,target,p1);}}
function setSelectByText(xObj,selText){var maxI=xObj.length;var ii=0;while(ii<maxI){ var xtemp=xObj.options[ii].text;if (xtemp==selText) {xObj.selectedIndex=ii; ii=maxI;}ii++;}}



function changeLanguageTo(langcode)
{var tmpx=""+document.location;
if (tmpx.indexOf("language_code=")>-1){tmpx=removePAR(tmpx,"language_code=");document.location=tmpx+"&language_code="+langcode;}
else{document.location="/alienPORT.al"+_jsessionid+"?ewcateg0=1&language_code="+langcode+"&shopid=rooflite";}
}

/*  LOGIN/LOGOUT/REGISTER  */
function alienLOGIN(UNAME,UPW,EXTCTG,AUTOL,tDomain,storey)
{if(!tDomain){tDomain="";}if(!storey){storey="";}else{storey="&storey="+encodeURIComponent(storey);}if(AUTOL!=null){if (AUTOL.checked){AUTOL="&autologin=1"}else{AUTOL="&autologin=0";}}else{AUTOL="";};
document.location=tDomain+"/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=89&ewtarget0=0a&log_username="+UNAME+"&log_password="+UPW+"&extctg="+EXTCTG+AUTOL+storey;
return false;
}
function alienLOGINkeep(UNAME,UPW,EXTCTG,AUTOL,tDomain,boxid)
{if(!tDomain){tDomain="";}if(AUTOL!=null){if (AUTOL.checked){AUTOL="&autologin=1"}else{AUTOL="&autologin=0";}}else{AUTOL="";};
var storey="";EXTCTG=trim(EXTCTG);
if(EXTCTG.length<1)
{var tmp=""+document.location;var pz=tmp.indexOf("?");
if(pz>-1){storey=tmp.substring(pz+1,tmp.length);storey=removePAR(removePAR(storey,"shopid="),"language_code=");}else{storey="ewtarget0="+getHTMLVar("ewtarget0")+" &ewassoc0="+getHTMLVar("ewassoc0")+" &ewcateg0="+getHTMLVar("ewcateg0")+" &ewitem0="+getHTMLVar("ewitem0")+" ";}
storey="&storey="+encodeURIComponent(storey);
}
document.location=tDomain+"/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=89&ewtarget0=0a&log_username="+UNAME+"&log_password="+UPW+"&extctg="+EXTCTG+AUTOL+storey;
return false;
}

function sendRegister(){_loadREGPAGE("0");}
function _loadREGPAGE(boxid)
{if(!boxid){boxid="0";}
var storey=getHTMLVar("storey"+boxid);
if(storey.length<5)
{var tmp=""+document.location;var pz=tmp.indexOf("?");
if(pz>-1){storey=tmp.substring(pz+1,tmp.length);storey=removePAR(removePAR(storey,"shopid="),"language_code=");}else{storey="ewtarget0="+getHTMLVar("ewtarget0")+" &ewassoc0="+getHTMLVar("ewassoc0")+" &ewcateg0="+getHTMLVar("ewcateg0")+" &ewitem0="+getHTMLVar("ewitem0")+" ";}
}
storey="&storey="+encodeURIComponent(storey);
document.location="/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=87&ewtarget0=0"+storey;
}

//orig: function _loadREGPAGE(){_formOBJ=document.dm01;_formOBJ.storey.value="ewtarget0="+_formOBJ.ewtarget0.value+" &ewassoc0="+_formOBJ.ewassoc0.value+" &ewcateg0="+_formOBJ.ewcateg0.value+" ";_formOBJ.ewassoc0.value="87";_formOBJ.ewtarget0.value="0";_formOBJ.updsql0.value="";_formOBJ.ewcateg0.value="";_formOBJ.ewitem0.value="";_formOBJ.submit();}
function _saveREG(){_formOBJ=document.dm01;_formOBJ.ewassoc0.value="86";_formOBJ.ewtarget0.value="0g";_formOBJ.ewitem0.value="";_formOBJ.submit();}
function _userPROFIL(tDomain){if(!tDomain){tDomain="";}document.location=tDomain+"/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=86";}



/* search/sub/unsub */

function _newSearch(hftxt,loc1,tDomain)
{if(!tDomain){tDomain="";}var strg="a";if (loc1!=null){strg=getHTMLVar(loc1);};document.location=tDomain+"/alienPORT.al"+_jsessionid+"?ewassoc0=99&ewtarget0=0"+strg+"&shopid=rooflite&language_code=en&hftxt="+encodeURIComponent(hftxt);return false;}

function alienSUBUNSUB(epubID,uemail,userName,subunsub,tDomain)
{if(!tDomain){tDomain="";}
if (uemail.length<1){return;}
var xtrg="a";if (subunsub=="0"){xtrg="b";}
var ntrg=tDomain+"/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=75&ewtarget0=0"+xtrg+"&epublishcode="+epubID+"&useremail="+encodeURIComponent(uemail);
document.location=ntrg;
return false;
}



/* uniportal ends */








function _newSearch(hftxt,loc1,tDomain)
{if(!tDomain){tDomain="";}var strg="a";if (loc1!=null){strg=getHTMLVar(loc1);};document.location=tDomain+"/alienPORT.al"+_jsessionid+"?ewassoc0=99&ewtarget0=0"+strg+"&shopid=rooflite&language_code=en&hftxt="+hftxt;return false;}

function goGALL(gid){document.location="/alienPORT.al"+_jsessionid+"?gid0="+gid+"&ewassoc0=86&ewtarget0=0h4&shopid=rooflite&language_code=en";}
function addGALLITEM(gid){document.location="/alienPORT.al"+_jsessionid+"?gid0="+gid+"&ewassoc0=86&ewtarget0=0h5&shopid=rooflite&language_code=en";}
function modGALLITEM(id){document.location="/alienPORT.al"+_jsessionid+"?id0="+id+"&ewassoc0=86&ewtarget0=0h7&shopid=rooflite&language_code=en";}
function delGALLITEM(id){document.location="/alienPORT.al"+_jsessionid+"?ewassoc0=86&ewtarget0=0h5&shopid=rooflite&language_code=en";}
function startFPW(uname,uemail){document.location="/alienPORT.al"+_jsessionid+"?ewassoc0=89&ewtarget0=0c&shopid=rooflite&language_code=en&uname="+escape(uname)+"&uemail="+escape(uemail);}
function showReviews(nid)
{var tmpx=""+document.location;if (tmpx.indexOf("ewtarget83=")>-1){tmpx=removePAR(tmpx,"ewtarget83=");}
 var JPP=""; var pt=tmpx.indexOf("#");if (pt>0){JPP=tmpx.substring(pt,tmpx.length);tmpx=tmpx.substring(0,pt);}else{JPP="#rev01";}
document.location.replace(tmpx+"&ewtarget83=83d&aid="+nid+JPP);
}


function sendLICIT(NID,boxID)
{var newLV=eval("document.dm01.licit"+NID+".value");
var rloc=""+document.location;rloc=removePAR(rloc,"ewtarget"+boxID+"=");
if (rloc.indexOf("language_code=")<0){rloc="/alienPORT.al"+_jsessionid+"?ewcateg0=1&language_code=en&shopid=rooflite";}
rloc+="&licitid"+boxID+"="+NID+"&ewtarget"+boxID+"="+boxID+"f&licit"+boxID+"="+newLV;
document.location.replace(rloc);
}


function writeIfNotEmpty(par1,par2){if (par1.length>0){document.write(par2);}}
function writeIfEnabled(enabled,xtext1,xtext2){if (enabled.length>0) {document.write(xtext1);}else {document.write(xtext2);}}

function isImageExists5(imgCode,alt,align,vspace,hspace,imgPreURL,imgLEAD,styl)
{if (styl==null){styl="";}if (imgLEAD.length>2){document.write("<img src='"+imgPreURL+imgLEAD+"' ALT='"+alt+"' border=0 hspace="+hspace+" vspace="+vspace+" align="+align+" "+styl+"/>");}
  else{if (imgCode.length>2){document.write("<img src='"+imgPreURL+imgCode+"' ALT='"+alt+"' border=0 hspace="+hspace+" vspace="+vspace+" align="+align+" "+styl+"/>");}
      }
}

function isDownload2(dlFile,xID,xSHOPID,xlangcode){if(dlFile.length>2){var outs="";outs="<a href='/ew_catdownload.al?id="+xID+"&shopid="+xSHOPID+"&playtype=m' target='_blank'><b><font size=1 color=red>VIEW</font></b></a> &nbsp;&nbsp;";outs+="<a href='/ew_catdownload.al?id="+xID+"&shopid="+xSHOPID+"&playtype=d'><b><font size=1 color=red>DOWNLOAD</font></b></a>";document.write(outs);}}
function cutDecoder(instr){var pz=instr.indexOf(":");if (pz>-1){instr=instr.substring(pz+1,instr.length);}return instr;}




/* ***********************
    eBusiness extensions

 ************************* */

/* product to cart */
/* --------------- */
// ide bele kell venni a source paramot, ha mas db-bol jonne a cucc
function selectorMOD2(boxid,jtxindex,formobjname,shopid,shoptitle,id,id2,authtitle,price,amount,vat,lang,i_me,current_amount,xdiscrule,userdisc)
{var udisc=parseFloat(userdisc);if (isNaN(udisc)){udisc=0;}
var dscappl=0; var tp=xdiscrule.indexOf(":"); 
if(tp>-1){dscappl=xdiscrule;}else if(udisc>0){dscappl=udisc;}
authtitle=getHTMLVar("creator"+boxid+jtxindex);if (authtitle.length>1){authtitle+=" ";}
authtitle+=getHTMLVar("title"+boxid+jtxindex);shoptitle+=getHTMLVar("shoptitle");
addc3a(shopid,shoptitle,id,id2,authtitle,price,amount,vat,dscappl,lang,i_me,current_amount,shopid+"_cart");
reFRESH2();
}



/*  calculating  price from net price+vat+discount    change to ajax ??? */
function getPrice(xpriceS,xvatS,xcurr,xdiscrule,userdiscount)
{var outSTR="";var xprice=parseFloat(xpriceS);if (isNaN(xprice)){xprice=0;}
if(!userdiscount){userdiscount="0";}
var udisc=parseFloat(userdiscount);if (isNaN(udisc)){udisc=0;}
var xvat=parseFloat(xvatS);if (isNaN(xvat)){xvat=0;}if (xvat==0){xvat=20;}
var dscappl=0;
var tp=xdiscrule.indexOf(";1:");
if(tp>-1)
{var tp2=xdiscrule.indexOf(";",tp+2);if(tp2<0){tp2=xdiscrule.length;}
dscappl=parseFloat(xdiscrule.substring(tp+3,tp2));if (isNaN(dscappl)){dscappl=0;}
}
else if(udisc>0){dscappl=udisc;}
var xbrutprice=xprice+Math.round(xprice*xvat/100);
var aprice="";  var bprice="";
if(dscappl>0){aprice="<b>&nbsp;&nbsp; "+Math.round(xbrutprice-(xbrutprice*dscappl/100))+"</b>";bprice="<strike>"+xbrutprice+"</strike>";}
else{bprice="<b>"+xbrutprice+"</b>";}
outSTR="<b>PRICE:</b> "+bprice+" "+aprice+" <b>"+xcurr+"</b>";
if (dscappl>0){outSTR+="<font color=red><b> !</b></font>";}
return outSTR;}


/*  get Discount */
function getDISC(disc,xme)
{var outs="";cdisc+="; ";var pp1=disc.indexOf(";");
if(pp1<-1){return disc;}
while (pp1>-1){var tmp1=disc.substring(0,pp1);disc=disc.substring(pp1+1,disc.length);var pp2=tmp1.indexOf(":");
if (pp2>-1){var cce=tmp1.substring(0,pp2);tmp1=tmp1.substring(pp2+1,tmp1.length);var ncce=parseFloat(cce);outs+=ncce+" "+xme+"-tól -"+tmp1+" &nbsp;&nbsp; ";}
pp1=disc.indexOf(";");}return outs;}


/*  get Discount type-2 */
/*  ------------------- */
function getDISC2(disc,xme)
{var outs="";var pp1=disc.indexOf(";");var lDISC=0;var preAM=0;var nxme=parseFloat(xme);
if(pp1<0){return disc;}
while (pp1>-1){var tmp1=disc.substring(0,pp1);disc=disc.substring(pp1+1,disc.length);var pp2=tmp1.indexOf(":");
if (pp2>-1){var cAM=parseFloat(tmp1.substring(0,pp2));tmp1=tmp1.substring(pp2+1,tmp1.length);
var ncAM=parseFloat(cAM);if(ncAM<=nxme){if(preAM<ncAM){lDISC=parseFloat(tmp1);preAM=ncAM;}}}
pp1=disc.indexOf(";");}return lDISC;}






/*  ??? */
function _viewCart(xObj){document.location="/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=77";}

/* gives back a cookie value */
/* ------------------------- */
function getCookie2(name){var prefix = name + "="; var cSI = document.cookie.indexOf(prefix);if (cSI==-1) return null;
var cEI= document.cookie.indexOf(";", cSI + prefix.length); if (cEI==-1) cEI=document.cookie.length;
return unescape(document.cookie.substring(cSI+prefix.length,cEI));}




/* -------------------------------- */



// ???



function dummy1(){return false;}
function _startSearch(ftxt,xtarget,BGIMG,lngC,ord1)
{var xObj=document.dm01;var xsql="select A.*,B.hiercode,B.title as btitle from vtext A,vcateg B where (A.shopid='rooflite')and(A.language_code='"+lngC+"')and(A.main_categ=B.categcode)and(B.language_code='"+lngC+"')and(B.shopid='rooflite')";
if (ftxt.length>0){xsql+="and((A.title like'%"+ftxt+"%')or(A.vtext like'%"+ftxt+"%')or(A.summary like'%"+ftxt+"%')or(A.subject like'%"+ftxt+"%'))";}
xObj.updsql0.value=xsql;xObj.firstkey0.value=0;xObj.ewcateg0.value="";xObj.ewassoc0.value="99";xObj.ewtarget0.value="0a";xObj.ewitem0.value="";xObj.submit();}







function newDownload(dlFile,xID){var outs=" <a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=m' target='_blank'><b><font size=1>VIEW</font></b></a> ";outs+="<a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=d'><b><font size=1>DOWNLOAD</font></b></a>";return outs;}





function startNewTheme(_fObj,forumID,firstkey,boxID){_fObj.ewtarget0.value="0d";_fObj.ewassoc0.value="93";_fObj.submit();}
function authorThis(itemid,pcard){var trg="/ew_showusers.al?itemid="+itemid+"&pcard="+pcard+"&template=userdata_en.html&bgimage=<#BGIMAGE>";ow(trg,400,200);}
function answerThis(_fObj,ownID,baseID,categ,boxID){_fObj.ewtarget0.value="0e";_fObj.ewassoc0.value="93";_fObj.forumbaseid0.value=baseID;_fObj.forumitemid0.value=ownID;_fObj.submit();}
function sendGuestBook(_formOBJ){_formOBJ.ewtarget0.value="0b"; _formOBJ.ewassoc0.value="91"; _formOBJ.submit();}
function sendForum(_formOBJ){ _formOBJ.submit();}

function sendFORM(){_formOBJ=document.dm01;_formOBJ.ewassoc0.value="95";_formOBJ.ewtarget0.value="0b";_formOBJ.ewitem0.value="";_formOBJ.submit();}

function sendLOGIN(UNAME,UPW){document.location.replace("/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=89&ewtarget0=0a&log_username="+UNAME+"&log_password="+UPW);}
function _sendLOGIN2(UNAME,UPW,EXTCTG,AUTOL,tDomain){if(!tDomain){tDomain="";}if(AUTOL!=null){if (AUTOL.checked){AUTOL="&autologin=1"}else{AUTOL="&autologin=0";}}else{AUTOL="";};
document.location=tDomain+"/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc0=89&ewtarget0=0a&log_username="+UNAME+"&log_password="+UPW+"&extctg="+EXTCTG+AUTOL;}

function _sendLOGIN(UNAME,UPW){_formOBJ=document.dm01;_formOBJ.storey.value="ewtarget0="+_formOBJ.ewtarget0.value+" &ewassoc0="+_formOBJ.ewassoc0.value+" &ewcateg0="+_formOBJ.ewcateg0.value+" ";_formOBJ.ewtarget0.value="0a";_formOBJ.ewassoc0.value="89";_formOBJ.ewcateg0.value="";_formOBJ.submit();}
function _sendLOGOUT(tDomain){if(!tDomain){tDomain="";}document.location="/ns_logout.al?callnext="+escape("/alienPORT.al?ewcateg0=1&language_code=en&shopid=rooflite");}

function sendCard(_formOBJ,eml1,eml2){if (isEmpty(eml1,3)||isEmpty(eml2,3)){alert("Kérjük, töltse ki mindkét email címet!");}
   else{_formOBJ.ewtarget0.value="0b";_formOBJ.submit();}
}
function goUSERPAGE(ewtarget,boxID,cstatus){document.location="/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewassoc"+boxID+"=86&ewtarget"+boxID+"="+ewtarget+cstatus;}

function sendReview2(_formOBJ,boxID)
{eval("_formOBJ.ewtarget"+boxID+".value='"+boxID+"e'");_formOBJ.ewtarget0.value='0d';
/*var itemID=_formOBJ.ewitem0.value; eval("_formOBJ.ewitem"+boxID+".value=itemID");*/
_formOBJ.submit();
}


function backSTEP2(boxid,formOBJ){var x_id=eval("formOBJ.ewitem"+boxid+".value");var srcb=document.dm01.srcback.value;if(srcb.length>0){document.location="/alienPORT.al"+_jsessionid+"?ewassoc0=99&ewtarget0=0a&shopid=rooflite&language_code=en&updsql0="+escape(srcb);}else{goD(x_id);}}
function _sendAPRO(_formOBJ){_formOBJ.ewtarget0.value="0b"; _formOBJ.ewassoc0.value="71"; _formOBJ.submit();}
function _loadAPRO(_formOBJ){_formOBJ.ewtarget0.value="0a"; _formOBJ.ewassoc0.value="71";_formOBJ.ewcateg0.value=""; _formOBJ.submit();}



function checkCookieEnabled2(){var curCookie= "test_cookie=Denebola";document.cookie=curCookie;var cSI = document.cookie.indexOf("test_cookie=");if (cSI<0){return false;}document.cookie = "test_cookie=" +"; expires=Thu, 01-Jan-70 00:00:01 GMT";return true;}
function setCookie2(name, value){var curCookie = name + "=" + escape(value);document.cookie = curCookie;}

function reFRESH2(formOBJname){if(formOBJname==null){formOBJ=document.dm01;}else{eval("formOBJ="+formOBJname);}var lcc=document.location;var lca=""+lcc;var pz=lca.indexOf("?");if (pz>0) {eval('document.location="'+lcc+'"');}else {formOBJ.submit();}}
function SHOWHIDE(id,docobj) {if(docobj){var spI=docobj.getElementById(id);}else{var spI=document.getElementById(id);}
 if(spI.className=="genHIDENO"){spI.className="genHIDE";}else{spI.className="genHIDENO";}}
function SHOWHIDE_D(id,stype,docobj) {if(docobj){var spI=docobj.getElementById(id);}else{var spI=document.getElementById(id);}
 if(spI.style.display=="none"){spI.style.display=((stype)?stype:"block");}else{spI.style.display="none";}}


//backward comp.
function goC(xc_id){document.location="/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewcateg0="+xc_id;}
function goD(_itemID){document.location="/alienPORT.al"+_jsessionid+"?shopid=rooflite&language_code=en&ewitem0="+_itemID;}
function startDownload(_itemID){document.location="/ew_proddownload.al"+_jsessionid+"?itemid="+_itemID;}

// ***********
function wrtCALoxSEL(elID,xDateNum,targ)
{ var YEARscroll=false;
if(!marked){var marked="";}

var ARR_MONTHS_EN = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"];
var ARR_WEEKDAYS_EN = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];

var ARR_MONTHS = ["Január", "Február", "Március", "Április", "Május", "Június","Július", "Augusztus", "Szeptember", "Október", "November", "December"];
var ARR_WEEKDAYS = ["V", "H", "K", "Sze", "Cs", "P", "Szo"];

var NUM_WEEKSTART = 1; // day week starts from (normally 0-Su or 1-Mo)
var STR_ICONPATH = 'img/';  // path to the directory where calendar images are stored. trailing slash req.

var dt_selected=new Date();
var dt_current=dt_selected;
if (xDateNum>0){dt_current=new Date(xDateNum);}
var dt_firstday = new Date(dt_current);
dt_firstday.setDate(1);dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);
var dt_prev_month = new Date(dt_current);dt_prev_month.setMonth(dt_prev_month.getMonth() - 1);
if (dt_prev_month.getDate() != dt_current.getDate())dt_prev_month.setDate(0);
var dt_next_month = new Date(dt_current);dt_next_month.setMonth(dt_next_month.getMonth() + 1);
if (dt_next_month.getDate() != dt_current.getDate())dt_next_month.setDate(0);
var dt_prev_year = new Date(dt_current); dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
if (dt_prev_year.getDate() != dt_current.getDate())dt_prev_year.setDate(0);
var dt_next_year = new Date(dt_current); dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
if (dt_next_year.getDate() != dt_current.getDate())dt_next_year.setDate(0);

var outSTR='<table class="clsOTable" cellspacing="0" border="0" width="100%"><tr><td bgcolor="#4682B4"><table cellspacing="1" cellpadding="3" border="0" width="100%"><tr><td colspan="7"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>'+
'<td nowrap>'+(YEARscroll?'<a href=\'javascript:wrtCALoxSEL("'+elID+'",'+dt_prev_year.valueOf()+',"'+targ+'")\'><img src="'+STR_ICONPATH+'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a>&nbsp;':'')+'<a href=\'javascript:wrtCALoxSEL("'+elID+'",'+dt_prev_month.valueOf()+',"'+targ+'")\'><img src="'+STR_ICONPATH+'prev.gif" width="16" height="16" border="0" alt="previous month"></a></td>'+
'<td align="center" width="100%"><font color="#ffffff">'+ARR_MONTHS[dt_current.getMonth()]+' '+dt_current.getFullYear() + '</font></td>'+
'<td nowrap><a href=\'javascript:wrtCALoxSEL("'+elID+'",'+dt_next_month.valueOf()+',"'+targ+'")\'><img src="'+STR_ICONPATH+'next.gif" width="16" height="16" border="0" alt="next month"></a>'+(YEARscroll?'&nbsp;<a href=\'javascript:wrtCALoxSEL("'+elID+'",'+dt_next_year.valueOf()+',"'+targ+'")\'><img src="'+STR_ICONPATH+'next_year.gif" width="16" height="16" border="0" alt="next year"></a>':'')+'</td>'+
'</tr></table></td></tr><tr>';

for (var n=0; n<7; n++)outSTR+='<td class="days" align="center">'+ARR_WEEKDAYS[(NUM_WEEKSTART+n)%7]+'</td>';
outSTR+='</tr>';
var dt_current_day = new Date(dt_firstday);
while (dt_current_day.getMonth() == dt_current.getMonth() ||dt_current_day.getMonth() == dt_firstday.getMonth())
 {outSTR+='<tr>';
  for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
		if (dt_current_day.getDate() == dt_selected.getDate() && dt_current_day.getMonth() == dt_selected.getMonth() && dt_current_day.getFullYear() == dt_selected.getFullYear())
			outSTR+='<td class="cday" align="center" width="14%">'; // print current date
		else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
			outSTR+='<td class="wedays" align="center" width="14%">'; // weekend days
		else 		
			outSTR+='<td bgcolor="#ffffff" align="center" width="14%">'; // print working days of current month

                outSTR+='<a href=\'javascript:setcal("'+targ+'","'+dt_current_day.getYear()+'.'+lCorr(dt_current_day.getMonth()+1,2)+'.'+lCorr(dt_current_day.getDate(),2)+'.","'+elID+'")\'>';

		if (dt_current_day.getMonth() == dt_current.getMonth()) outSTR+='<font color="#000000">'; // print days of current month
			else outSTR+='<font color="#606060">';// print days of other months
		outSTR+=dt_current_day.getDate()+'</font></a></td>';
		dt_current_day.setDate(dt_current_day.getDate()+1);
	}
	outSTR+='</tr>';
}
outSTR+='</table></td></tr></table>';
var xDIV=document.getElementById(elID);
xDIV.innerHTML=outSTR;
}
function lCorr(nm,lng){var s="000"+nm;return s.substring(s.length-lng,s.length);}
function setcal(trg,ots,calid)
{ var calDIV=document.getElementById(calid);calDIV.style.display="none";
var calTRG=document.getElementById(trg);calTRG.value=ots;}
function writeCAL(elID,xDateNum,targ)
{var calDIV=document.getElementById(elID);
//var e=window.event; calDIV.style.top=e.clientY+"px"; calDIV.style.left=e.clientX+"px";
if(calDIV.style.display=="block"){calDIV.style.display="none";}else{calDIV.style.display="block";}
wrtCALoxSEL(elID,xDateNum,targ);
}






/* dynaCREATE*/
var counters = new Array();

function addAlertWin(template, type)
{if(!counters[type]){counters[type]=0;}
 counters[type] += 1;
 var container = document.getElementById(type + "Container");
 var templateHTML = document.getElementById(template).innerHTML;
 var itemDiv = document.createElement("div");
 itemDiv.setAttribute("id", type + "_" + counters[type] + "_div");
 itemDiv.setAttribute("style", "width:300px;height:200px;border:#ff0000 1px solid;position:absolute;z-index:77;top:"+(counters[type]*15+30)+"px;left:40px;");
 itemDiv.className = "repeatedField"
 itemDiv.innerHTML = templateHTML.replace(/COUNTER/g, counters[type]);
 container.appendChild(itemDiv);
}
function addRepeatedField(template, type)
{if(!counters[type]){counters[type]=0;}
 counters[type] += 1;
 var container = document.getElementById(type + "Container");
 var templateHTML = document.getElementById(template).innerHTML;
 var itemDiv = document.createElement("div");
 itemDiv.setAttribute("id", type + "_" + counters[type] + "_div");
 itemDiv.className = "repeatedField"
 itemDiv.innerHTML = templateHTML.replace(/COUNTER/g, counters[type]);
 container.appendChild(itemDiv);
 return counters[type];
}
function deleteRepeatedField(prefix, counterVal)
{var container = document.getElementById(prefix + "Container");
 var elemName;
 if(counterVal != -1){elemName = prefix + "_" + counterVal + "_div";}else{elemName = prefix + "_div";}
 var elem = document.getElementById(elemName);
 container.removeChild(elem);	
}

function scanFIELDS(fOBJ)
{alert(fOBJ.elements.length);
for(i=0;i<fOBJ.elements.length;i++)
 {alert(fOBJ.elements[i].name+"="+fOBJ.elements[i].value+"  ||"+fOBJ.elements[i].type)}
}

// googleMaps
GMAPs = function()
{var GMObj;
 var gdir; var geocoder; var ajaxMon; var latTarget; var lonTarget; var altTarget;
 var geoJSON;
 var baseDOC; var callBack;var finFN;
}
GMAPs.prototype ={
init: function(baseDOC,callBack,finFN)
{ GMObj=this;
 if (baseDOC){this.baseDOC=baseDOC;}else{this.baseDOC=document;}
 if (callBack){this.callBack=callBack;}else{this.callBack="GMObj.GEO2CNF";}
 if (finFN){this.finFN=finFN;}else{this.finFN="GMObj.GEO2FIN";}
if (GBrowserIsCompatible()){GMObj.geocoder = new GClientGeocoder();}
},
GeoCodeIt: function(address,ajaxMon,latTarget,lonTarget,altTarget)
{GMObj.ajaxMon=ajaxMon;GMObj.latTarget=latTarget;GMObj.lonTarget=lonTarget;GMObj.altTarget=altTarget;
GMObj.geocoder.getLocations(address, GMObj.GeoCoded);
},
GeoCoded: function(response)
{if (!response || response.Status.code != 200) {alert("Sorry, we were unable to geocode that address");}
else
{GMObj.geoJSON=response;
if(GMObj.geoJSON.Placemark.length>0)
 {var str1="<div id='sss' class='inp' style='display:block;border:#000 1px solid;padding:5px;height:auto;'>";
  for (var i=0;i<GMObj.geoJSON.Placemark.length;i++)
   {str1+="<input type='radio' name='pln' id='pln' value='"+i+"' onclick='javascript:"+GMObj.callBack+"("+i+")' /> "+GMObj.geoJSON.Placemark[i].address+"<br/>";}
  str1+="<div align='right' style='border-top:#000 1px solid;padding:3px;'><input type='button' value='close' class='btn' onclick='javascript:"+GMObj.finFN+"()'/></div></div>" 
  var e = GMObj.baseDOC.getElementById(GMObj.ajaxMon);e.innerHTML = str1;
 }
}
},
GEO2CNF: function(poz)
{GMObj.latTarget.value=GMObj.geoJSON.Placemark[poz].Point.coordinates[1];
 GMObj.lonTarget.value=GMObj.geoJSON.Placemark[poz].Point.coordinates[0];
},
GEO2FIN: function(){var e = document.getElementById(GMObj.ajaxMon);e.innerHTML ="";},

handleErrors: function()  // general errorhandler
{if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)  alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
   else alert("An unknown error occurred.");
}
}


/*   googleMaps V3.0 

obj.ret:
results[]: {
 types[]: string,
 formatted_address: string,
 address_components[]: {
   short_name: string,
   long_name: string,
   types[]: string
 },
 geometry: {
   location: LatLng,
   location_type: GeocoderLocationType
   viewport: LatLngBounds,
   bounds: LatLngBounds
 }
}

*/
GMAPs_V3 = function()
{var GMObj;
 var gdir; var geocoder; var ajaxMon; var latTarget; var lonTarget; var altTarget;
 var geoJSON;
 var baseDOC; var callBack;var finFN;
}
GMAPs_V3.prototype ={
init: function(baseDOC,callBack,finFN)
{ GMObj=this;
 if (baseDOC){this.baseDOC=baseDOC;}else{this.baseDOC=document;}
 if (callBack){this.callBack=callBack;}else{this.callBack="GMObj.GEO2CNF";}
 if (finFN){this.finFN=finFN;}else{this.finFN="GMObj.GEO2FIN";}
 GMObj.geocoder = new google.maps.Geocoder(); // gm v3.1
},
GeoCodeIt: function(address,ajaxMon,latTarget,lonTarget,altTarget)
{if (GMObj.geocoder){GMObj.ajaxMon=ajaxMon;GMObj.latTarget=latTarget;GMObj.lonTarget=lonTarget;GMObj.altTarget=altTarget;
		 GMObj.geocoder.geocode( { 'address': address}, GMObj.GeoCoded);
		}
},
GeoCoded: function(results, status)
{if(status!=google.maps.GeocoderStatus.OK){alert("Geocode was not successful for the following reason: " + status);/*closeform*/}
else
{GMObj.geoJSON=results;
if(GMObj.geoJSON.length>0)
 {var str1="<div id='sss' class='inp' style='display:block;border:#000 1px solid;padding:5px;height:auto;'>";
  for (var i=0;i<GMObj.geoJSON.length;i++)
   {str1+="<input type='radio' name='pln' id='pln' value='"+i+"' onclick='javascript:"+GMObj.callBack+"("+i+")' /> "+GMObj.geoJSON[i].formatted_address+"<br/>";}
  str1+="<div align='right' style='border-top:#000 1px solid;padding:3px;'><input type='button' value='close' class='btn' onclick='javascript:"+GMObj.finFN+"()'/></div></div>" 
  var e = GMObj.baseDOC.getElementById(GMObj.ajaxMon);e.innerHTML = str1;
 }
}
},
GEO2CNF: function(poz)
{GMObj.latTarget.value=GMObj.geoJSON[poz].geometry.location.lat();
 GMObj.lonTarget.value=GMObj.geoJSON[poz].geometry.location.lng();
},
GEO2FIN: function(){var e = document.getElementById(GMObj.ajaxMon);e.innerHTML ="";},

handleErrors: function()  // general errorhandler
{if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)  alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_KEY) alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
   else alert("An unknown error occurred.");
}
}




function showHideN(idN)
{var o1=document.getElementById(idN);
 if(o1){if (o1.style.display=="none"){o1.style.display="block";}else{o1.style.display="none";}}
}

function setClassName(idN,cName)
{if ("object" == typeof idN){idN.className=cName;}
  else{ var o1=document.getElementById(idN); if(o1){o1.className=cName;}}
}



function printIT()
{ //var ewCT=getHTMLVar("ewcateg0");alert("Printing:"+ewCT);
  window.print();
}

function changeIMG(idN,imgSpec)
{if ("object" == typeof idN){idN.src=imgSpec;}
  else{ var o1=document.getElementById(idN); if(o1){o1.src=imgSpec;}}
}


function fileAttach(fobj,txtname)
{var fname=fobj.value;
 document.getElementById(txtname).value=fname;
}


function seeMore(xdir,files)
{var fA=files.split(",");
var finalA=new Array();
var options = {continuous: false}; // true means neverending
for (var j=0;j<fA.length;j++)
{ var fspec=xdir+fA[j];
  var img = {player:"img",content:fspec,options:options};
  finalA.push(img);
}
Shadowbox.open(finalA);
}



function ox64encode(inS){return ( Base64.encode(inS).replace(/[+]/g,"_").replace(/[/]/g,"|").replace(/[=]/g,"-"));}
function ox64decode(inS){return ( Base64.decode(inS.replace(/[_]/g,"+").replace(/[|]/g,"/").replace(/[-]/g,"=")));}
/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64=
{_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = ""; var i = 0; var c = c1 = c2 = 0;
while ( i < utftext.length ) {
  c = utftext.charCodeAt(i);
  if (c < 128){string += String.fromCharCode(c);i++;}
	else if((c > 191) && (c < 224)) {c2 = utftext.charCodeAt(i+1);string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));i += 2;}
		else {c2 = utftext.charCodeAt(i+1);c3 = utftext.charCodeAt(i+2);string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));i += 3;}
 		}
		return string;
	} 
}



/* in-place editing */
var ESCAPE = 27
var ENTER = 13
var TAB = 9
function joinEDTField(inpIDname, isDoubleClick)
{var view = document.getElementById(inpIDname+"VW");
 view.editor = document.getElementById(inpIDname);
 
 var showEditor = function(event)
  {event = fixEvent(event); var view = this; var editor = view.editor; if (!editor) {return true;} if (editor.currentView != null) {editor.blur();}
   editor.currentView = view; editor.style["top"]=0+"px"
; editor.style["left"]=0+"px";
   if (editor.nodeName == 'TEXTAREA'){editor.style['width'] = view.offsetWidth + "px"; editor.style['height'] = view.offsetHeight + "px";}
   editor.value = view.innerHTML; editor.style['visibility']='visible'; view.style['visibility']='hidden';editor.focus();return false;
  }
 
 if (isDoubleClick){view.ondblclick=showEditor;} else {view.onclick=showEditor;}
 
 view.editor.onblur = function(event)
  {event=fixEvent(event); var editor=event.target;var view=editor.currentView;
   if (!editor.abandonChanges) view.innerHTML = editor.value
   editor.abandonChanges = false; editor.style['visibility'] = 'hidden'; /*editor.value = '';*/
   view.style['visibility'] = 'visible'; editor.currentView = null; return true;}
	
 view.editor.onkeydown = function(event){event=fixEvent(event); var editor = event.target;if (event.keyCode == TAB) {editor.blur();return false;}}
 view.editor.onkeyup = function(event)
  {event = fixEvent(event);var editor = event.target
   if (event.keyCode == ESCAPE){editor.abandonChanges=true;editor.blur();return false;}
     else if (event.keyCode == TAB) {return false;} else {return true;}
  }
 
	// TODO: this method is duplicated elsewhere
 function fixEvent(event)
  {if (!event) {event = window.event;}
   if (event.target) {if (event.target.nodeType == 3) event.target = event.target.parentNode;} else if (event.srcElement) {event.target = event.srcElement;}
   return event;
  }
}

function editINIT(inpClassName)
{ var l01= document.getElementsByClassName(inpClassName);
 for(i=0;i<l01.length;i++){joinEDTField(l01[i].id, true);}
}


/* ****************************
       ENDWriter class. 

   Elhelyezi: %PRICE,%CURR,xxxx,
   auction

.replace(/COUNTER/g, counters[type]);
remove BRUTTO,DBRUTTO,CURR1,
   returns html string
   **************************** */

function ENDWriter(selfName,docOBJName,templateID,boxid,params)
{ var selfName=selfName;
  var docOBJName=docOBJName;
  var boxid=boxid;
  var params=params;
  var template=getHTMLVar(templateID);
  var ecatalog="";
  var newid="";
  var clr="CAMOUNT,BRUTTO,DBRUTTO,CARTBUTT";


  function gV(pn){ return params[pn];}
  function cV(what,nval){return eval("template.replace(/"+what+"/g,nval);");}

  function getHTML()
    {	newFINISH();
	//final tag clearance
	for (var i in params){if(params[i]!=null) {template=eval("template.replace(/%"+i+"%/g,\""+params[i]+"\");");}}
	var clrS=clr.split(",");
	for (var j=0;j<clrS.length;j++){template=eval("template.replace(/%"+clrS[j]+"%/g,\"\")");}
	return template;
    }

  function eCATALOG(subTEMPLATE)
    {var os="";
     var dlFile=gV("ECATALOG");
     var xID=gV("NEWID");
     if(dlFile.length<2){return os;}
     if(!subTEMPLATE)
        { var os="<a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=m' target='_blank'>VIEW</a> ";
          os+="<a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=d'><b><font size=1>DOWNLOAD</font></b></a>";
	}
	else
	{ os=getHTMLVar(subTEMPLATE);
	  os=os.replace(/%ECATALOG%/g,dlFile);
	  os=os.replace(/%ID%/g,xID);
	}
     return os;
    }

  function eCOMMENT(subTEMPLATE)
    {var os="";
     var dlFile=gV("ECATALOG");
     var xID=gV("NEWID");
     if(dlFile.length<2){return os;}
     if(!subTEMPLATE)
        { var os="<a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=m' target='_blank'>VIEW</a> ";
          os+="<a href='/ew_catdownload.al?id="+xID+"&shopid=rooflite&playtype=d'><b><font size=1>DOWNLOAD</font></b></a>";
	}
	else
	{ os=getHTMLVar(subTEMPLATE);
	  os=os.replace(/%ECATALOG%/g,dlFile);
	  os=os.replace(/%ID%/g,xID);
	}
     return os;
    }

  function newFINISH()
    { var userdiscount=gV("userdiscount"); 
      var STime=gV("STime");
      if(userdiscount==null){userdiscount="0";} if(STime==null)STime="";
      var x1="";
      getEBS(boxid,gV("NEWID"),gV("ID2"),"en",gV("ISEB"),gV("PRICE1"),gV("CURR1"),gV("VAT"),gV("DISC"),gV("AMOUNT"),gV("AUCTION"),gV("A_START"),gV("A_STOP"),gV("A_MINLIMIT"),gV("A_CURRPRICE"),STime,gV("JTXINDEX"),gV("SHOPID"),gV("SHOPT"),gV("ME"),userdiscount,gV("MINQUANTITY"),gV("SELQUANT_ID"));
      template=cV("%ECATALOG%",eCATALOG());
      // if (reviewenabled=="1"){x1+="<br /> <a href=\"javascript:showCOMMENTS('"+newid+"')\"><font class='INFO1'>REVIEWS ("+reviewcount+")</font></a>";}
    }
 
  function getEBS(BOXID,NEWID,ID2,LANGUAGECODE,ISEBUSINESS,PRICE1,CURR1,VAT,DISCOUNTRULE,CURRENTAMOUNT,AUCTION,AUCTION_START,AUCTION_STOP,AUCTION_MINLIMIT,AUCTION_CURRPRICE,SERVERTIME,JTXINDEX,SHOPID,SHOPTITLE,ME,userdiscount,MINQUANTITY,SELQUANT_ID)
    {var outSSS="";
     if (ISEBUSINESS=="1")
       {if(AUCTION!="1")
        { getPriceS(PRICE1,VAT,CURR1,DISCOUNTRULE,userdiscount);
	  if(MINQUANTITY==null){MINQUANTITY="";}
	  var MQ=parseFloat(MINQUANTITY); if (isNaN(MQ)){MQ=1;}
	  outSSS="<input type='button' class='btn' onclick=\"javascript:"+selfName+".toCart('"+BOXID+"',"+JTXINDEX+","+docOBJName+",'"+SHOPID+"','"+SHOPTITLE+"','"+NEWID+"','"+ID2+"','','"+PRICE1+"','"+SELQUANT_ID+"','"+VAT+"','"+LANGUAGECODE+"','"+ME+"','"+CURRENTAMOUNT+"','"+DISCOUNTRULE+"','"+userdiscount+"','"+MQ+"');\" value=\"TO CART\" />";
          template=cV("%CARTBUTT%",outSSS);
          template=cV("%CAMOUNT%",CURRENTAMOUNT+" "+ME);
	}
	else
	{var xxcp=parseFloat(AUCTION_CURRPRICE); var xxcv=parseFloat(PRICE1);
	 if (xxcp<xxcv){xxcp=xxcv;}else{xxcp+=parseFloat(AUCTION_MINLIMIT);}
	 outSSS="<br/><b> AUCTION</b>";
	 if (AUCTION_MINLIMIT.length>0)
	  { outSSS+="<b>:</b><br/> interval: "+AUCTION_START+"-"+AUCTION_STOP+"<br/> minimum licit: "+AUCTION_MINLIMIT+" "+CURR1+"<br/> AUCTION PRICE: "+PRICE1+" "+CURR1+" &nbsp;&nbsp; CURRENT PRICE: "+AUCTION_CURRPRICE+" "+CURR1+".";
	    outSSS+="<br/> YOUR LICIT: <input type=text name='licit"+NEWID+"' value='"+xxcp+"' class='inp' size=5> "+CURR1+" &nbsp;<a href='javascript:sendLICIT(\""+NEWID+"\",\""+BOXID+"\")'>licit</a>";
	  }
	 }
	}
	// return outSSS;
     }

   /*  calculating  price from net price+vat+discount    change to ajax ??? */
   function getPriceS(xpriceS,xvatS,xcurr,xdiscrule,userdiscount)
	{
var outSTR="";var xprice=parseFloat(xpriceS);if (isNaN(xprice)){xprice=0;}
	 if(!userdiscount){userdiscount="0";}
	 var udisc=parseFloat(userdiscount);if (isNaN(udisc)){udisc=0;}
	 var xvat=parseFloat(xvatS);if (isNaN(xvat)){xvat=0;}if (xvat==0){xvat=20;}
	 var dscappl=0;
	 var tp=xdiscrule.indexOf(";1:");
	 if(tp>-1)
	  {var tp2=xdiscrule.indexOf(";",tp+2);if(tp2<0){tp2=xdiscrule.length;}
	   dscappl=parseFloat(xdiscrule.substring(tp+3,tp2));if (isNaN(dscappl)){dscappl=0;}
	  }
	 else if(udisc>0){dscappl=udisc;}
	 var xbrutprice=xprice+Math.round(xprice*xvat/100);
	 var aprice="";  var bprice="";
	 if(dscappl>0){aprice=Math.round(xbrutprice-(xbrutprice*dscappl/100))+"";bprice="<strike>"+xbrutprice+"</strike>";}
	  else{bprice=xbrutprice+"";}
	  outSTR="<b>PRICE:</b> "+bprice+" "+aprice+" <b>"+xcurr+"</b>";
          template=cV("%BRUTTO%",bprice);
          template=cV("%DBRUTTO%",aprice);
          template=cV("%CURR1%",xcurr);
	  if (dscappl>0){outSTR+="<font color=red><b> !</b></font>";}
	  // return outSTR;
	}



 function toCart(boxid,jtxindex,formobjname,shopid,shoptitle,id,id2,authtitle,price,selQUANT_ID,vat,lang,i_me,current_amount,xdiscrule,userdisc,minQuant,selQuant)
   {var udisc=parseFloat(userdisc);if (isNaN(udisc)){udisc=0;}
    var sQUANT=getHTMLVar(selQUANT_ID); if(sQUANT==null){sQUANT="1";}
    amount=parseFloat(sQUANT); if(isNaN(amount)){amount=1;}
    if (amount<minQuant){amount=minQuant;}
var dscappl=0; var tp=xdiscrule.indexOf(":"); 
if(tp>-1){dscappl=xdiscrule;}else if(udisc>0){dscappl=udisc;}
authtitle=getHTMLVar("creator"+boxid+jtxindex);if (authtitle.length>1){authtitle+=" ";}
authtitle+=getHTMLVar("title"+boxid+jtxindex);shoptitle+=getHTMLVar("shoptitle");
  toCookie(shopid,shoptitle,id,id2,authtitle,price,amount,vat,dscappl,lang,i_me,current_amount,minQuant,shopid+"_cart");

  sC.drawCART();

//reFRESH2();
  }

/* simple: handle multilevel object but no-arrays */
function serializeJSON(_jsn)
{var sOUT="{";
 for (var k in _jsn)
 {var vv=_jsn[k];
  if (typeof vv == 'object'){sOUT+="\""+k+"\":"+serializeJSON(_jsn[k])+",";}
    else {vv=String(vv);vv=vv.replace(/\"/g,"\\\"");sOUT+="\""+k+"\":\""+vv+"\",";}
 }
 sOUT=sOUT.substring(0,sOUT.length-1)+"}";
return sOUT;
}

function toCookie(shopid,shoptitle,i_id,i_id2,i_name,i_price,i_quant,i_vat,i_disc,langCode,i_me,i_c_amount,i_minquant,cookieName)
{var msg_OK=" put into the cart.";var msg_notOK=" already is in the cart.";var msg_NoCookie="For using the cart system cookies must be enabled.";
if (!checkCookieEnabled2()){alert(msg_NoCookie);return;}
var scart = getCookie2(cookieName);if(!scart){scart ="";}
if (scart.length<3){var scart="{\"shopid\":{\"shopid\":\""+shopid+"\",\"shoptitle\":\""+shoptitle+"\"}}";
		   }
var scart_js={};
eval("scart_js="+scart);
var cShopid=scart_js["shopid"]["shopid"];
if(cShopid!=shopid)
{var tmpscart=scart;var ti=0;
while (ti<3){pz1=tmpscart.indexOf("||");tmps=tmpscart.substring(0,pz1);tmpscart=tmpscart.substring(pz1+2,tmpscart.length);ti++;}
if ("aáeéiíoóöuúüAÁEÉIÍOÓÖUÚÜ".indexOf(tmps.substring(1,1))>-1){tmps=" az "+tmps;}else{tmps=" a "+tmps;}
alert("You can buy in one shop in one time. Jelenleg az Ön kosarában más üzletböl származó árucikkek is vannak.");return;
}

if(scart_js[i_id]==null)
 {scart_js[i_id]={"id":i_id,"name":i_name,"price":i_price,"quant":i_quant,"vat":i_vat,"disc":i_disc,"me":i_me,"camount":i_c_amount,"id2":i_id2,"minquant":i_minquant};
  scart=serializeJSON(scart_js);
  setCookie2(cookieName,scart);
  alert(i_quant+" "+i_me+"  "+i_name+msg_OK);
 }
else {alert(i_name+msg_notOK);}
return;
}

   this.gV=gV;
   this.cV=cV;
   this.toCart=toCart;
   this.newFINISH=newFINISH;
   this.eCATALOG=eCATALOG;
   this.getHTML=getHTML;
 }



/* smallcart object*/

function smallCART(selfName,divID,tmpcookieName,_fullList,xClass,xEST)
 { var selfName=selfName;
   var divID=divID;
   var tmpcookieName=tmpcookieName;
   var fullList=fullList;
   var xClass=xClass;
   var xEST=xEST;

function drawCART()
{xMoney="HUF";xME="pcs";var scart=getCookie2(tmpcookieName);if(!scart){return;}
var scart_js={};
eval("scart_js="+scart);
var shTitle=scart_js["shopid"]["shoptitle"];
var full_brutsum=0;
var itemNo=0;
for (var k in scart_js)
 {itemNo++;
  if(k!="shopid")
  {var tmp_js=scart_js[k];
  var cDISC=getDISC2(tmp_js["disc"],tmp_js["quant"]);
  var netPriceCC=tmp_js["price"]-(tmp_js["price"]*cDISC/100);
  var brutPrice=Math.round(netPriceCC*(100+1*tmp_js["vat"]))/100;
  var line_brutsum =tmp_js["quant"]*brutPrice;
  full_brutsum+=line_brutsum;
  }
 }
if (itemNo>0){itemNo--;} 
var outSTR="<table class=\""+xClass+"\" style=\""+xEST+"\" cellpadding='0' cellspacing='0' width='100%'><tr><td class='hdl'> </td><td class='hd1'><span class='hdt'>CART</span></td><td class='hdr'> </td></tr><tr><td class='mdl'> </td><td class='txt'>";
outSTR+=" Item: "+itemNo+"db<br>Total: "+convNum(full_brutsum,2)+" HUF.";
outSTR+="<div align=right><a href='#' onclick='javascript:_viewCart(document._rdr_x)'><font size=1>DETAILS</font></a></td><td class='mdr'> </td></tr><tr><td class='ftl'> </td><td class='ftm'> </td><td class='ftr'> </td></tr></table>";
setHTMLVar(divID,outSTR);
}

 this.drawCART=drawCART;
}


/* ******************************** DEPRECIATED ****************************************** */



function fullFINISH2(boxid,newid,id2,jtx_index,shopid,ecatalog,relation1,relation2,isebusiness,price1,curr1,vat,current_amount,me,discountrule,auction,auction_start,auction_stop,auction_minlimit,auction_currprice,auctioner,voting,voter,voting_start,voting_stop,isepublish,epubcode,reviewenabled,reviewcount,rateenabled,ratingno,ratingsum,shoptitle,STime,userdiscount)
{if(!userdiscount){userdiscount="0";}
if(STime==null)STime="";var x1=getEB2(boxid,newid,id2,"en",isebusiness,price1,curr1,vat,discountrule,current_amount,auction,auction_start,auction_stop,auction_minlimit,auction_currprice,STime,jtx_index,shopid,shoptitle,me,userdiscount);
if (ecatalog.length>2){x1+="<br>"+newDownload(ecatalog,newid);}
if (reviewenabled=="1"){x1+="<br /> <a href=\"javascript:showReviews('"+newid+"')\"><font class='INFO1'>REVIEWS ("+reviewcount+")</font></a>";}
if (relation1.length>1)  //hasonlok
{x1+="<br><a href='javascript:getREL1(\""+newid+"\",\""+relation1+"\",\"1\")'>ACCESSORIES</A>";}
if (relation2.length>1)  //tartozekok
{x1+="<br><a href='javascript:getREL1(\""+newid+"\",\""+relation2+"\",\"2\")'>SIMILARS</A>";}
return x1;}

function endWriting2(boxid,currentPAGE,maxPAGE,prevImage,nextImage,writePGNO,formOBJ,REP)
{var outV="";var cPG=0;if (REP!=null){REP=",'N'";}else{REP="";} var bPG1="";var bPG2="";
var cib=Math.floor(currentPAGE/10)*10;
var maxpglim=cib+10-1;
if (currentPAGE>10){bPG1="<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+(cib-10)+"'"+REP+")\"><b><<</b></a>&nbsp;&nbsp;";}
if (maxpglim<=maxPAGE){bPG2="&nbsp;&nbsp;<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+(cib+10)+"'"+REP+")\"><b>>></b></a>";}
if (maxpglim>maxPAGE){maxpglim=maxPAGE;}
if (currentPAGE>0)
{cPG=currentPAGE-1;
 outV+=bPG1+"<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+cPG+"'"+REP+")\"><b><</b></a>&nbsp;";}
if ((writePGNO=="1")&&(maxPAGE>0)){var ci=cib;while (ci<=maxpglim){if (currentPAGE!=ci) outV+=" <a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+ci+"'"+REP+")\">"+(ci+1)+"</a>";else outV+=" <b>"+(ci+1)+"</b>";
ci++;}}
if(currentPAGE<maxPAGE){cPG=currentPAGE+1;outV+=" &nbsp;<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+cPG+"'"+REP+")\"><b> > </b></a>"+bPG2;}
return outV;}


function endWriting2OLD(boxid,currentPAGE,maxPAGE,prevImage,nextImage,writePGNO,formOBJ,REP){var outV="";var cPG=0;if (REP!=null){REP=",'N'";}else{REP="";}
if (currentPAGE>0){cPG=currentPAGE-1; outV+="<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+cPG+"'"+REP+")\"><img src='"+prevImage+"' alt='Previous' border='0' /></a>&nbsp;";}
if ((writePGNO=="1")&&(maxPAGE>0)){var ci=0;while (ci<=maxPAGE){if (currentPAGE!=ci) outV+=" <a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+ci+"'"+REP+")\">"+(ci+1)+"</A>";else outV+=" <b>"+(ci+1)+"</b>";
ci++;}}
if(currentPAGE<maxPAGE){cPG=currentPAGE+1;outV+=" &nbsp;<a href=\"javascript:setPAGE2_get('"+boxid+"',"+formOBJ+",'"+cPG+"'"+REP+")\"><img src='"+nextImage+"' alt='Next' border=0></a>";}return outV;}


function getEB2(BOXID,NEWID,ID2,LANGUAGECODE,ISEBUSINESS,PRICE1,CURR1,VAT,DISCOUNTRULE,CURRENTAMOUNT,AUCTION,AUCTION_START,AUCTION_STOP,AUCTION_MINLIMIT,AUCTION_CURRPRICE,SERVERTIME,JTXINDEX,SHOPID,SHOPTITLE,ME,userdiscount)
{var outSSS="";if (ISEBUSINESS==+"1"){if(AUCTION!="1")
{outSSS=getPrice(PRICE1,VAT,CURR1,DISCOUNTRULE,userdiscount);if(outSSS.length>0){outSSS="<br />"+outSSS;}
outSSS+="&nbsp;&nbsp;<span class='btn'><a href=\"javascript:selectorMOD2('"+BOXID+"',"+JTXINDEX+",'document.dm01','"+SHOPID+"','"+SHOPTITLE+"','"+NEWID+"','"+ID2+"','','"+PRICE1+"',1,'"+VAT+"','"+LANGUAGECODE+"','"+ME+"','"+CURRENTAMOUNT+"','"+DISCOUNTRULE+"','"+userdiscount+"');\">";outSSS+="TO CART</a></span><br/>&nbsp;"+CURRENTAMOUNT+" "+ME;}else{
var xxcp=parseFloat(AUCTION_CURRPRICE); var xxcv=parseFloat(PRICE1);
if (xxcp<xxcv){xxcp=xxcv;}else{xxcp+=parseFloat(AUCTION_MINLIMIT);}
outSSS="<br/><b> AUCTION</b>";
if (AUCTION_MINLIMIT.length>0)
 { outSSS+="<b>:</b><br/> interval: "+AUCTION_START+"-"+AUCTION_STOP+"<br/> minimum licit: "+AUCTION_MINLIMIT+" "+CURR1+"<br/> AUCTION PRICE: "+PRICE1+" "+CURR1+" &nbsp;&nbsp; CURRENT PRICE: "+AUCTION_CURRPRICE+" "+CURR1+".";
   outSSS+="<br/> YOUR LICIT: <input type=text name='licit"+NEWID+"' value='"+xxcp+"' class='inp' size=5> "+CURR1+" &nbsp;<a href='javascript:sendLICIT(\""+NEWID+"\",\""+BOXID+"\")'>licit</a>";
 }
}}
return outSSS;}



function addc3a(shopid,shoptitle,i_id,i_id2,i_name,i_price,i_quant,i_vat,i_disc,langCode,i_me,i_c_amount,cookieName)
{var msg_OK=" put into the cart.";var msg_notOK=" already is in the cart.";var msg_NoCookie="For using the cart system cookies must be enabled.";
if (!checkCookieEnabled2()){alert(msg_NoCookie);return;}
var scart = getCookie2(cookieName);if(!scart){scart ="";}
if (scart.length<2){var scart="x_s_h_o_p||"+shopid+"||"+shoptitle+"||x||x||x||x||x||x_s_end||";}
else{var checkseq="x_s_h_o_p||"+shopid+"||";var pz1=scart.indexOf(checkseq);
if (pz1<0){var tmpscart=scart;var ti=0;
while (ti<3){pz1=tmpscart.indexOf("||");tmps=tmpscart.substring(0,pz1);tmpscart=tmpscart.substring(pz1+2,tmpscart.length);ti++;}
if ("aáeéiíoóöuúüAÁEÉIÍOÓÖUÚÜ".indexOf(tmps.substring(1,1))>-1){tmps=" az "+tmps;}else{tmps=" a "+tmps;}
alert("You can buy in one shop in one time. Jelenleg az Ön kosarában más üzletböl származó árucikkek is vannak.");return;}}
var tstr=i_id+"||"+i_name+"||"+i_price+"||"+i_quant+"||"+i_vat+"||"+i_disc+"||"+i_me+"||"+i_c_amount+"||"+i_id2+"||";i_id+="||";
if (scart.indexOf(i_id)<0){scart=scart+tstr;  alert(i_name+msg_OK);}else{alert(i_name+msg_notOK);}
setCookie2(cookieName,scart);return;}

/* draw the smallcart in javascript */
function writeSmallCart(tmpcookieName,_fullList,xClass,xEST)
{xMoney="HUF";xME="pcs";var scart=getCookie2(tmpcookieName);if(!scart){return;}
if (scart.length<5){return;}var x0=0;var x1=0;var fno=9-1;var cno=0;var lofs=scart.length;var subTotal=0;var fullTotal=0;var tmpVals=new Array();var tmpPrice=0,tmpAmount=0,tmpDisc="",fullAmount=0;var mainCycle=0;var line_netsum=0; line_brutsum=0; line_vat=0;var full_netsum=0;full_brutsum=0;full_vat=0;
while (x1<lofs){if (scart.substring(x1,x1+2)=="||"){tmpVals[cno]=scart.substring(x0,x1);
if(cno==fno){tmpItemID=tmpVals[0];tmpItem=tmpVals[1];netPrice=tmpVals[2];tmpAmount=tmpVals[3];tmpVat=tmpVals[4];tmpDisc=tmpVals[5];tmpME=tmpVals[6];tmpmaxamount=tmpVals[7];tmpItemID2=tmpVals[8];
var cDISC=getDISC2(tmpDisc,tmpAmount);
if(tmpItemID=="x_s_h_o_p"){ // document.write("<td ALIGN=LEFT COLSPAN=8><FONT SIZE=2><B><U>"+netPrice+"</U><input type=hidden name='shopid' value='"+tmpItem+"'>&nbsp;&nbsp;</TD></TR><TR>");
}else
{fullAmount+=(tmpAmount*1);netPriceCC=netPrice-(netPrice*cDISC/100);line_netsum=tmpAmount*netPriceCC;var brutPrice=Math.round(netPriceCC*(100+1*tmpVat))/100;var vatvalue=brutPrice-netPriceCC;line_brutsum =tmpAmount*brutPrice;line_vat=line_brutsum-line_netsum;full_netsum+=line_netsum;full_vat+=line_vat;full_brutsum+=line_brutsum;var tmpIN=mainCycle.toString();}cno=0;mainCycle++;}else{cno++;}
x1++;x0=x1+1;}x1++;}if (mainCycle>0){mainCycle--;}
var outSTR="<table class=\""+xClass+"\" style=\""+xEST+"\" cellpadding='0' cellspacing='0' width='100%'><tr><td class='hdl'> </td><td class='hd1'><span class='hdt'>CART</span></td><td class='hdr'> </td></tr><tr><td class='mdl'> </td><td class='txt'>";
outSTR+=" Item: "+fullAmount+"db<br>Total: "+convNum(full_brutsum,2)+" HUF.";
outSTR+="<div align=right><a href='javascript:_viewCart(document._rdr_x)'><font size=1>DETAILS</font></a></td><td class='mdr'> </td></tr><tr><td class='ftl'> </td><td class='ftm'> </td><td class='ftr'> </td></tr></table>";
document.write(outSTR);}

/*
var e = document.getElementById(cArea); 
	if (ajax.responseStatus){
		var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
	}
	e.innerHTML = string;	

*/