//JavaScript dokument
/*
* Figyelem!! Mivel ez a class JQuery-t használ és a legtöbb esetben használunk prototype-ot is,
* ezért vagy a használt jquery-x.x.x.min.js végére célszerű beírni az alábbi sort:
* jQuery.noConflict();
* vagy a jquery-x.x.x.min.js betöltése után be kell szúrni az alábbi sort:
* jQuery.noConflict();
*
* Az options paraméterben az alábbi kulcsok szerepelhetnek:
* - urlParam: Az url-ben 'page' kulccsal átadandó paraméter.
* - padX: A kijelölt objektum és a keret közötti vízszintes távolság
* - padY: A kijelölt objektum és a keret közötti föggőleges távolság
* - borderWidth: A kerekhez használt képek pixelben mért mérete.
* - boxMargin: A doboz ilyen messzire lesz a kijelölt objektum keretétől (már ha elfér)
* - winPadding: Az ablak körvonalától ilyen távolságra nem kerül sem kijelölt objektum sem megjelenő box (már ha megoldható)
*
* A kerethez használt képek méretei az alábbiak szerint alakuljon:
* - a sarkokra kerülő képek X és Y mérete egyezzen meg
* - a függőleges keretelem szélessége egyezzen meg a sarok elem szélességével
* - a vízszintes keretelem magassága egyezzen meg a sarok elem magasságával.
*
* Az egyes dobozokhoz a következő adatokat kell/lehet megadni:
* - id (kötelező): A magyarazando elem id-ja
* - content (kötelező): A doboz tartalma
* - buttons (erősen ajánlott): A dobozban megjelenő gombok.
*   Formátum: array("következő"=>"next", "előző"=>"prev")
*   Használható értékek:
*    - "next": következő létező/látható dobozra ugrik
*    - "prev": előző lézető/látható  dobozra ugrik
*    - "close": bezárja az aktuális dobozt
*    - "go:xxx": átugrik az xxx id-val azonosított dobozra
* - boxwidth (erősen ajánlott): A doboz szélesége.
* - boxheight (erősen ajánlott): A doboz magassága. 0 esetén automatikusan méretezi, de ez Operában nem működik!!!
* - title (opcionalis): A doboz fejlécében megjelenő szöveg
* - alignx (opcionalis): Lehetséges értékek: left, center, right
* - aligny (opcionalis): Lehetséges értékek: top, middle, bottom
* - padx (opcionalis): az adott elem esetén az objektum és a keret közötti vízszintes távolság
* - pady (opcionalis): az adott elem esetén az objektum és a keret közötti függőleges távolság
*/


Tutorial=function(tourId,sourceUrl,options){
	this.initialize(tourId,sourceUrl,options);
}
jQuery.extend(Tutorial.prototype,{
	initialize:function(tourId,sourceUrl,options)
	{
		var parentThis=this;
		this.clog("Version: 2010-08-06 01:00:00");
		this.clog("options:"+options+":");
		this.clog("options:"+jQuery.param(options)+":");
		//jQuery.each(options,function(key,value){
		//	parentThis.clog(key+":"+value);
		//});

		this.isActive=false;
		this.tourId=tourId;
		this.dataStatus='none'; 
		this.sourceUrl=sourceUrl;
		
		this.hasSteps=true;
		this.curId=-1;
		this.stepNumb=0;
		
		//Alapbeallitasok.
		//Ha van options parameter, akkor ezek kozul barmelyik valtozhat 
		this.urlParam='';
		this.padX=15;//paddingX
		this.padY=15;//paddingY
		this.borderWidth=10;//borderWidth
		this.boxMargin=20;//A felugro ablak es az objektum kozotti tavolsag
		this.winPadding=20;//Ha mozgatni kell az ablakot, akkor ennyivel lejjebb-feljebb pozicionalja a kivalasztott elemet.
		this.enableClose=true;//A felugro dialog box bezarhato legyen vagy sem
		this.moveWin=true;//Mozgassa-e az ablakot
		
		this.emergency=false;//Ha ez true-ra valt, akkor nincs semmi megjelenites.
		this.noStepNumb=0;//Nemtalalhato lepesek (id-k) szama. Ha ez eleri a adat StepsData meretet, akkor this.emergency=true-ra valt 
		this.direction=0;
		this.calcWithMargin=false;//Szamoljon-e az objektum margin-javal. Meg csak terv
		
		if(options!=undefined)
		{	//Ha van options, akkor modositom az alapbeallitasokat
			if(typeof(options.urlParam)!='undefined' && options.urlParam!=''){this.urlParam=options.urlParam;this.sourceUrl+="?page="+options.urlParam;}
			if(typeof(options.padX)!='undefined' && !isNaN(options.padX)) this.padX=options.padX;
			if(typeof(options.padY)!='undefined' && !isNaN(options.padY)) this.padY=options.padY;
			if(options.borderWidth && !isNaN(options.borderWidth)) this.borderWidth=options.borderWidth;
			if(typeof(options.boxMargin)!='undefined' && !isNaN(options.boxMargin)) this.boxMargin=options.boxMargin;
			if(typeof(options.winPadding)!='undefined' && !isNaN(options.winPadding)) this.winPadding=options.winPadding;
			if(typeof(options.enableClose)!='undefined' && options.enableClose==false) this.enableClose=false;
			if(typeof(options.moveWin)!='undefined' && options.moveWin==false) this.moveWin=false;
		}
		this.clog("urlParam: "+this.urlParam);
		this.clog("padX: "+this.padX);
		this.clog("padY: "+this.padY);
		this.clog("borderWidth: "+this.borderWidth);
		this.clog("boxMargin: "+this.boxMargin);
		this.clog("winPadding: "+this.winPadding);
	},
	
	loadData : function()
	{
		this.clog("dataStatus: "+this.dataStatus);
		if(this.dataStatus=='none')
		{
			this.dataStatus='loading';
			this.clog("dataStatus: "+this.dataStatus);			
			var tutObj=this;
			
			jQuery.ajax({
				type: "POST",
				url: tutObj.sourceUrl,
				async: false,
				dataType: "json",
				success: function(req){
					tutObj.StepsData = req;
					tutObj.clog("StepsData: "+tutObj.StepsData);
					tutObj.stepNumb=0;//Ezt majd ugyis atallitom
					tutObj.dataStatus='loaded';
					tutObj=null;
				}
			});
			
			this.clog("end dataStatus: "+this.dataStatus);
		}
	},
	
	showCurrentStep : function()
	{
		if(!this.emergency)
		{
			this.isActive=true;
			this.loadData();
			this.setCurrentStep();
			this.createBorder();
			this.showBox();
		}
	},
	
	setCurPositions : function()
	{
		if(!this.emergency)
		{
			this.clog("setCurPositions");
			if(this.currentStep!=null)
			{
				var win = jQuery(window);
				var curStep=this.currentStep;
				//this.clog("curStep OK");
				
				var objAbsPos=curStep.offset(); //Az elem pozicioja az oldal tetejetol (nem az aktualis ablak tetejetol!)
				
				this.objAbsTop=Math.round(objAbsPos.top);
				this.objAbsLeft=Math.round(objAbsPos.left);
				
				this.objOuterWidth=Math.round(curStep.outerWidth()); //Margin nelkul
				this.objOuterHeight=Math.round(curStep.outerHeight());
				this.clog("objOuterWidth: "+this.objOuterWidth);
				this.clog("objOuterHeight: "+this.objOuterHeight);
				this.objOuterWidthTrue=Math.round(curStep.outerWidth(true)); //Marginnal (haat, van itt hiba, mert 0 eseten is hozzaad bizonyos erteket FF-ben biztos)
				this.objOuterHeightTrue=Math.round(curStep.outerHeight(true));
				this.clog("objOuterWidthTrue: "+this.objOuterWidthTrue);
				this.clog("objOuterHeightTrue: "+this.objOuterHeightTrue);
				this.objWidth=Math.round(curStep.width()); //Border es padding nelkul
				this.objHeight=Math.round(curStep.height());
				this.clog("objWidth: "+this.objWidth);
				this.clog("objHeight: "+this.objHeight);
				this.objAbsBottom=this.objAbsTop+this.objHeight;
				
				this.objMarginTop=parseInt(curStep.css('marginTop'));
				this.objMarginRight=parseInt(curStep.css('marginRight'));
				this.objMarginBottom=parseInt(curStep.css('marginBottom'));
				this.objMarginLeft=parseInt(curStep.css('marginLeft'));
				if(isNaN(this.objMarginTop)) this.objMarginTop=0;
				if(isNaN(this.objMarginRight)) this.objMarginRight=0;
				if(isNaN(this.objMarginBottom)) this.objMarginBottom=0;
				if(isNaN(this.objMarginLeft)) this.objMarginLeft=0;
				this.clog("objMarginTop: "+this.objMarginTop);
				this.clog("objMarginRight: "+this.objMarginRight);
				this.clog("objMarginBottom: "+this.objMarginBottom);
				this.clog("objMarginLeft: "+this.objMarginLeft);

				this.objBorderTopWidth=parseInt(curStep.css('borderTopWidth'));
				this.objBorderRightWidth=parseInt(curStep.css('borderRightWidth'));
				this.objBorderBottomWidth=parseInt(curStep.css('borderBottomWidth'));
				this.objBorderLeftWidth=parseInt(curStep.css('borderLeftWidth'));
				if(isNaN(this.objBorderTopWidth)) this.objBorderTopWidth=0;
				if(isNaN(this.objBorderRightWidth)) this.objBorderRightWidth=0;
				if(isNaN(this.objBorderBottomWidth)) this.objBorderBottomWidth=0;
				if(isNaN(this.objBorderLeftWidth)) this.objBorderLeftWidth=0;
				this.clog("objBorderTopWidth: "+this.objBorderTopWidth);
				this.clog("objBorderRightWidth: "+this.objBorderRightWidth);
				this.clog("objBorderBottomWidth: "+this.objBorderBottomWidth);
				this.clog("objBorderLeftWidth: "+this.objBorderLeftWidth);

				this.objPaddingTop=parseInt(curStep.css('paddingTop'));
				this.objPaddingRight=parseInt(curStep.css('paddingRight'));
				this.objPaddingBottom=parseInt(curStep.css('paddingBottom'));
				this.objPaddingLeft=parseInt(curStep.css('paddingLeft'));
				if(isNaN(this.objPaddingTop)) this.objPaddingTop=0;
				if(isNaN(this.objPaddingRight)) this.objPaddingRight=0;
				if(isNaN(this.objPaddingBottom)) this.objPaddingBottom=0;
				if(isNaN(this.objPaddingLeft)) this.objPaddingLeft=0;
				this.clog("objPaddingTop: "+this.objPaddingTop);
				this.clog("objPaddingRight: "+this.objPaddingRight);
				this.clog("objPaddingBottom: "+this.objPaddingBottom);
				this.clog("objPaddingLeft: "+this.objPaddingLeft);

				this.objWidth=this.objWidth+this.objPaddingLeft+this.objPaddingRight+this.objBorderLeftWidth+this.objBorderRightWidth+this.objMarginLeft+this.objMarginRight;
				this.objHeight=this.objHeight+this.objPaddingTop+this.objPaddingBottom+this.objBorderTopWidth+this.objBorderBottomWidth+this.objMarginTop+this.objMarginBottom;
				//Az IE nem jol adja vissza a .width()-et es a .height()-et ezert a fejbecsapas
				this.objWidth=this.objOuterWidthTrue;
				this.objHeight=this.objOuterHeightTrue;
				this.clog("newobjWidth: "+this.objWidth);
				this.clog("newobjHeight: "+this.objHeight);
				
				this.winTop=Math.round(win.scrollTop()); //Fuggoleges gorgetes merteke
				this.winHeight=win.height();
				this.winBottom=this.winTop+this.winHeight; //Ablak also koordinataja
				
				this.winLeft=Math.round(win.scrollLeft());
				this.winWidth=win.width();
				this.winRight=this.winLeft+this.winWidth; 
				this.clog("winLeft: "+this.winLeft);
				
				this.objRelTop=Math.round(this.objAbsTop-this.winTop);
				this.objRelLeft=Math.round(this.objAbsLeft-this.winLeft);
				this.objRelRight=this.objRelLeft+this.objWidth;
				
				//Nezzuk, hol van tobb hely...
				if(this.objRelLeft-this.winLeft >= this.winRight-this.objRelRight)
				{	//Balra tobb hely van
					this.boxLeft=this.objRelLeft - this.padX - this.borderWidth - this.boxMargin - this.dataRow.BoxWidth;
					if(this.boxLeft<this.winPadding) this.boxLeft=this.winPadding;
				}
				else
				{	//Jobba kell keruljon...
					this.clog("jobb objRelLeft: "+this.objRelLeft);
					this.clog("jobb objWidth: "+this.objWidth);
					this.boxLeft=this.objRelLeft + this.objWidth + this.padX + this.borderWidth + this.boxMargin;
					this.clog("jobb1 this.boxLeft: "+this.boxLeft);
					if(this.boxLeft+this.dataRow.BoxWidth>this.winWidth)
						this.boxLeft=this.winWidth-this.winPadding-this.dataRow.BoxWidth;
					this.clog("jobb2 this.boxLeft: "+this.boxLeft);
				}
	
	
				this.clog("1 this.boxLeft: "+this.boxLeft);
				
				this.clog("objAbsTop: "+this.objAbsTop);
				this.clog("objAbsLeft: "+this.objAbsLeft);
				this.clog("objRelTop: "+this.objRelTop);
				this.clog("objRelLeft: "+this.objRelLeft);
				this.clog("boxWidth: "+this.dataRow.BoxWidth);
				this.clog("winWidth: "+win.width());
				this.clog("winTop: "+this.winTop);
				this.clog("winHeight: "+this.winHeight);
				this.clog("winBottom: "+this.winBottom);
				
				//if(this.objAbsTop > this.winBottom || this.objAbsTop < this.winTop)
				if((this.objAbsBottom > this.winBottom || this.objAbsTop < this.winTop) && this.moveWin)
				{
					win.scrollTop(this.objAbsTop - this.padY - this.borderWidth - this.winPadding);
					this.clog("uj winTop: "+(this.objAbsTop - this.padY - this.borderWidth - this.winPadding));
					
					win=jQuery(window);
					curStep=this.currentStep;
					
					objAbsPos=curStep.offset(); //Az elem pozicioja az oldal tetejetol (nem az aktualis ablak tetejetol!)
					this.winTop = Math.round(win.scrollTop());
					this.objRelTop=Math.round(this.objAbsTop-this.winTop);
					this.clog("objRelTop: "+this.objRelTop);
				}
				this.boxTop=this.objRelTop;
			}
			this.clog("setCurPositions Done");
		}
	},
	
	startTutorial : function()
	{
		this.clog("startTutorial Start");
		this.loadData();
		this.stepNumb=0;
		this.showCurrentStep();
		this.clog("startTutorial End");
	},
  
	showThisStep : function(thisId)
	{
		this.clog("showThisStep Start");
		this.clog("parameter thisId:"+thisId+":");

		var parentThis=this;
		jQuery.each(thisId,function(key,value){
			parentThis.clog(key+":"+value);
		});

		this.closeBox();
		this.stepNumb=this.getStepNumber(thisId);
		this.showCurrentStep();
		this.clog("showThisStep End");
	},
  
	showNextStep : function()
	{
		this.closeBox();
		this.setNextStep();
		this.showCurrentStep();
	},
	
	showPrevStep : function()
	{
		this.closeBox();
		this.setPrevStep();
		this.showCurrentStep();
	},
	
	setCurrentStep : function()
	{
		this.clog("setCurrentStep");
		this.clog("this.stepNumb: "+this.stepNumb);
		this.setCurrentDataRow();
		
		this.curId=this.dataRow.Id;
		this.clog("this.curId: "+this.curId);
		
		if(this.curId!=0)
		{
			this.currentStep=jQuery('#'+this.curId);
	
			//if(this.currentStep!=null) //Mindig objektumot ad vissza
			//Nezni kell a display es a visibility tulajdonsagot is
			this.clog("id:"+this.currentStep.attr("id")+":");
			this.clog("display:"+this.currentStep.css('display')+":");
			this.clog("visibility:"+this.currentStep.css('visibility')+":");
			if(this.currentStep.attr("id")!=undefined && this.currentStep.css('display')!="none" && this.currentStep.css('visibility')!="hidden")
			{
				this.clog("currentStep is not null: "+this.currentStep);
				this.clog("currentStep.id: "+this.currentStep.attr("id"));
				this.clog("currentStep.nodeName: "+this.currentStep[0].nodeName);
				
				var tutObj=this;
				this.noStepNumb=0;//noStepNumb reset
				
				this.currentStep.addClass("tutorial_step");
				this.setCurPositions();
				jQuery('#ui-dialog-title-'+this.tourId).html(this.dataRow.StepTitle);
				jQuery('#'+this.tourId).html(this.dataRow.StepContent);
				
				if(this.enableClose!=true)
				{
					this.clog("remove Close X");
					jQuery("div[aria-labelledby='ui-dialog-title-"+this.tourId+"'] a.ui-dialog-titlebar-close").remove();
				}
				
				jQuery('#'+this.tourId).dialog("option","width",this.dataRow.BoxWidth);
				//Operaban nem működik a doboz magasságának beállítása!! 10.60-as verziótól mar nincs vele gond.
				if(this.dataRow.BoxHeight>0) jQuery('#'+this.tourId).dialog("option","height",this.dataRow.BoxHeight);
				
				var options=new Object();
				//this.clog(this.dataRow.Buttons);
				var buttons=this.dataRow.Buttons; //jQ
				
				jQuery.each(buttons,function(key,value){ //jQ
					var command;
					var cmdStrArr=value.split(":"); //jQ
					var cmdStr=cmdStrArr[0];
					var idStr=cmdStrArr[1];
					
					if(cmdStr=='go'&&(idStr==undefined||idStr==''))cmdStr='next';//Balazs kerte, h bolondbiztos legyen.
					
					tutObj.clog("cmdStr:"+cmdStr+":");
					switch(cmdStr)
					{
						default:
						case "next":        command=jQuery.proxy(tutObj.showNextStep, tutObj); break; //jQ
						case "prev":        command=jQuery.proxy(tutObj.showPrevStep, tutObj); break; //jQ
						case "close":       command=jQuery.proxy(tutObj.closeBox, tutObj); break; //jQ
						case "go":          command=jQuery.proxy(function(){tutObj.showThisStep(idStr);}, tutObj); break; //jQ
                        case "javascript":	command=jQuery.proxy(function(){eval(idStr);}, tutObj); break; //csak egy funckio lehet paraméterekkel
					}
					tutObj.clog("command: "+command);
					options[key]=command; //jQ
								
				});
				
				jQuery('#'+this.tourId).dialog("option","buttons",options);
			}
			else
			{
				//alert("Nem létező step ("+this.curId+")!!");
				this.noStepNumb++;
				//if(this.noStepNumb>=this.StepsData.size()) this.emergency=true;
				if(this.noStepNumb>=this.StepsData.length) this.emergency=true;
				//if(this.noStepNumb>=1) this.emergency=true; //TESTONLY!!
				if(this.direction>-1) this.setNextStep();
				else this.setPrevStep();
				this.setCurrentStep();
			}
		}
		else
		{
			//alert("A megadott id-hoz nem tartozik help! (Id: "+this.curId+")!!");
			this.emergency=true;
		}
	},
	
	setNextStep : function()
	{
		if(this.hasSteps)
		{
			this.direction=1;
			this.clog("this.StepsData.length:"+this.StepsData.length);
			if(this.stepNumb<(this.StepsData.length-1))
				this.stepNumb++;
			else
				this.stepNumb=0;
		}
	},
	
	setPrevStep : function()
	{
		if(this.hasSteps)
		{
			this.direction=-1;
			if(this.stepNumb>0)
				this.stepNumb--;
			else
				this.stepNumb=this.StepsData.length-1;
		}
	},
	
	setCurrentDataRow : function()
	{
		this.clog("setCurrentDataRow start");
		if(typeof(this.stepNumb) != 'undefined' && typeof(this.StepsData) != 'undefined' && this.StepsData[this.stepNumb]!=null)
		{
			var item=this.StepsData[this.stepNumb];
			this.dataRow = {
				Id : item.id,
				StepContent : item.content,
				Buttons : item.buttons,
				BoxWidth : parseInt(item.boxwidth),
				BoxHeight : parseInt(item.boxheight)
			};

			if(item.title!=undefined) this.dataRow.StepTitle = item.title;
			else this.dataRow.StepTitle = '';

			if(item.alignx!=undefined) this.dataRow.alignx = item.alignx;
			else this.dataRow.alignx = '';

			if(item.aligny!=undefined) this.dataRow.aligny = item.aligny;
			else this.dataRow.aligny = '';
			
			if(item.padx!=undefined) this.dataRow.padX = parseInt(item.padx);
			else this.dataRow.padX = '';
			
			if(item.pady!=undefined) this.dataRow.padY = parseInt(item.pady);
			else this.dataRow.padY = '';
		}
		else this.dataRow={Id:0};
		this.clog("setCurrentDataRow end");
	},
	
	showBox : function()
	{
		if(!this.emergency)
		{
			this.clog("showBox");
			this.clog("boxLeft: "+this.boxLeft);
			this.clog("boxTop: "+this.boxTop);
			if(this.dataRow.alignx!='') var left = this.dataRow.alignx;
			else var left = this.boxLeft;
			if(this.dataRow.aligny!='') var top = this.dataRow.aligny;
			else var top = this.boxTop;
			jQuery('#'+this.tourId).dialog('option',"position", [left,top]);
			jQuery('#'+this.tourId).dialog('open');
			//Az Operaban nem működik a doboz magasságának beállítása
			//if(this.dataRow.BoxHeight>0) jQuery('#'+this.tourId).height(150); //Ez sem segített
			this.isActive=true;//Ez mar talana hamarabb is megtortenhet
			this.clog("showBox Done");
		}
	},
	
	closeBox : function()
	{
		this.clog("closeBox");
		this.currentStep.removeClass("tutorial_step");
		this.clog("removeClass");
		this.deleteBorder();
		this.clog("deleteBorder");
		jQuery('#'+this.tourId).dialog("close");
		this.clog("dialog(close)");
		this.isActive=false;
	},
	
	resetTutorial : function()
	{
		this.stepNumb=0;
		this.setCurrentStep();
	},
	
	createBorder : function()
	{
		if(!this.emergency)
		{
			var curStep=this.currentStep;
			var bW=this.borderWidth;
			
			var padX;
			var padY;
			
			if(this.dataRow.padX!='') padX=this.dataRow.padX;
			else padX=this.padX;
			
			if(this.dataRow.padY!='') padY=this.dataRow.padY;
			else padY=this.padY;
			
			var parW=this.objWidth;
			var parH=this.objHeight;
			
			var margT=this.objMarginTop;
			var margR=this.objMarginRight;
			var margB=this.objMarginBottom;
			var margL=this.objMarginLeft;
			
			var bordT=this.objBorderTopWidth;
			var bordR=this.objBorderRightWidth;
			var bordB=this.objBorderBottomWidth;
			var bordL=this.objBorderLeftWidth;
			
			var bT=document.createElement('DIV');
			bT.className='tbord tbord-t';
			var cssString='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY-bW))+'px;width:'+(parW+(padX*2))+'px;height:'+bW+'px;';
			this.clog("cssString: "+cssString);
			bT.style.cssText='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY-bW))+'px;width:'+(parW+(padX*2))+'px;height:'+bW+'px;';
			curStep.append(bT);
			
			var bTR = document.createElement('DIV');
			bTR.className = 'tbord tbord-tr';
			bTR.style.cssText = 'left:'+this.getDistStr(this.modX0(parW-bordL-margL+padX))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY-bW))+'px;width:'+bW+'px;height:'+bW+'px;';
			curStep.append(bTR);
			
			var bR=document.createElement('DIV');
			bR.className='tbord tbord-r';
			bR.style.cssText='left:'+this.getDistStr(this.modX0(parW-bordL-margL+padX))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY))+'px;width:'+bW+'px;height:'+(parH+(padY*2))+'px;';
			curStep.append(bR);
			
			var bBR=document.createElement('DIV');
			bBR.className='tbord tbord-br';
			bBR.style.cssText='left:'+this.getDistStr(this.modX0(parW-bordL-margL+padX))+'px;top:'+this.getDistStr(this.modY0(parH-bordT-bordB-margB+padY))+'px;width:'+bW+'px;height:'+bW+'px;';
			curStep.append(bBR);
			
			var bB=document.createElement('DIV');
			bB.className='tbord tbord-b';
			bB.style.cssText='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX))+'px;top:'+this.getDistStr(this.modY0(parH-bordT-bordB-margB+padY))+'px;width:'+(parW+(padX*2))+'px;height:'+bW+'px;';
			curStep.append(bB);
			
			var bBL=document.createElement('DIV');
			bBL.className='tbord tbord-bl';
			bBL.style.cssText='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX-bW))+'px;top:'+this.getDistStr(this.modY0(parH-bordT-bordB-margB+padY))+'px;width:'+bW+'px;height:'+bW+'px;';
			curStep.append(bBL);
			
			var bL=document.createElement('DIV');
			bL.className='tbord tbord-l';
			bL.style.cssText='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX-bW))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY))+'px;width:'+bW+'px;height:'+(parH+(padY*2))+'px;';
			curStep.append(bL);
			
			var bTL=document.createElement('DIV');
			bTL.className='tbord tbord-tl';
			bTL.style.cssText='left:'+this.getDistStr(this.modX0(0-bordL-margL-padX-bW))+'px;top:'+this.getDistStr(this.modY0(0-bordT-margT-padY-bW))+'px;width:'+bW+'px;height:'+bW+'px;';
			curStep.append(bTL);
		}
	},
	
	modX0:function(pX)
	{	//Nem jo, mert a kulonbozo bongeszokben elteroen szamol
		return pX;
		if(this.currentStep[0].nodeName=='BUTTON') return pX-this.objPaddingLeft;
		else return pX;
	},
	
	modY0:function(pY)
	{	//Nem jo, mert a kulonbozo bongeszokben elteroen szamol
		return pY;
		if(this.currentStep[0].nodeName=='BUTTON') return pY-this.objPaddingTop;
		else return pY;
	},
	
	getDistStr:function(dist)
	{
		if(dist<0) return "-"+Math.abs(dist);
		else return Math.abs(dist);
	},
	
	getStepNumber : function(sId)
	{
		var rV=-1;
		var stop;
		this.loadData();//Ha mar van adat, akkor ugysem csinal semmit...
		//this.StepsData.each(function(p,key) {
		//	if(stop)return;      
		//	if(p.id == sId){rV=key;stop=true;}
		//});
		jQuery.each(this.StepsData,function(key,value) {
			if(stop)return;      
			if(value.id == sId){rV=key;stop=true;}
		});
		return rV;
	},
	
	isActive:function(){return this.isActive;},
	deleteBorder : function(){jQuery('.tbord').remove();},
	clog:function(s){if( (typeof(console)!='undefined'))console.log(s);}
});
