if(location.hostname == "localhost")
	domain = 'localhost/www.lasertechniek.com/';
else
	domain = location.hostname+'/';

 domain = "http://"+domain;

function conPage(msg,page,target,param, show) {
	if(!msg)
		msg = "Weet u dit zeker ?";
		
	
    if(!confirm("Let op: "+msg))
		return false;
	
	loadPage(page,target,param)
}


function loadPage(page,target,param) {
	loading();
	
	var url = domain+page;
	if(!param)
		param = "";
	
		
	var pars = param;
	var target = target;
	

	var myAjax = new Ajax.Updater({success: target},url, {method: 'get',onFailure:reportError, onComplete : unload, parameters: pars, evalScripts: 'true'});

	
	
	

}
function reportError() {
	
	//alert("error");
}


function sendForm(page, id, target){

		
	var page = domain+page;
	var params = Form.serialize($(id));
	new Ajax.Updater(target, page, { method: 'post',onComplete : unload, asynchronous:true, parameters:params,evalScripts: 'true'});
	
} 


function loading(target) {
	
	$('loading').show();
	$('loading').update('<img src="'+domain+'data/images/icons/loading.gif" border="0" style="padding-left:5px;" align="absmiddle">&nbsp;&nbsp;Loading ...</div>');
	
	if(target)
		$(target).update('<img src="'+domain+'data/images/icons/loading.gif" border="0" style="padding-left:5px;" align="absmiddle">&nbsp;&nbsp;Loading ...</div>');
	
}

function unload() {
	
	$('loading').update('');
	$('loading').hide();
	
}

function checkEnter(e, func){ 
	var characterCode;

	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}
	
	if(characterCode == 13){ 
		
		func;
	}

}

function checkEnterForm(e, page, id, target, show){ 
	
	var characterCode;

	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}
	
	

	if(characterCode == 13){ 
		
		sendForm(page,id,target,show);
	}

}


// Some Class
function FCKcheck()
{
        this.doCheck = function()
        {
                for ( i = 0; i < parent.frames.length; ++i )
                        if ( parent.frames[i].FCK )
                                parent.frames[i].FCK.UpdateLinkedField();
        }
}
// instantiate the class
var FCKcheck = new FCKcheck();

var Fades = {
	initialize: function() {
		this.currentSection = 'technical';
	  //(3).times(function(i){
      //i++;
      i = 1;
      //$('brochure').invoke('setStyle', {  bottom:'-2000px', position:'relative'});
      //$('info_'+i).setStyle({ zIndex:1000 });
   // });   
	},
  	
	showSection: function(event, section) {
    	if(section == this.currentSection) return;
    	this.hideCurrentSection();
    	this.flyIn(section, 1);
    	this.currentSection = section;
    	document.body.style.overflow = "auto";
  	},
  	
	flyOut: function(element) {
  		document.body.style.overflow = "hidden";
  		
  		
  		element = $(element);
    	Effect.Fade(element,{duration:0.5});
  		var delay = arguments[1];
    	element.setStyle({
      		position:'relative'
    	}).morph('bottom:-2000px', {
      		duration:1, 
      		delay:delay
    	});
    	Effect.Fade(element,{duration:0.5});
    	document.body.style.overflow = "auto";
    	
  },
  
  flyIn: function(element) {
  	
  	document.body.style.overflow = "hidden";
    element = $(element)
    element.setStyle({
      bottom:'-2000px'
    });
    var delay = arguments[1];
    element.morph('bottom:0px', {
      duration:1.2, 
      delay:delay
    });
    element.up().setStyle({ zIndex:1000 });
    Effect.Appear(element,{duration:2.2});
  
  },
  hideCurrentSection: function() {
    this.flyOut(this.currentSection, 0.1);

  }
 
}

