// {{{ loginSubmit ( form ) 
function loginSubmit ( form )
{
	var email	= form.elements['email'];
	var password	= form.elements['password'];
	var code	= form.elements['code'];
	var regExp	= /\d{4}/;

	if ( ! isValidEmail( email.value ) )
	{
		alert( 'Invalid email address.' );
		email.focus();
		return false;
	}

	if ( password == '' )
	{
		alert( 'Empty password.' );
		password.focus();
		return false;
	}

	if ( ! regExp.exec( code.value ) )
	{
		alert( 'Invalid secure code.' );
		code.focus();
		return false;
	}

	form.submit();

	return true;
}
// }}}

// {{{ isValidEmail( str ) 
// only basic check
function isValidEmail( str ) 
{
	if ( ! str.indexOf("@") > 0 )
		return false;

	if ( str.indexOf(" ") >= 0 )
		return false;

	var domain = str.substr( str.indexOf("@") + 1, str.length );

	return ( domain.indexOf(".") >= 1 );
}
// }}}

// {{{ show( id ) 
function show( id )
{
	var el  = document.getElementById( id );
	var img = document.getElementById( id + '_img' );

	if ( el.style.display == 'none' )
	{
		el.style.display	= 'block';
		if ( img ) img.src 	= '/themes/shared/images/icon_minus.gif';
	}
}
// }}}

// {{{ showHelp 
function showHelp ( name )
{
	window.open( '/html/help/' + name + '.html','Help','toolbar=no, location=no, directories=no, status=yes, menubar=no, resizable=yes, copyhistory=no, scrollbars=yes, width=480, height=280' );

	return false;
}
// }}}

// {{{ showORhide( id ) 
function showORhide( id )
{
	var el  = document.getElementById( id );
	var img = document.getElementById( id + '_img' );

	if ( el.style.display == 'none' )
	{
		el.style.display	= 'block';
		if ( img ) img.src 	= '/themes/shared/images/icon_minus.gif';
	}
	else
	{
		el.style.display	= 'none';
		if ( img ) img.src 	= '/themes/shared/images/icon_plus.gif';
	}
}
// }}}

// {{{ delTestimonial( oID ) 
function delTestimonial( oID ) {
	if ( confirm('Are you sure you want to delete this testimonial?') ) {
		document.location = '/reseller/?o=testimonials;type=del;oID=' + oID;
	}
}
// }}}

// {{{ editTestimonial( oID ) 
function editTestimonial( oID ) {
	form 	= document.getElementById('edit_panel_form');
	subject	= document.getElementById('subject_' + oID);
	body	= document.getElementById('body_' + oID);
	
	form.oID.value 		= oID;
	form.subject.value	= subject.innerHTML;
	form.body.innerHTML	= body.innerHTML;

	show( 'edit_panel' );
}
// }}}

// {{{ delNews( oID ) 
function delNews( oID ) {
	if ( confirm('Are you sure you want to delete this news?') ) {
		document.location = '/reseller/?o=news;type=del;oID=' + oID;
	}
}
// }}}

// {{{ editNews( oID ) 
function editNews( oID ) {
	form 	= document.getElementById('edit_panel_form');
	subject	= document.getElementById('subject_' + oID);
	body	= document.getElementById('body_' + oID);
	
	form.oID.value 		= oID;
	form.subject.value	= subject.innerHTML;
	form.body.innerHTML	= body.innerHTML;

	show( 'edit_panel' );
}
// }}}


