var myEffect, myEffectpc, myEffectqu, pu, qu, txtb, wh;

window.addEvent('domready', function() {
	

	
	/*
	
	 txtb	= $('txtblok').getCoordinates();
	wh		= window.getHeight()-50;
	console.log(txtb.height+' - '+wh);	
	  
	if(txtb.height<wh){
		$('popup_content').setStyles({
		    overflow: 'auto',
		    height: wh-45
		});
	*/
	
$('popup').setStyle('opacity', '0');
$('quotediv').setStyle('opacity', '0');
$('popup_shade').setStyle('opacity', '0');

$('bs').setStyle('opacity', '0.8');

$('bs').addEvent('mouseover', function(bs) {
$('bs').setStyle('opacity', '1');
});


$('bs').addEvent('mouseout', function(bs) {
$('bs').setStyle('opacity', '0.8');
});


if(Cookie.read('taal')=="null"){
Cookie.write('taal', 'nl', {duration: 5});
}

$('popup').setStyles({
    display:'block',
     opacity: '0'
});

$('quotediv').setStyles({
    opacity: '0',
    display:'block'
});

$('popup_shade').setStyles({
    opacity: '0.4',
    display:'block'
});


myEffect = new Fx.Morph('popup', {duration: 100, transition: Fx.Transitions.Sine.easeOut});
//myEffectpc= new Fx.Morph('popup_content', {duration: 300, transition: Fx.Transitions.Sine.easeOut});
myEffectqu= new Fx.Morph('quotediv', {duration: 300, transition: Fx.Transitions.Sine.easeOut});
});



window.addEvent('resize', function() {
	txtb	= $('txtblok').getCoordinates();
	wh		= window.getHeight()-50;
	console.log(txtb.height+' - '+wh);	
	
var p	= $('txtblok').getCoordinates();
var po	= $('popup').getCoordinates();
wh	= window.getHeight()-20;
var myEffect = new Fx.Morph('popup', {duration: 100, transition: Fx.Transitions.Sine.easeOut});
myEffect.start({
'left': [po.left, p.left]
});	

cheight();

});

function cheight(){
var p	= $('txtblok').getCoordinates();
var po	= $('popup').getCoordinates();
var wh	= window.getHeight()-20;	

if(wh<po.height){
$('popup_content').setStyles({
    overflow: 'auto',
    height: wh-45
});

$('popup_shade').setStyles({
    height: wh-10
});


}else{
$('popup_content').setStyles({
    overflow: 'visible'
});

$('popup_shade').setStyles({
    height: $('popup_content').offsetHeight
});

}	
	
}


var Quote= new Class({
initialize: function(qid){
        this.qid 		= qid;
},

quoteOpen: function(){    
var wi	= window.getCoordinates();
$('windowdiv').setStyles({
    width: wi.width,
    height: wi.height,
    opacity: 1
});
/*   'left': [0, $('txtblok').offsetLeft()],
    'height': [0, 300], 
*/

myEffectqu.start({
    'opacity': [0, 1],  
    'width': [0, 450],  
  'left': [0, $('txtblok').getLeft()]
});
new Request.HTML({onComplete: this.popoc,update:'quotediv', url: 'index.php'}).post({ajaxrequest: 1, f: 'quote', qid:this.qid});
},

quoteClose: function(){
$('windowdiv').setStyles({
    width: 0,
    height: 0,
    opacity: 0
});
	
myEffectqu.start({
    'opacity': [1,0],  
    'width': [450,0],  
  'left': [$('txtblok').getLeft(),0]
});


}
});




var Popup= new Class({

initialize: function(eupdate, f, jf, taal){
        this.eupdate 	= eupdate;
        this.f 		= f;
        this.jf 		= jf;
        this.taal 		= taal;
        if(this.taal!=""){
        Cookie.write('taal', this.taal, {duration: 5});
        }
        $('popup_content').style.display='block';


switch(this.jf){
case 'popLoad':
  this.popLoad();
  break;    

case 'popOpenLoad':
  this.popOpenLoad();
  break;     
  
default:
  this.popLoad();
}
 
},


popoc: function(){    
this.size = $('popup_content').getSize();
//this.size = $('popup_content').getCoordinates();
//this.size	= window.getHeight()-120;

$('popup').setStyle('z-index', 30);	
$('popup_shade').setStyle('display', 'none');

/*
$('popup_shade').setStyles({
    display:'block',
	opacity: 0.4,
    height: this.size.y
});
*/

},

popLoad: function(){    
new Request.HTML({onComplete: this.popoc,update:this.eupdate, url: 'index.php'}).post({ajaxrequest: 1, f: this.f, taal:this.taal});


}, 
   
popOpenLoad: function(){    
this.popOpen();
new Request.HTML({onComplete: this.popoc, update:this.eupdate, url: 'index.php'}).post({ajaxrequest: 1, f: this.f, taal:this.taal});

}, 

//'top': [0, 100]   'top': [100, 0]
popOpen: function(){
var p	= $('txtblok').getCoordinates();
var wh	= window.getHeight()-120;

myEffect.start({
'left':[0,p.left],
'height': [0, wh], 
'width': [0, 530],  
'opacity': [0, 1]
});	

},
 //'left': [0, p.x]   'left': [p.x,0],
popClose: function(){
$('popup').setStyle('z-index', 0);	
var p=$('txtblok').getPosition(); 
var wh	= window.getHeight();
myEffect.start({
    'width': [530, 0],  
    'height': [wh,0], 
    'opacity': [1,0] 
});

}    
    
});

