/*
Php YT Site
Copyright (C) 2007 Ciprian Dosoftei
http://www.phpytsite.org/
 
This program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Further to the terms mentioned you should leave the copyright footers and
copyright notice in the code intact, stating me as the original author.
*/

function youTubePlayer( vid ) {
	document.write( "<object width='480' height='395'><param name='movie' value='http://www.youtube.com/v/" + vid + "'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/" + vid + "' type='application/x-shockwave-flash' wmode='transparent' width='480' height='395'></embed></object>" );
}

function checkLogin() {
	if( ! $F("username") ) {
		$("username").setStyle( { background: '#a00' , color: '#fff' } );
		$("username").focus();
		window.alert( "Please enter your username!" );
		return false;
	} else
		$("username").setStyle( { background: '#fff' , color: '#000' } );
	
	if( ! $F("password") ) {
		$("password").setStyle( { background: '#a00' , color: '#fff' } );
		$("password").focus();
		window.alert( "Please enter your password!" );
		return false;
	} else
		$("password").setStyle( { background: '#fff' , color: '#000' } );
	
	$("loginFrm").submit();
}

function saveSettings() {
	var fields = new Array( "sitename" , "siteurl" , "path" , "tagline" , "tag" , "vpp" , "welcome" );
	
	for( f = 0 ; f < fields.length ; f++ )
		if( ! $F( fields[f] ) ) {
			$( fields[f] ).setStyle( { background: '#a00' , color: '#fff' } );
			$( fields[f] ).focus();
			window.alert( "Please fill in all fields!" );
			return false;
		} else
			$( fields[f] ).setStyle( { background: '#fff' , color: '#000' } );
	
	$("settingsFrm").submit();
}

function saveCredentials() {
	if( ! $F("admin") ) {
		$("admin").setStyle( { background: '#a00' , color: '#fff' } );
		$("admin").focus();
		window.alert( "Please enter your administrator username!" );
		return false;
	} else
		$("admin").setStyle( { background: '#fff' , color: '#000' } );
	
	if( $F("npassword") ) {
		if( ! $F("cpassword") ) {
			$("cpassword").setStyle( { background: '#a00' , color: '#fff' } );
			$("cpassword").focus();
			window.alert( "You must enter your current password before updating it!" );
			return false;
		} else
			$("cpassword").setStyle( { background: '#fff' , color: '#000' } );
		
		if( ! $F("rpassword") || $F("npassword") != $F("rpassword") ) {
			$("rpassword").setStyle( { background: '#a00' , color: '#fff' } );
			$("rpassword").focus();
			window.alert( "Please confirm your new password!" );
			return false;
		} else
			$("rpassword").setStyle( { background: '#fff' , color: '#000' } );
	}
	
	$("credentialsFrm").submit();
}

function updateVideos() {
	location.href = "admin.php?atask=updateVideos";
}
