// ZET TABEL OP GOEDE HOOGTE

//document.body.onresize = function (){ zettabel();}

function blockError(){return true;}
window.onerror = blockError;


if(document.URL.search('#')>0){
urlArr=document.URL.split('#');
window.location.href=urlArr[1];
}



function zettabel(){
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winH = document.body.offsetHeight;
 }
}
//if(document.getElementById('tabel').offsetHeight<winH){
	document.getElementById('tabel').style.height=winH+'px';
//}
}




// ANIMATIE

var rechtsbalk=160;
var middenbalk=622;
var speed=500;

function opencenter(){
	$("#menubalk").animate({ height: '760px'}, speed);
}

function openrechts(extra){
	$("#schaalrechts").animate({ width: rechtsbalk+'px'}, speed);
	if(extra!=1){
	$("#smallcontact").animate({ width: rechtsbalk+'px'}, speed);
	$("#kernwaarde").animate({ width: rechtsbalk+'px'}, speed);
	}
}

function openmidden(){
	$("#schaalmidden").animate({ width: middenbalk+'px'}, speed);
	$("#smallcontact").animate({ width: '1px'}, speed,function(){document.getElementById('smallcontact').style.display='none';});
	$("#kernwaarde").animate({ width: '1px'}, speed,function(){document.getElementById('kernwaarde').style.display='none';});
}

function sluitrechts(){
	$("#schaalrechts").animate({ width: '1px'}, speed,function(){sluitmidden()});
}

function sluitmidden(){
	$("#schaalmidden").animate({ width: '1px'}, speed);
	$("#smallcontact").animate({ width: rechtsbalk+'px'}, speed);
	$("#kernwaarde").animate({ width: rechtsbalk+'px'}, speed);
}



// ZICHTBAAR/ONZICHTBAAR MAKEN


var itemheight=Array()
function toggled(id){
if(document.getElementById(id).offsetHeight>1){
	itemheight[id]=document.getElementById(id).offsetHeight;
	$("#"+id).animate({ height: '1px'}, speed);
	document.getElementById(id+'top').style.background="#6e0a24 url('images/rechtsitem_top_open.gif') 16px 10px no-repeat";
}else{
	$("#"+id).animate({ height: itemheight[id]+'px'}, speed);
	document.getElementById(id+'top').style.background="#6e0a24 url('images/rechtsitem_top_sluit.gif') 16px 10px no-repeat";
}	
}




function togglemidden(){
	if(document.getElementById('schaalmidden').offsetWidth>1){
		sluitmidden();
	}else{
		openpagina('index.php');
		openmidden();
	}
}








// PAGINA OPENEN 

function openpagina(pag){
openmidden();
insertcontent('content',pag,0);
}




var http_request = false;

function insertcontent(targ,page,extra){
target=targ;
pagina=page;
ext=extra;

if(targ=='content'){
document.getElementById(target).innerHTML='<img src="images/loading.gif" class="loading">';
}
  
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', pagina, true);
      http_request.send(null);
	  return true;
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            		
			document.getElementById(target).style.marginTop='6px';
			document.getElementById(target).style.opacity=0;
			
			document.getElementById(target).innerHTML = result;
			
			// $("#content").animate({ opacity: 0, marginTop: '6px'}, 1 );
 if (navigator.appName.indexOf("Microsoft")!=-1) {
			$("#"+target).animate({ opacity: 1, marginTop: '0px'}, 800,'swing',function(){document.getElementById(target).style.removeAttribute("filter");zettabel();});
 }else{
			$("#"+target).animate({ opacity: 1, marginTop: '0px'}, 800,'swing',function(){zettabel();});
 }
		
			if(ext!=1){
				
				page1=pagina.split('.php');
				pag=page1[0]+'.html'+page1[1];
				pagt=page1[0];
				scroll(0,0);
				

pagetitle='';
if(pagt.search('_')>0){
pagetits=pagt.split('_');

 for ( var i in pagetits ){
	if(i>1){
 		pagetitle+=pagetits[i]+' ';
	}
 }
}else{
 pagetitle=page1[0];	
}

cp=pag.split('.html');
currentpage=cp[0];
				
			location.hash = '#'+pag;
			document.title='Sniper-X - ' + pagetitle;
			//window.lochash.location='loc.php?loc='+pag;
			pageTracker._trackPageview(pag);
			
			}

//			document.getElementById('alert').style.display='block';
         } else {
            document.getElementById(target).innerHTML = '<div class="warning">Probleem met het laden van de pagina. ('+pagina+')<br><br>Breng de webmaster op de hoogte door <a href="#error" onclick="insertcontent(\'content\',\'error.php?pag='+pagina+'\');">hier</a> te klikken</div>';
//			document.getElementById('alert').style.display='block';
         }
      }
   }
   
   
   
   
   
// post form via AJAX (kutclub)   


function reageren(){
	
	var para='naam=' + encodeURI( document.reactie.naam.value ) +
			'&email=' + encodeURI( document.reactie.email.value ) +
			'&reactie=' + encodeURI( document.reactie.reactie.value ) +
			'&content=' + encodeURI( document.reactie.content.value ) +
			'&id=' + encodeURI( document.reactie.id.value );
makePOSTRequest('content','reageren.php',para);
}

   
 var http_request = false;
   function makePOSTRequest(targ, url, parameters) {
	   
	   target=targ;
	   
	   document.getElementById(target).innerHTML='&nbsp;';
	document.getElementById(target).style.background="transparent url('images/loading.gif') 50% 30% no-repeat";
	   
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
   
   
   
   
   
   
// SLIDESHOW 


function openbig(img){

slideimages=new Array();
slidetitles=new Array();
slideimgnr=0;

	var arr = document.getElementsByTagName("a");
	for (i = 0; i < arr.length; i++) {
		if ( arr[i].className=='slidelink'){
			slideimgnr++;
		  slideimages.push(arr[i].href);
		  slidetitles.push(arr[i].title);
		  if(img==arr[i].href){num=slideimgnr;}
		}
	}
	
	var slideaant=slideimages.length;
	
	showimage();	
	
}


function showimage(){
	document.getElementById('logoholder').style.display='none';
	document.getElementById('slideshow_imgholder').style.display='block';
	document.getElementById('slideshow_holder').style.opacity=0;
	document.getElementById('slideshow_holder').style.display='block';
	document.getElementById('slideshow_img').src='images/loading.gif';
	document.getElementById('slideshow_img').src=slideimages[num-1];
	document.getElementById('slideshow_bg').style.display='block';
	document.getElementById('slideshow_status').innerHTML='image '+num+' of '+slideimgnr+': <b>'+slidetitles[num-1]+'</b>';
	$("#slideshow_bg").animate({ opacity: 0.6}, 200,'swing' );
	
}

function scaleimage(){
	$("#slideshow_holder").animate({ opacity: 1}, 300,'swing' );
	wid=document.getElementById('slideshow_img').offsetWidth;
	hig=document.getElementById('slideshow_img').offsetHeight;
	
	if(wid<1){
	wid=document.getElementById('slideshow_img').width;
	hig=document.getElementById('slideshow_img').height;
	}
	
	document.getElementById('slideshow_holder').style.width=wid+'px';
	document.getElementById('slideshow_holder').style.height=hig+'px';
	
	//$("#slideshow_holder").animate({ width: document.getElementById('slideshow_img').offsetWidth+'px'}, 300,'swing' );
	//$("#slideshow_holder").animate({ height: document.getElementById('slideshow_img').offsetHeight+'px'}, 300,'swing' );	
}

function nextimage(){
	num++;
	if(num>slideimgnr){num=1;}
	showimage();
}

function previmage(){
	num--;
	if(num<1){num=slideimgnr;}
	showimage();
}

function hideimage(){
	document.getElementById('logoholder').style.display='block';
	document.getElementById('slideshow_img').src='images/loading.gif';
	document.getElementById('slideshow_imgholder').style.display='none';
	$("#slideshow_bg").animate({ opacity: 0}, 200,'swing', function(){document.getElementById('slideshow_bg').style.display='none'});
}