// JavaScript Document
	function popupWindow(page, title, vars){
		window.open(page,title,vars);
	}


	function close_info(){
			
		showFlash();
		document.getElementById('cover').style.visibility = "hidden";
		document.getElementById('cover').style.width = "0px";
		document.getElementById('cover').style.height = "0px";
		document.getElementById("frame").style.visibility = "hidden";
		
	}
	
	function show_app_info(frameWidth, frameHeight){
		//define height and width of popup frame
				
		if(frameWidth==null){
			frameWidth = 450;
		}
		if(frameHeight==null){
			frameHeight = 250;
		}
	
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		
		var arrayPageScroll = getPageScroll();
//		alert('arrayPageSize:' + arrayPageSize);
//		alert('arrayPageScroll:' + arrayPageScroll);

		var cover = document.getElementById('cover');

		cover.style.width = arrayPageSize[2]+'px';
		cover.style.height = arrayPageSize[1]+'px';
		cover.style.visibility = "visible";
		
		var frame = document.getElementById("frame");
		frame.innerHTML = '';
		document.getElementById('loginFrame').style.display = 'none';

//		var content = document.getElementById("frameContent");

		var content = document.createElement('div');
		content.setAttribute('id', 'frameContent');
		content.style.paddingTop = '30px';
		content.innerHTML = '<h1>Sending Application</h1><p><img src="assets/images/misc/ajax-loader.gif" width="32" height="32" /></p><p>We\'re uploading your files and sending in your application, please be patient! Do not navigate away from this page, or your application will be lost into internet space.</p>';

		frame.appendChild(content);


		//Define width of border
		var border = 15;
		
		var boxTop = arrayPageScroll[1] + 90;
		//top and left corners are based size of viewable area
		var boxLeft = arrayPageScroll[0] + Math.round(arrayPageSize[2] / 2) - border;
	
		if(boxLeft > frameWidth/2){ boxLeft -= Math.round(frameWidth/2);}
//		if(boxTop > frameHeight/2){ boxTop -= Math.round(frameHeight/2);}
		frame.style.top = boxTop + 'px';
		frame.style.left = boxLeft + 'px';
		frame.style.height = frameHeight + 'px';
		frame.style.width = frameWidth + 'px';

		hideFlash();
		frame.style.visibility = 'visible';
	}

	function show_must_login_info(frameWidth, frameHeight){
		//define height and width of popup frame
				
		if(frameWidth==null){
			frameWidth = 450;
		}
		if(frameHeight==null){
			frameHeight = 250;
		}
	
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		
		var arrayPageScroll = getPageScroll();
//		alert('arrayPageSize:' + arrayPageSize);
//		alert('arrayPageScroll:' + arrayPageScroll);

		var cover = document.getElementById('cover');

		cover.style.width = arrayPageSize[2]+'px';
		cover.style.height = arrayPageSize[1]+'px';
		cover.style.visibility = "visible";
		
		var frame = document.getElementById("frame");
		if(document.getElementById('frameContent')){
			var frameContent = document.getElementById('frameContent');
			frame.removeChild(frameContent);
//			frameContent = null;
			
		}

		document.getElementById('loginFrame').style.display = 'none';

//		var content = document.getElementById("frameContent");

		var content = document.createElement('div');
		content.setAttribute('id', 'frameContent');
		content.style.paddingTop = '30px';
		content.innerHTML = '<h1>Ooops!</h1><p>Sorry, you must <a href="javascript:show_login_info();">login</a> before you can rate the tracks.</p><p>Don\'t have an account? <a href="register.php">Register now!</ It\'s easy and free!</p><p><a href="javascript:close_info();">Changed your mind? Click here to return to the page.</a></p>';

		frame.appendChild(content);


		//Define width of border
		var border = 15;
		
		var boxTop = arrayPageScroll[1] + 90;
		//top and left corners are based size of viewable area
		var boxLeft = arrayPageScroll[0] + Math.round(arrayPageSize[2] / 2) - border;
	
		if(boxLeft > frameWidth/2){ boxLeft -= Math.round(frameWidth/2);}
//		if(boxTop > frameHeight/2){ boxTop -= Math.round(frameHeight/2);}
		frame.style.top = boxTop + 'px';
		frame.style.left = boxLeft + 'px';
		frame.style.height = frameHeight + 'px';
		frame.style.width = frameWidth + 'px';

		hideFlash();
		frame.style.visibility = 'visible';
	}

	function show_login_info(frameWidth, frameHeight){
		//define height and width of popup frame
				
		if(frameWidth==null){
			frameWidth = 450;
		}
		if(frameHeight==null){
			frameHeight = 270;
		}
	
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		
		var arrayPageScroll = getPageScroll();
//		alert('arrayPageSize:' + arrayPageSize);
//		alert('arrayPageScroll:' + arrayPageScroll);

		var cover = document.getElementById('cover');

		cover.style.width = arrayPageSize[2]+'px';
		cover.style.height = arrayPageSize[1]+'px';
		cover.style.visibility = "visible";
		
		var frame = document.getElementById("frame");
			
		document.getElementById('loginFrame').style.display = 'block';

		
		//Define width of border
		var border = 15;
		
		var boxTop = arrayPageScroll[1] + 90;
		//top and left corners are based size of viewable area
		var boxLeft = arrayPageScroll[0] + Math.round(arrayPageSize[2] / 2) - border;
	
		if(boxLeft > frameWidth/2){ boxLeft -= Math.round(frameWidth/2);}
//		if(boxTop > frameHeight/2){ boxTop -= Math.round(frameHeight/2);}
		frame.style.top = boxTop + 'px';
		frame.style.left = boxLeft + 'px';
		frame.style.height = frameHeight + 'px';
		frame.style.width = frameWidth + 'px';

		hideFlash();
		frame.style.visibility = 'visible';
	}


// -----------------------------------------------------------------------------------
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
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;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}
// ---------------------------------------------------
function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}

