function createRequestObject() {
  var ro;
  try {ro = new XMLHttpRequest();}
  catch(e) {
    try {ro = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e) {
      try {ro = new ActiveXObject("Microsoft.XMLHTTP");}
      catch(e) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  return ro;
}

//var http = createRequestObject();
var getReq = createRequestObject();
var sendReq = createRequestObject();


function intReq(){
	getReq.open('POST','v3_load_vCP.php');
	getReq.setRequestHeader("Content-type", "text/plain");
  //	http.setRequestHeader("Connection", "close");   
	getReq.onreadystatechange = handleReq;
    getReq.send(null);
}

function handleReq() {
    if(getReq.readyState == 4){
        var response = getReq.responseText;
        var update = new Array();

        if(response.indexOf('yougottakeepemseperated' != -1)) {
            update = response.split('yougottakeepemseperated');
			document.getElementById('background').innerHTML = update[1];
			document.getElementById('recent_thumbs').innerHTML = update[3];
			document.getElementById('main_img_bg').src=document.getElementById('main_img').src;
						   
		 }
    }
}

function sndReq(word,algview,fadesetting) {
	document.getElementById('word').disabled='disabled';	
	document.getElementById('background').style.visibility='hidden';

	var word = encodeURIComponent(word);
//	alert(word);
  sendReq.open('POST','v3_process_vCP.php?word='+word+'&algview='+algview+'&fadesetting='+fadesetting);
//	sendReq.setRequestHeader("Content-type", "text/plain");
 //sendReq.setRequestHeader("Connection", "close");   
	sendReq.onreadystatechange = handleResponse;
    sendReq.send(null);
}
function handleResponse() {
    if(sendReq.readyState == 4){
        var response = sendReq.responseText;
        var update = new Array();

        if(response.indexOf('yougottakeepemseperated' != -1)) {
            update = response.split('yougottakeepemseperated');
			document.getElementById('word').disabled='';		
			document.getElementById('background').innerHTML = update[1];
			document.getElementById('recent_thumbs').innerHTML = update[3];
			document.inputform.word.value = document.getElementById('main_img').title;
			
			setTimeout("document.inputform.word.blur();", 0);
			setTimeout("document.inputform.word.select();", 0);
			$('#loader').fadeOut('fast');
			//initLytebox();				   
		 }
    }
}


	$(document).ready(function(){

		$('a.link_moreinfo').click(function() {
			
			if ($('#moreinfo_footer').is(":hidden"))
	              {
	                    $('#moreinfo_footer').slideDown("fast");
	               } else {
	                    $('#moreinfo_footer').slideUp("fast");
	               }
		   // $('#moreinfo_footer').toggle(400);
		    return false;
		  });
		
		$('a#link_recent_thumbs').click(function() {

			if ($('#recent_thumbs').is(":hidden"))
	              {
	                    $('#recent_thumbs').slideDown("fast");
	               } else {
	                    $('#recent_thumbs').slideUp("fast");
	               }
		   // $('#moreinfo_footer').toggle(400);
		    return false;
		  });
		
	});
