/*----------------------------------------------------------------------------------------------------------------------------
	SKIN 2 JOIN - Javascript Functions
----------------------------------------------------------------------------------------------------------------------------*/
var lightbox1_width = 680, lightbox1_height= 220;
/*----------------------------------------------------------------------------------------------------------------------------
	showLightbox()
----------------------------------------------------------------------------------------------------------------------------*/
function showLightbox( iddiv ){
	
	var arrayPageSize = getPageSize();

	// arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	document.getElementById('overlay').style.width = (arrayPageSize[0] + 'px');
	document.getElementById('overlay').style.height = (arrayPageSize[1] + 'px');
// 	document.getElementById('overlay').onclick = function () {hideLightbox(); return false;}
	document.getElementById('overlay').style.display = 'block';

	document.getElementById(iddiv).style.left = ( ( ( arrayPageSize[0] / 2 ) - ( lightbox1_width / 2 ) ) + 'px');
	document.getElementById(iddiv).style.top = ( ( getPageScroll() + ( lightbox1_height / 2 ) ) + 'px');

	document.getElementById(iddiv).style.display = 'block';
	
	document.getElementById('search').style.display = 'none';

}
/*----------------------------------------------------------------------------------------------------------------------------
	hideLightbox()
----------------------------------------------------------------------------------------------------------------------------*/
function hideLightbox( iddiv ){
	
	document.getElementById('overlay').style.display = 'none'; // hide lightbox and overlay
    document.getElementById(iddiv).style.display = 'none';
    
	document.getElementById('search').style.display = 'block';
	
	document.onkeypress = ''; // disable keypress listener
}
/*----------------------------------------------------------------------------------------------------------------------------
	getPageScroll()
		Returns array with y page scroll values.
----------------------------------------------------------------------------------------------------------------------------*/
function getPageScroll(){
	
	var theTop = 0;
	var old = 0;
	if (window.innerHeight) {
		pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		pos = document.body.scrollTop
	}
	return pos;
	
}
/*----------------------------------------------------------------------------------------------------------------------------
	getPageSize()
		Returns array with page width, height and window width, height
----------------------------------------------------------------------------------------------------------------------------*/
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		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
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function up_down( sftw ) {
    var xmlHttpReq = false;

    if (window.XMLHttpRequest) {// Mozilla/Safari
        xmlHttpReq = new XMLHttpRequest();
        xmlHttpReq.overrideMimeType('text/xml');
    }else if (window.ActiveXObject) { // IE
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open('GET', 'up_down.php?sftw='+sftw, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            return( true );
        }
    }
    xmlHttpReq.send( '' );
}
