/*
version 1.5

- tab size 2
===================
fix scrolling
resize immagine
tweet
permalink
===================

iframe navigation ->
see this
vedere!!!
http://developer.apple.com/internet/webcontent/iframe.html

http://www.sebastian.it/wordpress/wp-content/themes/revolucion/javascript/core.js

https://www.allposters.com/-st/Vintage-Art-Posters_c2152_.htm
http://eu.art.com/gallery/id--c1837/posters.htm
http://eu.art.com/products/p12544175-sa-i1905638/ken-bailey-bostons-best-cream-pie.htm?sorig=cat&sorigid=0&dimvals=1837&ui=5711d9834b194aacb18161a4b58d1544

http://www.flickr.com/photos/pauliusportfolio/3399350453/in/pool-thegridsystem/

http://www.epiloguemagazine.com/contributors.html

http://www.aisleone.net/about/

http://www.yearofthesheep.com/typography/enotmik/

http://www.legistyles.com/
*/
var globalSettings={};
var U=Segunda.Utils;
var $=U.$;

//disable auto z-index adjustment during element dragging
Segunda.Ui.autoAdjustZIndex=0;
/*
since after segunda revision 51 we have a great speed increase set to
100 cycles per second
*/
Segunda.Clock.set(10);

globalSettings.currentMenuPage='';


globalSettings.mapLinks=[
'<div class="rlink fuchsia" style="left:90px;margin-top:-404px;"><a onclick="globalSettings.showThrobber()" target="hidden" href="'+PAGES_DIRECTORY+'/linkparser/?category=5">graphic resources</a></div>',
'<div class="rlink fuchsia" style="left:-1px;margin-top:-365px;"><a onclick="globalSettings.showThrobber()" target="hidden" href="'+PAGES_DIRECTORY+'/linkparser/?category=6">vector Gfx</a></div>',
'<div class="rlink cyan" style="left:103px;margin-top:-540px;"><a onclick="globalSettings.showThrobber()" target="hidden" href="'+PAGES_DIRECTORY+'/cessing">CeSSing</a></div>'
];

globalSettings.aboutMeLinks=[
'<div class="rlink blue" style="position:absolute;left:1920px;top:198px;"><a onclick="globalSettings.showThrobber()" target="hidden" href="'+PAGES_DIRECTORY+'/g4t0l0c0">g4t0l0c0</a></div>',
];


globalSettings.help=[];
globalSettings.help['hbar']='click & drag to navigate main menu';
globalSettings.help['postDataTogle_show']='click to reveal main content';
globalSettings.help['postDataTogle_hide']='click to hide main content';

globalSettings.help['sideBarTogle_show']='click to reveal secondary content';
globalSettings.help['sideBarTogle_hide']='click to hide secondary content';

globalSettings.help['vbar2']='click & drag to scroll main content and hide main menu';
globalSettings.help['vbar2Reset']='click to reset vertical bar position and reveal main menu';
globalSettings.help['inspectBar']='click & drag to scroll art';
globalSettings.help['sizeBar']='click & drag to resize art';
globalSettings.help['printableicon']='click to open a new window with a printer friendly version of current content';
globalSettings.help['permalinkicon']='permanent link to current content. Drag to your favorites to bookmark';

globalSettings.sideBarDisplay='block';
globalSettings.verticalScrollPowerUp=1; //mul
globalSettings.horizontalScrollPowerUp=0; //add

globalSettings.showInfo=function(sId) {
  var sHelp=globalSettings.help[sId];
  if (typeof sHelp!='undefined')
    $('infotext').innerHTML=sHelp;
  else  
    $('infotext').innerHTML=sId;
}
globalSettings.hideInfo=function(sId) {
  $('infotext').innerHTML='';
}

globalSettings.hasUserId=0;

globalSettings.checkcmt=function(o) {
	try {
		globalSettings.checkcmt_authorOk=0;
		globalSettings.checkcmt_emailOk=0;
		globalSettings.checkcmt_commentOk=0;
		if (typeof $('author')=='undefined' || $('author')==null) {
			globalSettings.checkcmt_authorOk=1;
			globalSettings.checkcmt_emailOk=1;
		}
		if (typeof $('author')!='undefined' && $('author')!=null)
			if ($('author').value!='')
				globalSettings.checkcmt_authorOk=1
		if (typeof $('email')!='undefined' && $('email')!=null)
			if ($('email').value!='')
				globalSettings.checkcmt_emailOk=1;
		if ($('comment').value!='')
			globalSettings.checkcmt_commentOk=1;
		if (
			globalSettings.checkcmt_authorOk && globalSettings.checkcmt_emailOk &&
			globalSettings.checkcmt_commentOk
		) {
			$('submit').style.opacity=1;
			$('submit').onclick=null;
		} else {
			$('submit').style.opacity=.4;
			$('submit').onclick=new Function("return false");
		}
	} catch(er) {
		
	}
	//console.log(globalSettings.checkcmt_authorOk,globalSettings.checkcmt_emailOk,globalSettings.checkcmt_commentOk);
}
globalSettings.checkcmt_authorOk=0;
globalSettings.checkcmt_emailOk=0;
globalSettings.checkcmt_commentOk=0;
globalSettings.imageLoaded=0;
globalSettings.imageHorizontalFreeDragging=0;

globalSettings.parseLoadedContent=function(o) {
	try {
	  var bodyId=o.contentWindow.document.body.id;
		//console.log(bodyId);
		switch (bodyId) {
			case 'error-page':
				var content=o.contentWindow.document.body.innerHTML;
				$('errormsg').innerHTML=content;
			  $('errormsg').style.display='block';
				$('errormsg').style.opacity=1;
        globalSettings.hideErrorMsg.play({wait:2000});
			break;
		  case 'imageGallery':
				if (!WPD.globalSettings.imageLoaded)
				globalSettings.showThrobber();
			break;
		  default:
        globalSettings.hideThrobber();			
			  $('errormsg').style.display='none';
			break;
		}
	  globalSettings.checkcmt();	
	} catch(er) {
	}	
	var contentHeight=$('content').offsetHeight;
	if ($('contentSideBar'))
    $('contentSideBar').style.top=contentHeight+'px';
}

globalSettings.setVisibility=function() {
  $('theimage').style.height='';
	if (U.def(globalSettings.autoHideMenu) && globalSettings.autoHideMenu) {
		//alert('x');
		//$('bar0').style.opacity=0;
		$('vbar2').style.visibility='hidden';
		$('vbar2Reset').style.opacity=1;
		$('inspectBar').style.opacity=.5;
		$('sizeBar').style.opacity=.5;
		//$('topmenu').style.opacity=0;
		//$('hbar').style.opacity=0;
	}	else {
		//alert('y');
		//$('bar0').style.opacity=1;//opacityVariable; //opacity auto hide
		$('vbar2Reset').style.opacity=1;
		$('vbar2').style.visibility='visible';
		$('inspectBar').style.opacity=0;
		$('sizeBar').style.opacity=0;
	}
}

globalSettings.hideErrorMsg=Segunda.Animator.define({
  objects:['errormsg'],
  animation:[
    {properties:['opacity'],duration:500,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}  
  ]
});

globalSettings.hideLoader=Segunda.Animator.define({
  objects:['loader'],
  animation:[
    {properties:['opacity'],duration:300,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}  
  ]
});
//--
globalSettings.showThrobberAnim=Segunda.Animator.define({
  objects:['th'],
  animation:[
    {properties:['display'],duration:100,from:[],to:['block']},    
    {properties:['opacity'],duration:300,from:[0],to:[1]}
  ]
});
//--
globalSettings.hideThrobberAnim=Segunda.Animator.define({
  objects:['th'],
  animation:[
    {properties:['opacity'],duration:300,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}    
  ]
});
//--
globalSettings.hideContentAnim=Segunda.Animator.define({
  objects:['content_content'],
  animation:[
    {properties:['opacity'],duration:300,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}    
  ]
});
//--
globalSettings.showContentAnim=Segunda.Animator.define({
  objects:['content_content'],
  animation:[
    {properties:['display'],duration:100,from:[],to:['block']},    
    {properties:['opacity'],duration:300,from:[0],to:[1]}  
  ]
});
//--
globalSettings.hideArtAnim=Segunda.Animator.define({
  objects:['imagediv'],
  animation:[
    {properties:['opacity'],duration:300,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}    
  ]
});
//--
globalSettings.showArtAnim=Segunda.Animator.define({
  objects:['imagediv'],
  animation:[
    {properties:['display'],duration:100,from:[],to:['block']},    
    {properties:['opacity'],duration:300,from:[0],to:[1]}  
  ]
});

globalSettings.showThrobber=function() {
  globalSettings.hideThrobberAnim.pause();
  globalSettings.showThrobberAnim.play();
	
}
globalSettings.hideThrobber=function() {
  globalSettings.hideThrobberAnim.play();
}

globalSettings.pageLoaded=function() {
  globalSettings.hideLoader.play();
}

globalSettings.pageReady=function() {
  window.scroll(0,0); //reset scrolling
  globalSettings.hideThrobberAnim.play();
}


//globalSettings.hideThrobberAnim
/*
globalSettings.hideThrobberAnim=Segunda.Animator.define({
  objects:['th'],
  animation:[
    {properties:['opacity'],duration:300,from:[1],to:[0]},
    {properties:['display'],duration:100,from:[],to:['none']}    
  ]
});

*/

/*
globalSettings.flyAroundAnim=Segunda.Animator.define({
	objects:[
		{}
	],
	animation:[
		{
			properties:[
				function(o,value) {
					if (typeof value!='undefined') {//write mode -> do something
						o.value=value; //needed
						globalSettings.horizontalScrollPowerUp=value;
						globalSettings.wMain.elements['hbar'].click(); //simulate hori scrollbar click
					}	
					return o.value; //needed
				}
			],duration:1000,from:[0],to:[2500],easing:[Segunda.Animator.Easing.expo.easeOut]}
	]
});
*/


globalSettings.currentHScrollValue=0;

globalSettings.flyAround=function(o) {
  var xto=o.to;

	var anim=Segunda.Animator.define({
		objects:[
			{}
		],
		animation:[
			{
				properties:[
					function(o,value) {
						if (typeof value!='undefined') {//write mode -> do something
							o.value=value; //needed
							globalSettings.horizontalScrollPowerUp=value;
							globalSettings.wMain.elements['hbar'].click(); //simulate hori scrollbar click
						}	
						return o.value; //needed
					}
				],
				duration:1000,from:[globalSettings.currentHScrollValue],
				to:[xto],easing:[Segunda.Animator.Easing.expo.easeOut],
				onEnd:[
					function() {
						//console.log(o);
						if (o.hide) {
							var $=Segunda.Utils.$;
							for (var z=0,zEnd=o.hide.length;z<zEnd;z++) {
								//console.log($(o.hide[z]));
								$(o.hide[z]).style.display='none';
							}
						}		
  				}
				]
			}
		]
	});

	globalSettings.currentHScrollValue=xto;

  if (o.show) {
		var $=Segunda.Utils.$;
		for (var z=0,zEnd=o.show.length;z<zEnd;z++) {
			//console.log($(o.hide[z]));
			$(o.show[z]).style.display='block';
		}
	}		
	anim.play();
	//console.log(globalSettings.wMain);
}

function offLeafs() {
	var sId=globalSettings.sId;
  var leafs=U.domWalker({node:sId,getNodeWithChildren:false});
	for (var z=0,zEnd=leafs.length;z<zEnd;z++) {
		if (leafs[z].tagName=='A') {
			leafs[z].className='leaflink';
		}	
	}	
}

function selectLeaf(event) {
	//attach events to leafs
	offLeafs();
	var obj=event.currentTarget;
	obj.className='leaflinkselected';
	//console.log(obj);
}

function toggleMenu(event) {
	var startIndex=2; //first child node to inspect
	event.cancelBubble=true;
	var obj=event.currentTarget;	
	var next_nodes=U.domWalker({node:obj.childNodes[startIndex],getNodeWithDepthLessThan:2}); //include itself
	if (!next_nodes)
	  return;
	var next_node=next_nodes[1];
	if (!next_node)
	  return;	
	var action=(next_node.style.display=='block')?'none':'block';
	var icon=(next_node.style.display=='block')?'+':'-';
	var iClass=(next_node.style.display=='block')?'folder_closed':'folder_open';
  var children=U.domWalker({node:obj.childNodes[startIndex],getNodeWithDepthLessThan:2});
	for (var z=0,zEnd=children.length;z<zEnd;z++) {
		if (children[z].id!=obj && (children[z].tagName=='UL' || children[z].tagName=='LI')) {
			children[z].parentNode.childNodes[0].innerHTML=icon;
			children[z].parentNode.childNodes[0].className='folder '+iClass;
			children[z].style.display=action;// (children[z].style.display=='block')?'none':'block';
		}	
	}

}

function initMenu(sId) {
	globalSettings.sId=sId;
  var textNodes=U.domWalker({node:sId,getNodeType:3}); //https://developer.mozilla.org/en/Whitespace_in_the_DOM
	if (!textNodes)
	  return;

	for (var z=0,zEnd=textNodes.length;z<zEnd;z++) {
			var sp=document.createElement('div');
  		if (textNodes[z].nextSibling) {
			  sp.className='folder folder_closed';
  			sp.innerHTML='+'; //add folder like icon
  		} else {	 
			  sp.className='folder leaf';
  			sp.innerHTML='&nbsp;'; //add leaf like icon
			}	
			textNodes[z].parentNode.insertBefore(sp,textNodes[z]);
		  //textNodes[z].value='<span class="folder_closed">+</span>'+textNodes[z].textContent;
	}	

	//attach events to folders
  var folders=U.domWalker({node:sId,getNodeWithChildren:true});
	for (var z=0,zEnd=folders.length;z<zEnd;z++) {
		if (folders[z].id!=sId && folders[z].tagName=='LI') {
			folders[z].style.cursor='default';
			folders[z].id='xxmenu'+(z);
			folders[z].onclick=toggleMenu;// new Function("toggleMenu(e,'xxmenu"+z+"');");
		}	
	}
	//attach events to leafs
  var leafs=U.domWalker({node:sId,getNodeWithChildren:false});
	for (var z=0,zEnd=leafs.length;z<zEnd;z++) {
		if (leafs[z].tagName=='A') {
			leafs[z].onclick=selectLeaf;// new Function("toggleMenu(e,'xxmenu"+z+"');");
		}	
	}	
	//hide menu voices
  var objs=Segunda.Utils.domWalker({node:sId,getNodeWithDepthGreaterThan:1});
	for (var z=0,zEnd=objs.length;z<zEnd;z++) {
		if (objs[z].tagName=='UL' || objs[z].tagName=='LI') {
			objs[z].style.display='none';
		}
	}
}


/*
function main_disabled() {
  //load graphics
  //initialize sprite object 
  Segunda.Sprites.totalImagesToLoad=3; //set the number of images we need to be loaded before starting
  Segunda.Sprites.onReady=function() { //launch this function when all sprite images are loaded
    main2({portraits:portraits}); //pass some variables so we do not have to declare global vars
  }
  var portraits=Segunda.Sprites.define({ //create tile canvas sprites from stylesheet
    cssSelector:'portrait_',styleSheetIndex:1 //return an array having the classname as an index
  });
	
} 
*/

function main(o) {

  //console.log(navigator.userAgent);
  if (!navigator.userAgent.match(/firefox/i)) { //try to disabled unwanted text selection for other browsers (use -moz-user-select with firefox)
    document.body.onmousedown=function(e){          
      var sid=e.target.id;
      var goOn=true;
      //alert(sid);
      switch (sid) {
        case 'content': goOn=true;break; //override main
        case 'main':
        case 'inspectBar':
        case 'sizeBar':
        case 'hbar':
        case 'bar0':
        case 'bar0b':
        case 'footer':
        case 'vbar2':
          goOn=false;
      }  
      return goOn;
    }
	}	

  //$('hif').src='blank.html';
	try {
    revolucion_init();
	} catch(er) {
		setTimeout(function(){main(o)},100);
		return;
	}	

  replace({font:'revo_A',el:$('topmenu')});
	replace({font:'revo_C',el:$('copyright')});

  globalSettings.pageLoaded();
	
  globalSettings.wMain=Segunda.Window.define({ //create an application window
    movable:false,contentId:'main',
		handlers:[
/*
			{
				objectId:'contentFrame',
				movable:true,
				//relativePosition:false,
				relativePosition:true,
				//constraintVerticalMovement:true,
				horizontalMovementLimitLeft  : 0,
				horizontalMovementLimitRight : 'PARENT_WIDTH-OBJECT_WIDTH'
			},	
*/			
			{
				objectId:'postDataTogle',
				onActivate:function(o) { //config, element
          o.element.dom.className='M_arkanoidball';
					var vis=$('contentFrame').style.visibility;
					if (vis=='' || vis=='visible') {
						$('contentFrame').style.visibility='hidden';
						$('contentSideBar').style.display='none';
               $('vbar2').style.visibility='hidden';
					}	else {
						$('contentFrame').style.visibility='visible';
						$('contentSideBar').style.display=globalSettings.sideBarDisplay;
               $('vbar2').style.visibility='visible';
					}
          if (o.config)
            if (o.config.forceHide) {
	  			  $('contentFrame').style.visibility='hidden';
						$('contentSideBar').style.display=globalSettings.sideBarDisplay;
              $('vbar2').style.visibility='hidden';
            }  
          if (o.config)
            if (o.config.forceShowing) {
    			  $('contentFrame').style.visibility='visible';
					  $('contentSideBar').style.display=globalSettings.sideBarDisplay;
              $('vbar2').style.visibility='visible';
            }  
					/*
					hide comments and post data by modifying stylesheet on the fly... 
					 
          var ss0=U.getStyleSheetClasses({selector:'#postcomment_area',styleSheetIndex:0}); //obtain array containing all classes from stylesheet that match the selector filter
          var ss1=U.getStyleSheetClasses({selector:'#entry_data_info',styleSheetIndex:0}); //obtain array containing all classes from stylesheet that match the selector filter
					if (ss0[0].style.visibility=='hidden') {
						ss0[0].style.visibility='visible';
						ss1[0].style.visibility='visible';
					}	else {
						ss0[0].style.visibility='hidden';
						ss1[0].style.visibility='hidden';
					}
					*/
					Segunda.Timer.run({f:function(){o.element.dom.className='arkanoidball'},interval:100 });
          if ($('contentFrame').style.visibility=='hidden')
            globalSettings.showInfo(o.element.objectId+'_show');
          else  
            globalSettings.showInfo(o.element.objectId+'_hide');
				},
        onMouseOver:function(o) {
          if ($('contentFrame').style.visibility=='hidden')
            globalSettings.showInfo(o.element.objectId+'_show');
          else  
            globalSettings.showInfo(o.element.objectId+'_hide');
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        }        	
			},	

      
      
      //------------------------------------------------------------------------      
/*      
			{
				objectId:'sideBarTogle',
				onActivate:function(o) { //config, element
          o.element.dom.className='M_arkanoidball';
          var sobj='contentSidebar';
          
					var vis=$(sobj).style.visibility;
					if (vis=='' || vis=='visible') {
						$(sobj).style.visibility='hidden';
					}	else {
						$(sobj).style.visibility='visible';
					}
          if (o.config)
            if (o.config.forceHide) {
	  				  $(sobj).style.visibility='hidden';
            }  
          if (o.config)
            if (o.config.forceShowing) {
	  				  $(sobj).style.visibility='visible';
            }  
					Segunda.Timer.run({f:function(){o.element.dom.className='arkanoidball'},interval:100 });
          if ($(sobj).style.visibility=='hidden')
            globalSettings.showInfo(o.element.objectId+'_show');
          else  
            globalSettings.showInfo(o.element.objectId+'_hide');
				},
        onMouseOver:function(o) {
          if ($('contentSidebar').style.visibility=='hidden')
            globalSettings.showInfo(o.element.objectId+'_show');
          else  
            globalSettings.showInfo(o.element.objectId+'_hide');
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        }        	
			},
      
*/      	
      //------------------------------------------------------------------------      
      
      
      
			{
				objectId:'vbar2Reset',
				onActivate:function(o) {
					o.elements['vbar2'].moveToTop();
					o.element.dom.className='M_arkanoidball';
					Segunda.Timer.run({f:function(){o.element.dom.className='arkanoidball'},interval:100 });
					//o.
					//$('vbar2').style.top='35px';
				},
        onMouseOver:function(o) {
          globalSettings.showInfo(o.element.objectId);
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        }        	
			},	

			{
				objectId:'vbar2', //vertical scrollbar (page right)
				movable:true,
				relativePosition:true,
				constraintHorizontalMovement:true,
				verticalMovementLimitTop  : 35,
				verticalMovementLimitBottom : 'PARENT_HEIGHT-OBJECT_HEIGHT-150',
				onInitialize:function(o) {
					o.element.saveData=[
						parseInt($('bar0').style.marginTop),parseInt($('bar0b').style.marginTop),
						parseInt($('bar1').style.marginTop),parseInt($('bar2').style.marginTop),
						parseInt($('bar3').style.marginTop),parseInt($('topmenu').style.marginTop),
						parseInt($('hbar').style.marginTop),
            //objects
            parseInt($('obj0').style.marginTop)
					];
					o.element.click();				
				},
				onParentResize:function(o) {
					//console.log(o);
					o.element.click();
				},
        onMouseOver:function(o) {
          globalSettings.showInfo(o.element.objectId);
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        },        
				onMouseWheel:function(o) {
          if ($('vbar2').style.visibility=='hidden')
            return;
					//console.log(o.event.wheelDelta);
					if (o.event.wheelDelta>0) {
						for (var z=0,zEnd=o.event.wheelDelta/3;z<zEnd;z++) {
						  o.element.moveDown();
					  }	
						//console.log(o.element.dom.offsetTop);						
					  //o.element.dom.style.top=(o.element.dom.offsetTop)+'px';
					} else {						
						var delta=Math.abs(o.event.wheelDelta);
						//console.log(delta);
						for (var z=0,zEnd=delta/3;z<zEnd;z++) {
  						o.element.moveUp();
						}	
					}
					//o.element.click();  
					//console.log(o.event.wheelDelta);
				},
				onDrag:function(o) { //element, event
					//alert('vbar');
					//console.log($('content').clientHeight,$('content').offsetHeight);
					var hh=o.element.heightLimit;
					var oH=$('obj0').offsetHeight;
					
					var increment=globalSettings.verticalScrollPowerUp;
					
					var contentHeight=$('content').offsetHeight+$('contentSideBar').offsetHeight+500;
					var tt=-((o.element.normalizedTop*Math.abs(o.element.uiParent.offsetHeight-contentHeight))/hh);
					//set content scrolling
				  Segunda.Utils.$('content').style.top=tt+'px';
          //sidebar
          Segunda.Utils.$('contentSideBar').style.top=($('content').offsetHeight+tt)+'px';
					
					//console.log(tt);					
					$('bar0').style.marginTop=(o.element.saveData[0]-(tt*4*increment))+'px'; //erba
					$('bar0b').style.marginTop=(o.element.saveData[1]-(tt/5*increment))+'px'; //erba back trasparente
					$('bar1').style.marginTop=(o.element.saveData[2]-(tt/6*increment))+'px'; //fuchisa dandelion
					$('bar2').style.marginTop=(o.element.saveData[3]-(tt/8*increment))+'px'; //cyan dandelion
					$('bar3').style.marginTop=(o.element.saveData[4]-(tt/10*increment))+'px'; //yellow dandelion
					$('obj0').style.marginTop=(o.element.saveData[7]-(tt/7*increment))+'px'; //deco object
//          if (U.undef(globalSettings.autoHideMenu) || !globalSettings.autoHideMenu) { //if we scroll when menu is hidden do not move it down..
					$('topmenu').style.marginTop=(o.element.saveData[5]-(tt*2*increment))+'px'; //main menu
  				$('hbar').style.marginTop=(o.element.saveData[6]-(tt*2*increment))+'px';  //hori scrollbar
//					}	
					
					//console.log(o);
					
					//globalSettings.wMain.currentMargins=[
					o.element.parentWindow.currentMargins=[
						parseInt($('bar0').style.marginTop),parseInt($('bar0b').style.marginTop),
						parseInt($('bar1').style.marginTop),parseInt($('bar2').style.marginTop),
						parseInt($('bar3').style.marginTop),parseInt($('topmenu').style.marginTop),
						parseInt($('hbar').style.marginTop),
               parseInt($('obj0').style.marginTop)
					];
					//wMain.currentMargins=;					
				},
				onDragStart:function(o) {					
					o.element.dom.className='M_arkanoidv';
          //console.log('x');
				},
        onDragEnd:function(o) {
  			  o.element.dom.className='arkanoidv';
        }
			},
			
			{
				objectId:'sizeBar',
				movable:true,
				relativePosition:true,
				verticalMovementLimitTop:50,
        constraintVerticalMovement:true,                

				onParentResize:function(o) { //if dealing with firebug window sometimes this event is not fired...
					o.element.click();
				},

				onDrag:function(o) { //element, event
					var ww=o.element.relativeLeftPercent;
          if (typeof o.element.sizeMemory=='undefined' || typeof o.element.sizeMemory[$('theimage').src]=='undefined') {
            o.element.sizeMemory=[];
            o.element.sizeMemory[$('theimage').src]=$('theimage').offsetHeight; //store img size
          }
					var ww=o.element.widthLimit;
          var ll=o.element.sizeMemory[$('theimage').src]-((o.element.normalizedLeft*Math.abs(o.element.sizeMemory[$('theimage').src]-o.element.uiParent.offsetHeight))/ww);
          $('theimage').style.height=ll+'px';
          o.elements['inspectBar'].click({dontMove:1}); //adjust art position          
        },

        onMouseOver:function(o) {
          if (!o.elements['inspectBar'].dragging)
            globalSettings.showInfo(o.element.objectId);
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        },                  
				onDragStart:function(o) {					
					o.element.dom.className='M_arrowright';
				},
        onDragEnd:function(o) {
  			  o.element.dom.className='arrowright';
        }
      },  
      
			{
				objectId:'inspectBar',
				movable:true,
				relativePosition:true,
				/*constraintHorizontalMovement:true,*/
				verticalMovementLimitTop  : 60,
				verticalMovementLimitBottom : 'PARENT_HEIGHT/2',
				horizontalMovementLimitLeft  : 20,
				horizontalMovementLimitRight : 100,
				onInitialize:function(o) {
					o.element.click();
				},
				onParentResize:function(o) {
					o.element.click();
				},
				onDrag:function(o) { //element, event
					//alert('vbar');
					var hh=o.element.heightLimit;
					var ww=o.element.widthLimit;
					var tt=-((o.element.normalizedTop*Math.abs(o.element.uiParent.offsetHeight-$('theimage').offsetHeight))/hh);
          if (o.element.uiParent.offsetHeight<$('theimage').offsetHeight)
  				  Segunda.Utils.$('imagediv').style.top=tt+'px';
          else  
  				  Segunda.Utils.$('imagediv').style.top='0px';
					var ll=-((o.element.normalizedLeft*Math.abs(o.element.uiParent.offsetWidth-$('theimage').offsetWidth))/ww);
          if (o.element.uiParent.offsetWidth<$('theimage').offsetWidth) {
 				    Segunda.Utils.$('imagediv').style.left=ll+'px';
          } else  {
 					  if (!globalSettings.imageHorizontalFreeDragging)
 				      Segunda.Utils.$('imagediv').style.left='0px';
						else	
 				      Segunda.Utils.$('imagediv').style.left=ll+'px';
          }
          //real time update for other obj  
          var sBy=o.element.dom.offsetTop;
          var sBx=(o.element.dom.offsetLeft+70);
          //instead of updating style.top and left directly use the move method
          //since we need to update the offsetLeft and offsetTop properties also..
          //this op could be done directly: o.elements['sizeBar'].offsetLeft=$('sizeBar').offsetLeft;
          o.elements['sizeBar'].move(sBx,sBy); //move() is just a shortcut -> means update offset and real dom pos...
					/*
          $('sizeBar').style.top =sBy+'px';
          $('sizeBar').style.left=sBx+'px';
          o.elements['sizeBar'].offsetLeft=$('sizeBar').offsetLeft;
          o.elements['sizeBar'].offsetTop=$('sizeBar').offsetTop;
					*/
          
          o.elements['sizeBar'].originalLeft=sBx;
          o.elements['sizeBar'].originalTop=sBy;
          
          o.elements['sizeBar'].horizontalMovementLimitLeft=sBx;
          o.elements['sizeBar'].horizontalMovementLimitRight=sBx+200+5;
				},
				onDragStart:function(o) {					
					o.element.dom.className='M_stop';
				},
        onDragEnd:function(o) {
  			  o.element.dom.className='stop';
        },
        onMouseOver:function(o) {
          globalSettings.showInfo(o.element.objectId);
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        }        
			},

			{
				objectId:'hbar',
				movable:true,
				relativePosition:true,
				constraintVerticalMovement:true,
				horizontalMovementLimitLeft  : 120,
				horizontalMovementLimitRight : 'PARENT_WIDTH-OBJECT_WIDTH-120',
				onInitialize:function(o) {
					o.element.click();
				},
				onParentResize:function(o) {
					o.element.click();
				},
				onDrag:function(o) { //element, event
					//console.log(o.element.relativeLeftPercent,o.element.relativeTopPercent);
					
					//console.log(o.event.clientX);
					var $=Segunda.Utils.$;
					var ww=o.element.widthLimit;
					var ll=-((o.element.normalizedLeft*Math.abs(o.element.uiParent.offsetWidth-$('topmenu').offsetWidth))/ww);
					
				  $('topmenu').style.left=ll+'px';
					
					var increment=globalSettings.horizontalScrollPowerUp;
					
					var erbaOffset=3000;//-4000;
					
					$('bar0').style.left =(increment+parseInt((ll/5))-erbaOffset)+'px'; //erba
					$('bar0b').style.left=(increment+parseInt((ll/7))-erbaOffset-150)+'px'; //erba back
					$('bar1').style.left =(increment+300+parseInt((ll/10)))+'px'; //flower
					$('bar2').style.left =(increment+700+parseInt((ll/15)))+'px'; //flower
					$('bar3').style.left =(increment+900+parseInt((ll/20)))+'px'; //flower
					$('obj0').style.left =(increment+300+parseInt((ll/9)))+'px'; //object
				},
        
				onMouseOver:function(o) {
          globalSettings.showInfo(o.element.objectId);
        },
        onMouseOut:function(o) {
          if (!o.element.dragging)
            globalSettings.hideInfo();
        },
				onDragStart:function(o) {					
					o.element.dom.className='M_arkanoidh';
					//$('contentFrame').style.opacity=.2;
					$('contentFrame').style.display='none';
					$('contentSideBar').style.display='none';
          $('imagediv').style.display='none';
          $('obj0').style.display='block';
          $('bar1').style.display='block';
          $('bar2').style.display='block';
          $('bar3').style.display='block';
          $('bar0').style.display='block';
          //$('bar0').style.opacity=1;
					//console.log($('bar0'));
          $('bar0b').style.display='block';
          $('inspectBar').style.visibility='hidden';
          $('sizeBar').style.visibility='hidden';
          //$('bar0').style.display='none'; //speed up scrolling
				},
        onDragEnd:function(o) {
					
					//console.log('yo');
					
  			  o.element.dom.className='arkanoidh';
					//$('contentFrame').style.opacity=1;
					$('contentFrame').style.display='block';
					$('contentSideBar').style.display=globalSettings.sideBarDisplay;
					if (globalSettings.autoHideMenu) {
            $('imagediv').style.display='block';
            $('inspectBar').style.visibility='visible';
            $('sizeBar').style.visibility='visible';
            $('obj0').style.display='none';
            $('bar0').style.display='none';
            $('bar0b').style.display='none';
            $('bar1').style.display='none';
            $('bar2').style.display='none';
            $('bar3').style.display='none';
					} else {
            $('imagediv').style.display='none';
					}
          //$('bar0').style.display='block';
        }
			}
		
		],
		onMouseOut:function(e) {
			//console.log(e);
		},
  	onInitialize:function(o) {
			o.element.saveData=[
				parseInt($('bar0').style.marginTop),parseInt($('bar0b').style.marginTop),
				parseInt($('bar1').style.marginTop),parseInt($('bar2').style.marginTop),
				parseInt($('bar3').style.marginTop),parseInt($('topmenu').style.marginTop),
         parseInt($('obj0').style.marginTop)
			];
			globalSettings.setVisibility();
		},
		onMouseMove:function(o) {
			
      /*
			segunda revision 51 > defined methods are now evaluated before window compiling  
			if (!globalSettings.wMain.currentMargins)
			  return;
			*/
			//return;
			if (!o.element.currentMargins)
			  return;
			
			var margins=o.element.currentMargins;
			
			//console.log(Segunda.Ui.dragging.dom.id)
			if (Segunda.Ui.dragging) {
				if (
          Segunda.Ui.dragging.dom.id=='vbar2' || Segunda.Ui.dragging.dom.id=='inspectBar' ||
          Segunda.Ui.dragging.dom.id=='sizeBar'          
        )
				  return;
			}
			//console.log(o.event.dragging);
			//var contentHeight=$('content').offsetHeight+100;
			var triggerY=280;
			var hh=300;
			var bh=$('bodyx').offsetHeight;
			var cY=o.event.clientY;
			var limitY=bh-triggerY;

			var tt=-(((cY-limitY)*Math.abs(limitY))/hh);

      //console.log(wMain.currentMargins);

			if (tt>0)
			  tt=0;
			//console.log(tt);
			
			$('bar0').style.marginTop=((margins[0]-(tt*4)))+'px';
			$('bar0b').style.marginTop=((margins[1]-(tt/5)))+'px';
			$('bar1').style.marginTop=((margins[2]-(tt/6)))+'px';
			$('bar2').style.marginTop=((margins[3]-(tt/8)))+'px';
			$('bar3').style.marginTop=((margins[4]-(tt/10)))+'px';
      $('obj0').style.marginTop=((margins[7]-(tt/6)))+'px';

/*			
			$('bar0').style.marginTop=((o.element.saveData[0]-(tt*4)))+'px';
			$('bar0b').style.marginTop=((o.element.saveData[1]-(tt/5)))+'px';
			$('bar1').style.marginTop=((o.element.saveData[2]-(tt/6)))+'px';
			$('bar2').style.marginTop=((o.element.saveData[3]-(tt/8)))+'px';
			$('bar3').style.marginTop=((o.element.saveData[4]-(tt/10)))+'px';
*/
			
			//console.log(opacityVariable);
			if (U.def(globalSettings.autoHideMenu) && globalSettings.autoHideMenu) {
				var opacityVariable=(((cY-limitY)*100)/(triggerY/4))/100;
				if (opacityVariable<0)
					opacityVariable=0;
  			$('topmenu').style.opacity=opacityVariable; //opacity auto hide
  			//$('bar0').style.opacity=0;//opacityVariable; //opacity auto hide
				$('hbar').style.opacity=opacityVariable;//opacityVariable; //opacity auto hide
				//$('vbar2').style.visibility='hidden';
				$('vbar2Reset').style.opacity=1;
				$('inspectBar').style.opacity=.5;
				$('sizeBar').style.opacity=.5;
			}	else {
  			$('topmenu').style.opacity=1;
        $('hbar').style.opacity=1;
				$('vbar2Reset').style.opacity=1;
				$('vbar2').style.visibility='visible';
				$('inspectBar').style.opacity=0;
				$('sizeBar').style.opacity=0;
			}
		},

    main:function(o) {
    }

  });
	
  globalSettings.pageReady();
}