$(function(){

// this initialises the demo scollpanes on the page.
	
$('#pane').jScrollPane({showArrows:false});

});



var lightboxAction = 0;



 function getPageSize() {

	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
return [pageHeight];
		//return [pageWidth,pageHeight];
	}



function initBackground(){

document.getElementById("boxMainJs").style.height = getPageSize() +"px";

}



function getScrollXY() {   

    var scrOfX = 0, scrOfY = 0;   

  

    if( typeof( window.pageYOffset ) == 'number' ) {   

        //Netscape compliant   

        scrOfY = window.pageYOffset;   

        scrOfX = window.pageXOffset;   

    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {   

        //DOM compliant   

        scrOfY = document.body.scrollTop;   

        scrOfX = document.body.scrollLeft;   

    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {   

        //IE6 standards compliant mode   

        scrOfY = document.documentElement.scrollTop;   

        scrOfX = document.documentElement.scrollLeft;   

    }   

    return [scrOfY ];   

}  

















function createRequestObject() {

    var ro;

    var browser = navigator.appName;

    if(browser == "Microsoft Internet Explorer") {

        ro = new ActiveXObject("Microsoft.XMLHTTP");

    } else {

        ro = new XMLHttpRequest();

    }

    return ro;

}

var http = createRequestObject();



var DivOut;



function ActionResizeClose(myId, myName) {

lightboxAction=0;

document.getElementById("boxScreenAlpha").style.height = 0+"px";

document.getElementById("boxScreenAlpha").style.width = 0+"px";


      $('#boxScreenAlphaImage').fadeOut("240");
      $('#boxScreenContent').fadeOut("300");


}



function ActionResize() {



initLightbox(1)


}





var GlobalLinker=0;
function ActionProject(myAction,myId,myCounter) {


      DivOut = "boxProjectContent";

           $('#boxProjectContent').css("display","none");

           $('#boxProjectContent').animate({
                top: myCounter*18,  opacity: 'toggle'
           }, 1000,function() {
                               $('#d'+myCounter).addClass("cellProjectList1Active");
    // Animation complete.
  });
                        
                        
                    
         

               $('#d'+GlobalLinker).removeClass();
        //$('#boxProjectContent').css("display","none");
            $('#boxProjectContent').fadeIn("300");


           $('#l'+myCounter).css("color","#bc1617");
           $('#l'+GlobalLinker).css("color","#646668");
           
     
            
           
          GlobalLinker=myCounter;

      http.open('POST','ajax/AjaxInfo.php');
      http.onreadystatechange = handleResponse;
      http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      http.send('AjVal=jdfeiUU56e3reww&AjId='+myId);
     
}







function ActionDisplay(myNumber,myGallery) {

initLightbox(1)

DivOut = "boxScreenContent";

//document.getElementById("boxScreenContent").innerHTML = "<img src=\"img/uploadBig/"+myId+"\" />";



      http.open('POST','ajax/AjaxGallery.php');
      http.onreadystatechange = handleResponse;
      http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      http.send('AjVal=jdfeiUU56e3reww&AjGallery='+myGallery+'&AjNumber='+myNumber);
}



function  AjaxCheckForm(myType,myName,myInfo,myStatus){

 DivOut = "boxCorrect"+ myName;

CheckFormGlobal = true;

NameFormGlobal = myName;

//alert(NameFormGlobal)

 var varFormElement = document.formCheck["frm"+myName].value;

 document.formCheck.frmCheckVal.value = 1;



http.open('POST','ajax/checkForm.php');

 http.onreadystatechange = handleResponse;

 http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

 http.send('AjVal=jdfeiUU56e3reww&AjType='+myType+'&AjName='+myName+'&AjFormElement='+varFormElement+'&AjInfo='+myInfo+'&AjStatus='+myStatus);



//document.getElementById(["boxCorrect"+ myName]).innerHTML = "<font color=\"red\">*</font>";



}









function  handleResponse() {

    if(http.readyState == 4){

        var response = http.responseText;

//alert(http.getAllResponseHeaders()  )  

      

        var update = new Array();

         

       if(response.indexOf('|' != -1)) {

            update = response.split('|');





//alert(DivOut)

//alert(response)



}

document.getElementById(DivOut).innerHTML = response; 

}

}



function printer(){

    this.print();
    this.close();
}



function initLightbox() {

      var height = getPageSize();
      lightboxAction=1

      if(lightboxAction==1) {
            var browser = navigator.appName;
      
            if(browser == "Microsoft Internet Explorer") {
                    //document.getElementById("boxScreenAlpha").style.height = document.body.offsetHeight+"px";
            } else {
                    
                  //var height = window.innerHeight;
                  if( window.scrollMaxY){
                  //height += window.scrollMaxY;
                  
                  }
            }


            
            document.getElementById("boxScreenAlpha").style.height = height +"px";
            document.getElementById("boxScreenAlpha").style.width = document.body.offsetWidth+"px";




            var t = (height/2)-265;
            
            var l = (document.body.offsetWidth/2)-(480/2);
            
            
            $('#boxScreenContent').fadeIn("300");
            $('#boxScreenAlphaImage').fadeIn("300");


      }
}

//window.onresize = initLightbox; 
//window.onload=initBackground;


//window.onload=getPageSize

