/* ------------------------------------------------------------- */
// BEGIN check auth input

function CheckAuthForm( e )
{
	var f = document.getElementById( 'id_login' );
	var errstr = null;

	while( true )
	{
		//alert( 'email='+f.r_email.value );
		if( f.email.value.length < 1 )
		{
			errstr = 'please input your e-mail.';
			f.email.focus();
			break;
		}

		r = new RegExp( "[0-9a-zA-Z-._]+@[0-9a-zA-Z-._]+\.[0-9a-zA-Z]{2,4}", "g" );
		ar = r.exec( f.email.value );
		if( !ar )
		{
			errstr = 'e-mail is invalid.';
			f.email.focus();
			break;
		}

		if( f.pwd.value.length < 1 )
		{
			errstr = 'please input your password.';
			f.pwd.focus();
			break;
		}

		break;
	}

	if( errstr )
	{
		alert( errstr );
		if( e && e.preventDefault )
			e.preventDefault(); // DOM style
		if( window.event )
			window.event.returnValue = false;
		return false; // IE style
		/*
		if( !e )
		{
			var e = window.event;
			e.returnValue = false;
		}

		e.cancelBubble = true;
		if( e.stopPropagation )
			e.stopPropagation();
		return false;
		*/
	}

	return true;
}

// END 
/* ------------------------------------------------------------- */



/* ------------------------------------------------------------- */
// BEGIN preload menu images


function PreloadMenu()
{
	var img_im_home = new Image();
	img_im_home.src = '/templates/my/img-css/i_home_hover.jpg';

	var img_im_help = new Image();
	img_im_help.src = '/templates/my/img-css/i_help_hover.jpg';

	var img_im_signup = new Image();
	img_im_signup.src = '/templates/my/img-css/i_signup_hover.jpg';

	var img_im_mydls = new Image();
	img_im_mydls.src = '/templates/my/img-css/i_dls_hover.jpg';

	var img_im_myacc = new Image();
	img_im_myacc.src = '/templates/my/img-css/i_acc_hover.jpg';
}

// END
/* ------------------------------------------------------------- */







/* ------------------------------------------------------------- */
// BEGIN player settings and installations


var current_fid = 0;
var current_trid = 0;


function CompilePlayerFront( trid, fid )
{
	var front = '<a href="#" onclick="ChasePrelisten( \''+trid+'\', \''+fid+'\' );FlipPlayerFront( \''+trid+'\', \''+fid+'\' );return false;">'+
	'<img src="/images/xclusive/player_front.gif" width="80" height="15" border="0" /></a>';

	return front;
}

function FlipPlayerFront( trid, fid )
{
	/*
	alert( 'Unfortunately, preview feature is unavailable yet.\r\n\r\n'+
	'Please check back in awhile.' );
	return;
	*/

	var landing = CompilePlayer( trid, fid );
	document.getElementById( 'dip_'+trid ).innerHTML = landing;
}

function CompilePlayer( trid, fid )
{
	var landing = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
	'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" '+
	'width="80" height="15" id="'+fid+'">' +
	'<param name="movie" value="/images/xclusive/swf/player_small_v21.swf" />'+
	'<param name="AllowScriptAccess" value="always" />'+
	'<param name="quality" value="high" />'+
	'<param name="flashvars" value="trid='+trid+'&self_fid='+fid+'&resume=1">'+
	'<embed src="/images/xclusive/swf/player_small_v21.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" '+
	'flashvars="trid='+trid+'&self_fid='+fid+'&resume=1" allowScriptAccess="always" type="application/x-shockwave-flash" width="80" height="15"></embed></object>';

	return landing;
}


function InstallPlayer( trid, fid )
{
	var landing = CompilePlayerFront( trid, fid );
	//document.write( landing );

	document.getElementById( 'dip_'+trid ).innerHTML = landing;
	
}

function ChasePrelisten( trid, fid )
{
	// fid responds to the now-playing player fid
	// *

	if( current_trid < 1 )
	{
		current_trid = trid;
		current_fid = fid;
		return;
	}

	if( current_trid == trid )
		return;

	// flip last fid and update current one
	// *
	try {
	last_player = document.getElementById( fid );
	delete last_player; } catch( e ) { };
	
	
	document.getElementById( 'dip_'+current_trid ).innerHTML = CompilePlayerFront( current_trid, current_fid );
	
	current_trid = trid;
	current_fid = fid;
}

// END
/* ------------------------------------------------------------- */








/* ------------------------------------------------------------- */
// BEGIN chasing menu and etc...


function ChaseMenu( id_item, stat )
{
	if( stat < 1 )
	{
		// mouse out
		// *
		document.getElementById( id_item ).src = '/templates/my/img-css/'+id_item+'.jpg';
		return;
	}
	else
	{
		// mouse over
		// *
		
		document.getElementById( id_item ).src = '/templates/my/img-css/'+id_item+'_hover.jpg';
		return;
		
	}
	
}



// END 
/* ------------------------------------------------------------- */






/* ------------------------------------------------------------- */
// BEGIN expand "how to" on album pages

function HandleHowtdClick()
{
	if( is_htd_hidden )
	{
		div_htd.innerHTML = html_htd;
		document.getElementById( 'id_exp_htd_tip' ).innerHTML = "[-]";
		document.getElementById( 'id_exp_htp_tip' ).innerHTML = "[+]";
		div_htp.innerHTML = '';
		is_htp_hidden = true;
	}
	else
	{
		div_htd.innerHTML = '';
		document.getElementById( 'id_exp_htd_tip' ).innerHTML = "[+]";
		document.getElementById( 'id_exp_htp_tip' ).innerHTML = "[+]";
	}

	is_htd_hidden = !is_htd_hidden;

}

function HandleHowtpClick()
{
	if( is_htp_hidden )
	{
		div_htp.innerHTML = html_htp;
		document.getElementById( 'id_exp_htp_tip' ).innerHTML = "[-]";
		document.getElementById( 'id_exp_htd_tip' ).innerHTML = "[+]";
		div_htd.innerHTML = '';
		is_htd_hidden = true;
	}
	else
	{
		div_htp.innerHTML = '';
		document.getElementById( 'id_exp_htp_tip' ).innerHTML = "[+]";
		document.getElementById( 'id_exp_htd_tip' ).innerHTML = "[+]";
	}

	is_htp_hidden = !is_htp_hidden;

}

// END
/* ------------------------------------------------------------- */



function SyncLayoutHeight()
{
	var lh=0, rh=0;
	lh_block = document.getElementById( 'lblock_box' );
	if( lh_block )
		lh = document.getElementById( 'lblock_box' ).clientHeight;

	rh_block = document.getElementById( 'rblock_box' );
	if( rh_block )
		rh = document.getElementById( 'rblock_box' ).clientHeight;	
	
	mh_block = document.getElementById( 'msblock_box' );
	if( !mh_block )
	{
		mh_block = document.getElementById( 'mlblock_box' );
		if( !mh_block )
			return;
	}

	var mh = mh_block.clientHeight;

	if( mh >= Math.max( lh, rh ) )
	{
		return;
	}

	mh_block.style.height = Math.max( lh, rh ) + 'px';
}

function HandleSearchRequest( e )
{
	var in_query = document.getElementById( 'id_q' ).value;
	
	if( in_query.length < 1 || in_query == "input your search request here..." )
	{
		alert( 'please type something to search for...' );
		
		if( e && e.preventDefault )
			e.preventDefault(); // DOM style
		if( window.event )
			window.event.returnValue = false;
		return false; // IE style
		
		/*
		return false;
		
		
		alert( e );
		if( !e )
		{
			var e = window.event;
			e.returnValue = false;
		}

		e.cancelBubble = true;
		if( e.stopPropagation )
			e.stopPropagation();
		return false;
		*/
	}
	
	var go_image = document.getElementById( 'go_image' );
	if( go_image )
	    go_image.disabled=true;
	
	return true;
}

function ShowEmailSubscribeForm()
{
	var d = document.getElementById( 'email_sbscr_block' );

	
	d.style.visibility = 'visible';
	d.style.padding = '5px 5px 5px 10px';
	d.style.margin = '5px 0px 0px 0px';


	d.innerHTML = 
	'<input type="text" id="id_sbscr_email" name="s_email" value="your email here..." class="inputauth2" '+
	'onfocus="document.getElementById( \'id_sbscr_email\' ).value=\'\'">';
}

function OpenRecoverLayer()
{
    var holder = document.getElementById( 'id_recover_holder' );
    var layer = document.getElementById( 'id_recover_layer' );
    
    if( !holder )
    {
	alert( 'unexpected error occured. \r\nplease contact our support team via e-mail.' );
	return;
    }
    
    try {
    var mw = document.getElementById( 'overall_wrapper' );
    
    //var h = document.getElementById( 'id_xheader' );
    //var f = document.getElementById( 'footer_box' );
    /*h.style.filter = f.style.filter =*/ mw.style.filter = "alpha(opacity=50)";
    /*h.style.opacity = f.style.opacity =*/ mw.style.opacity = ".50";
    } catch( e ) {};
    
    var popup_err = document.getElementById( 'id_expand_delayed' );
    if( popup_err )
	if( popup_err.style.display != "none" )
	    popup_err.style.display = "none";
	    
    
    if( holder.style.display == "none" && layer )
    {
	holder.style.display = "block";
	return;
    }
    
    try{
	document.getElementById( 'id_flash_header' ).innerHTML = '<img src="/images/xclusive/noflash_header.jpg" />';
	document.getElementById( 'id_volatile_skyshare_manager' ).innerHTML = '<a href="/skyshare-manager"><img src="/images/xclusive/noflash_skyshare_man.jpg" width="190" height="161" border="0" /></a>';
	}catch(e){}
	holder.style.display = "block";
    holder.innerHTML = 
    
    '<div style="position:absolute;background:#FFFFFF;left:50%;margin-left:-270px;top:150px;width:500px;border:2px dashed #666666;padding:20px;z-index:10;" id="id_recover_layer">' +
    '<div style="background:#DDDDDD;min-height:120px;height:100%;">' + 
    '<div style="width:100%;text-align:right;padding-top:4px;padding-bottom:4px;background:#000000;"><a href="#" onclick="CloseRecoverLayer();" style="color:#FFFFFF;text-decoration:none;">'+
    '<div style="float:left;margin-left:10px;">password reminder</div> <strong><u>close</u> [X]</strong></a> &nbsp;</div>' +
    '<div style="clear:both;">' +
    
    '<iframe src="/forgot-password" width="500" height="160" frameborder="0" scrolling="no"></iframe>' + 
    
    '</div>' +
    '</div>';
    
    
}

function CloseRecoverLayer()
{
    var holder = document.getElementById( 'id_recover_holder' );
    if( holder )
    {
	holder.style.display = 'none';
	try {
	var mw = document.getElementById( 'overall_wrapper' );
	mw.style.opacity = "";
	mw.style.filter = "";
	} catch( e ) {};
    }    
}

function InstallFeedback( t )
{
    if( t == 0 )
	document.write( '<strong><a href="mailto:support@mp3skyline.com">support@mp3skyline.com</a></strong>' );
    else if( t == 1 )
	document.write( 
	'<strong><a style="color:#0000FF;" href="mailto:support@mp3skyline.com">support@mp3skyline.com</a></strong>'
	);
}

function StatInfo()
{
    w = window.open('/info/charge_stat.html', '_blank', 'width=600,height=500,status=no,toolbar=no,menubar=no');
    window.w.focus();
    window.event.returnValue = false;
    return false;
}


function Bookmark()
{
    var title = "MP3xclusive.com -- Largest MP3 download index.";
    var url = "http://mp3xclusive.com/";
    if (window.sidebar){ window.sidebar.addPanel(title, url,""); }
    else if( window.external ) { window.external.AddFavorite( url, title); }
    else if(window.opera && window.print) { return true; }
}
                    