// relocates the popup when someone scrolls the page
function myPopupRelocate() {
 var scrolledX, scrolledY;
 if( self.pageYOffset ) {
   scrolledX = self.pageXOffset;
   scrolledY = self.pageYOffset;
 } else if( document.documentElement && document.documentElement.scrollTop ) {
   scrolledX = document.documentElement.scrollLeft;
   scrolledY = document.documentElement.scrollTop;
 } else if( document.body ) {
   scrolledX = document.body.scrollLeft;
   scrolledY = document.body.scrollTop;
 }

 var centerX, centerY;
 if( self.innerHeight ) {
   centerX = self.innerWidth;
   centerY = self.innerHeight;
 } else if( document.documentElement && document.documentElement.clientHeight ) {
   centerX = document.documentElement.clientWidth;
   centerY = document.documentElement.clientHeight;
 } else if( document.body ) {
   centerX = document.body.clientWidth;
   centerY = document.body.clientHeight;
 }

 var leftOffset = scrolledX + (centerX - 250) / 2;
 var topOffset = scrolledY + (centerY - 200) / 2;

 document.getElementById("dhtml_popup").style.top = topOffset + "px";
 document.getElementById("dhtml_popup").style.left = leftOffset + "px";
}

// Displays the dhtml popup and fills in the data
function dhtml_popup(){ //x=image y=comment
	
	myPopupRelocate();
	document.getElementById("dhtml_popup").style.display = "block";
	document.body.onscroll = myPopupRelocate;
	window.onscroll = myPopupRelocate;
	return false;
}

function dhtml_close(){
	document.getElementById("dhtml_popup").style.display = "none";
	document.getElementById('com_name').value = '';
	document.getElementById('com_locn').value = '';
	document.getElementById('secure_match').value = '';
	document.getElementById('comments').value = '';
	document.getElementById('art_rating').value = '0';
}

function reloadImage(){
   img = document.getElementById("spam_image");
   img.src = "/feedback/captcha/image.php?" + Math.random();
}

function header_link(){
	window.location = "http://www.valleyofthestarz.com/"
}

function change_video(video){
	var video_title = video.split('.');
	video_title = video_title[0].split('_');
	if (video_title.length > 1){video_title= video_title[1];}else{video_title=video_title[0];}
	
	document.getElementById('current_video').innerHTML = '<h2>'+video_title+'</h2><a href="videos/'+video+'" style="display:block;width:520px;height:330px" id="player"></a>';
	flowplayer("player", {src: "../../../flash/flowplayer-3.1.5.swf", wmode: 'opaque'}, { 
    clip: { 
        autoPlay: true
    }, 
    play: { 
        label: null, 
        replayLabel: "click to play again" 
    } 
	} 
	);
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
