//**************************************//
//                                      //
//	 Programing by: TheLost             //
//                                      //
//**************************************//



function setLogin(){
	if(document.getElementById('uname').value == ''){
		document.getElementById('uname').focus();
	}else{
		document.getElementById('upass').focus();
	}
}


function addRankMulti(id,type,amount){
	target = "http://lostmoviesarchive.com/vote.php?id="+id+"&type="+type+"&amount="+amount;
	window.open(target,'openme');

}








function addReview(){
	
	var found = true;

	if(found){
		document.getElementById('inpContent').value = oEdit1.getHTMLBody();
		document.getElementById('Form1').submit();
	}else{
		alert('You must select an "Attach To:".');
	}

}








function addComment(){
	
	var found = true;

	if(found){
		document.getElementById('inpContent').value = oEdit1.getHTMLBody();
		document.getElementById('Form1').submit();
	}else{
		alert('You must select an "Attach To:".');
	}

}








function addQuote(){
	
	var found = true;

	if(found){
		document.getElementById('inpContent').value = oEdit1.getHTMLBody();
		document.getElementById('Form1').submit();
	}else{
		alert('You must select an "Attach To:".');
	}

}








function addBio(){
		document.getElementById('inpContent').value = oEdit1.getHTMLBody();
		document.getElementById('Form1').submit();

}








function checkLogin(){
	document.getElementById('login_form').submit();
}








function checkAddImage(){
	var found = true;
	
	
	if(found){
		document.getElementById('add_image').submit();
	}else{
		alert('You must select an "Attach To:".');
	}
	
}







function checkAddAlbum(){
	var allow = true;

	
	if(document.getElementById('name').value == ''){
		alert('You must enter an album name.');
		allow = false;
	}
	
	if(document.getElementById('country').value == ''){
		alert('You must enter a country.');
		allow = false;
	}
	
	if(document.getElementById('language').value == ''){
		alert('You must enter a language.');
		allow = false;
	}
	
	if(document.getElementById('year').value.length < 4){
		allow = false;
		alert('You must set the year. (If you don\'t know it, guess at the year you think is closest to the real thing.)');
	}
	

	if(document.getElementById('year').value.charAt(0) != '1' && allow){
		if(document.getElementById('year').value.charAt(0) != '2'){
			allow = false;
			alert('You must set the year. (If you don\'t know it, guess at the year you think is closest to the real thing.)');
		}
	}
	
	
	if(allow){
		document.getElementById('add_album').submit();
	}
	
}








function checkAddMovie(){
	allow = true;
	
	if(document.getElementById('title').value == ''){
		allow = false;
		alert('You must name the movie');
	}
	
	if(document.getElementById('year').value.length < 4){
		allow = false;
		alert('You must set the year. (If you don\'t know it, guess at the year you think is closest to the real thing)');
	}
	

	if(document.getElementById('year').value.charAt(0) != '1' && allow){
		if(document.getElementById('year').value.charAt(0) != '2'){
			allow = false;
			alert('You must set the year. (If you don\'t know it, guess at the year you think is closest to the real thing)');
		}
	}
	
	target2 = document.getElementById('sel_cast[]');
	if(allow){
		for(i = 0; i < target2.options.length; i++){
			target2.options[i].selected = true;
		}
		document.getElementById('add_movie').submit();
	}
}








function checkAddTVshow(){
	allow = true;
	target2 = document.getElementById('sel_cast[]');
	
	if(document.getElementById('title').value == ''){
		allow = false;
		alert('You must name the movie');
	}
	
	
	if(document.getElementById('year').value.length < 4){
		allow = false;
		alert('You must set the year. (If you don\'t know it, guess at the year you think is closest to the real thing)');
	}
	
	if(allow){
		for(i = 0; i < target2.options.length; i++){
			target2.options[i].selected = true;
		}
		document.getElementById('add_tvshow').submit();
	}
}








function checkAddEP(){
	allow = true;
	if(document.getElementById('title').value == ''){
		alert('You must enter an episode title.');
		allow = false;
	}
	
	
	target2 = document.getElementById('sel_cast[]');
	if(allow){
		for(i = 0; i < target2.options.length; i++){
			target2.options[i].selected = true;
		}
		document.getElementById('add_ep').submit();
	}
}





is_group = false;


function checkAddArtist(){
	allow = true;
	
	if(document.getElementById('art_name').value == ''  && allow){
		allow = false;
		alert('You must add a name');
	}
	
	if(!is_group){
		
		if(document.getElementById('month').value == 0  && allow){
			allow = false;
			alert('You must add a birthday. (If you can\'t find it, set it to "??" for the day an month and guess at the year that you think is closest to the real thing i.e. ??-??-1995)');
		}
		
		
		if(document.getElementById('day').value == 0  && allow){
			allow = false;
			alert('You must add a birthday. (If you can\'t find it, set it to "??" for the day an month and guess at the year that you think is closest to the real thing i.e. ??-??-1995)');
		}
		
		
		if(document.getElementById('year').value.length < 4){
			allow = false;
			alert('You must add a birthday. (If you can\'t find it, set it to "??" for the day an month and guess at the year that you think is closest to the real thing i.e. ??-??-1995)');
		}
		
	
		if(document.getElementById('year').value.charAt(0) != '1' && allow){
			if(document.getElementById('year').value.charAt(0) != '2'){
				allow = false;
				alert('You must add a birthday. (If you can\'t find it, set it to "??" for the day an month and guess at the year that you think is closest to the real thing i.e. ??-??-1995)');
			}
		}
	}
	
	
	if(allow){
		document.getElementById('add_artist').submit();
	}
}








function menu_rollover(target){
	document.getElementById(target).className = 'menu_on';
}








function menu_rollout(target){
	document.getElementById(target).className = 'menu_off';
}



function addArtist2(text,target){
	if(text){
		newOption = new Option(text,text);
		try{
			document.getElementById('sel_cast[]').add(newOption);
		}catch(helpme){
			document.getElementById('sel_cast[]').add(newOption,null);
		}
	}
}





function addArtist1(){
	target = document.getElementById('theCast');
	target2 = document.getElementById('sel_cast[]');
	if(target.selectedIndex != -1){
		set = target[target.selectedIndex].text.split('::');
		role = window.prompt('Enter the name of the role played (Example "Dancing Monkey" w/o quotes)','');
		time = window.prompt('Enter the percent of on screen time the artist has from one to hundred percent. (Example: "85%" w/o quotes)','');
		if(role != null && time != null){
			string = set[1]+'::'+role+'::'+time+'::'+set[0];
			addArtist2(string,target2);
		}
	}

}


function removeArtist(){
	target2 = document.getElementById('sel_cast[]');
	
	
	for(i = 0; i < target2.options.length; i++){
		if(target2.options[i].selected){
			target2.options[i] = null;
		}
	}

}


function selectSubtitleGroup(type){
	switch(type){
		
		
		case'movie':
			document.getElementById('tvshow').selectedIndex = 0;
			document.getElementById('ep').selectedIndex = 0;
			document.getElementById('type').value = 'movie';
			target = document.getElementById('movie');
			
		break;
		
		case'tvshow':
			document.getElementById('movie').selectedIndex = 0;
			document.getElementById('ep').selectedIndex = 0;
			document.getElementById('type').value = 'tv';
			target = document.getElementById('tvshow');
			
		break;
		
		case'ep':
			document.getElementById('movie').selectedIndex = 0;
			document.getElementById('tvshow').selectedIndex = 0;
			document.getElementById('type').value = 'ep';
			target = document.getElementById('ep');
			
		break;
	}
	document.getElementById('set_name').value = target[target.selectedIndex].text;
	document.getElementById('set_id').value = target[target.selectedIndex].value;
}


function checkAddSub(){
	if(document.getElementById('set_name').value == 0){
		alert('You must select an "Attach To"');
		return false;
	}
		
	if(document.getElementById('discs').value == 0){
		alert('You must select an "You select the amount of discs"');
		return false;
		
	}
	
	if(document.getElementById('language').value == ''){
		alert('You must enter a language"');
		return false;
	}
				
	
	if(document.getElementById('file_type').value == ''){
		alert('You must enter a file type"');
		return false;
	}
	
	document.getElementById('add_sub').submit();
}


function checkAddVideo(){
	if(document.getElementById('set_name').value == 0){
		alert('You must select an "Attach To"');
		return false;
	}
	

	document.getElementById('add_video').submit();
}


function checkAddMule(){
	if(document.getElementById('link').value != ''){
		document.getElementById('add_mule').submit();
	}else{
		alert('Umm so this is the upload a link form, how about you add a link.');
	}
}




function selectImageGroup(type){
	switch(type){
		case'artist':
			document.getElementById('movie').selectedIndex = 0;
			document.getElementById('tvshow').selectedIndex = 0;
			document.getElementById('ep').selectedIndex = 0;
			document.getElementById('type').value = 'artist';
			target = document.getElementById('artist');

		break;
		
		
		case'movie':
			document.getElementById('artist').selectedIndex = 0;
			document.getElementById('tvshow').selectedIndex = 0;
			document.getElementById('ep').selectedIndex = 0;
			document.getElementById('type').value = 'movie';
			target = document.getElementById('movie');
			
		break;
		
		case'tvshow':
			document.getElementById('artist').selectedIndex = 0;
			document.getElementById('movie').selectedIndex = 0;
			document.getElementById('ep').selectedIndex = 0;
			document.getElementById('type').value = 'tv';
			target = document.getElementById('tvshow');
			
		break;
		
		case'ep':
			document.getElementById('artist').selectedIndex = 0;
			document.getElementById('movie').selectedIndex = 0;
			document.getElementById('tvshow').selectedIndex = 0;
			document.getElementById('type').value = 'ep';
			target = document.getElementById('ep');
			
		break;
	}
	document.getElementById('set_name').value = target[target.selectedIndex].text;
	document.getElementById('set_id').value = target[target.selectedIndex].value;
}








function showImageUpload(){
	
	target = document.getElementById('set_images');
	amount = target[target.selectedIndex].text;
	
	if(amount > 0){
		document.getElementById('theButton').disabled = false;
	}else{
		document.getElementById('theButton').disabled = true;
	}
	document.getElementById('show_amount').value = amount;
	out = '<table width="650" border="0" cellpadding="0"><br />';
	i = 0;
	while(i < amount){
		name = 'image_'+i;
		desc = 'desc_'+i;
		
		out += '<tr><td valign="top"><div align="right"><b>Image '+(i+1)+':&nbsp;</b></div></td><td valign="top"><input type="file"  name="'+name+'" id="'+name+'"></td></tr>';
		
		out += '<tr><td valign="top"><div align="right"><b>Description:&nbsp;</b></div></td><td valign="top"><input type="text" name="'+desc+'" id="'+desc+'" size="60" maxlength="60" /><br /><br /></td></tr>';
		i++;
	}
	out += '</table>';
	document.getElementById('image_group').innerHTML = out;
}









function showTrackUpload(amount){
	if(amount > 0){
		document.getElementById('theButton').disabled = false;
	}else{
		document.getElementById('theButton').disabled = true;
	}
	document.getElementById('show_amount').value = amount;
	out = '<table width="650" border="0" cellpadding="0"><br />';
	i = 0;
	while(i < amount){
		track = 'track_'+i;
		desc = 'desc_'+i;
		
		out += '<tr><td valign="top"><div align="right"><b>Track '+(i+1)+' Name:&nbsp;</b></div></td><td valign="top"><input type="text"  name="'+track+'" id="'+track+'" size="60"></td></tr>';
		
		out += '<tr><td valign="top"><div align="right"><b>Misc Info:&nbsp;</b></div></td><td valign="top"><input type="text" name="'+desc+'" id="'+desc+'" size="60" maxlength="60" /><br /><br /></td></tr>';
		i++;
	}
	out += '</table>';
	document.getElementById('track_group').innerHTML = out;
}



function doSearch(){
	
	if(document.getElementById('search_box').value != ''){ 
		document.getElementById('search').value = document.getElementById('search_box').value; 
		document.getElementById('search_form').submit();
	}
	
}


function getOthers(id,target){
	target.innerHTML = 'test';
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	
	if(!xmlhttp){
		alert('Your browser does not support the required javascript to view other movies.');
	}else{
		
		function displayOthers() {
			if(xmlhttp.readyState==4){
				response = xmlhttp.responseText;
				document.getElementById('otherMovies').innerHTML = response;
			}else{
				document.getElementById('otherMovies').innerHTML = '<strong>Retrieving Movies, please wait...</strong>';	
			}
		}// End function displayThankyou();
		
		document.getElementById('otherMovies').innerHTML = '<strong>Retrieving Movies, please wait...</strong>';
		
		
		xmlhttp.onreadystatechange = displayOthers;
		xmlhttp.open("GET", "http://lostmoviesarchive.com/others.php?id="+id,true);
		xmlhttp.send(null);
	}// End if
	
}


// Vote Crap


var vote_state;
var roll_state;
var voted = false;

// Preload images

image1 = new Image(15,15);
image1.src = 'images/v0.0.gif';
image2 = new Image(15,15);
image2.src = 'images/vr.gif';
image3 = new Image(15,15);
image3.src = 'images/v1.0.gif';
image4 = new Image(15,15);
image4.src = 'images/v0.5.gif';

function vote_rollover(id){
	vote_state = document.getElementById('vote_icons').innerHTML;
	set_vote_state(document.getElementById(id).alt,id);
	
}


function roll_rollover(){
	//alert('x');
	roll_state = document.getElementById('vote_icons').innerHTML;
}



function roll_rollout(){
	if(vote_state != ''){
		//document.getElementById('vote_icons').innerHTML = roll_state;
	}
}




function vote_rollout(){
	document.getElementById('vote_icons').innerHTML = vote_state;
}


function set_vote_state(rating,id){
	if(!voted){
		document.getElementById('v1').src = 'images/v0.0.gif';
		document.getElementById('v2').src = 'images/v0.0.gif';
		document.getElementById('v3').src = 'images/v0.0.gif';
		document.getElementById('v4').src = 'images/v0.0.gif';
		document.getElementById('v5').src = 'images/v0.0.gif';
		document.getElementById('v6').src = 'images/v0.0.gif';
		document.getElementById('v7').src = 'images/v0.0.gif';
		document.getElementById('v8').src = 'images/v0.0.gif';
		document.getElementById('v9').src = 'images/v0.0.gif';
		document.getElementById('v10').src = 'images/v0.0.gif';
		
		switch (rating){
			case '1': 
				document.getElementById('v1').src = 'images/vr.gif';
				roll_rollover();
	
			break;
			case '2': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				roll_rollover();
			break;
			case '3': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '4': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '5': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '6': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				document.getElementById('v6').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '7': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				document.getElementById('v6').src = 'images/vr.gif';
				document.getElementById('v7').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '8': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				document.getElementById('v6').src = 'images/vr.gif';
				document.getElementById('v7').src = 'images/vr.gif';
				document.getElementById('v8').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '9': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				document.getElementById('v6').src = 'images/vr.gif';
				document.getElementById('v7').src = 'images/vr.gif';
				document.getElementById('v8').src = 'images/vr.gif';
				document.getElementById('v9').src = 'images/vr.gif';
				roll_rollover();
			break;
			
			case '10': 
				document.getElementById('v1').src = 'images/vr.gif';
				document.getElementById('v2').src = 'images/vr.gif';
				document.getElementById('v3').src = 'images/vr.gif';
				document.getElementById('v4').src = 'images/vr.gif';
				document.getElementById('v5').src = 'images/vr.gif';
				document.getElementById('v6').src = 'images/vr.gif';
				document.getElementById('v7').src = 'images/vr.gif';
				document.getElementById('v8').src = 'images/vr.gif';
				document.getElementById('v9').src = 'images/vr.gif';
				document.getElementById('v10').src = 'images/vr.gif';
				roll_rollover();
			break;
		}
	}
	

	
}



function addRank(id,type,amount){
	//alert(id+' '+type+' '+amount);
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	
	if(!xmlhttp){
		alert('Your browser does not support the required javascript to vote.');
	}else{
		
		function displayThankyou() {
			if(xmlhttp.readyState==4){
				document.getElementById('vote_icons').innerHTML = roll_state;
				voted = true;
			}else{
				document.getElementById('vote_icons').innerHTML = '<strong>Sending...</strong>';	
			}
		}// End function displayThankyou();
		
		xmlhttp.onreadystatechange = displayThankyou;
		xmlhttp.open("GET", "http://lostmoviesarchive.com/vote.php?id="+id+"&type="+type+"&amount="+amount,true);
		xmlhttp.send(null);
	}// End if
	
}







