/**
 * @author vpandia
 */

jQuery.noConflict()(function(){
	
	    jQuery('#pwd_box_id').dialog({
	        autoOpen: false,
	        width: 578,
	        modal: true,
	        title: 'Forgot your password?',
	        resizable: false,
	        draggable: true
	 
	    });  
	 
	jQuery('#forgot-password-link').click(function(){
		jQuery('#pwd_box_id').dialog('open');
	});
	
	jQuery('#forgot-password-close').live('click', function(){
		jQuery('#pwd_box_id').dialog('close');
	});
	
	jQuery('#mdr-standard-subscription').click(function(e){
		jQuery.ajax({
			url: '/ajax/mdr_subscription.php',
			type: "GET",
			ifModified: true,
		    data: "mdr_subscription=subscription_standard",
			cache: false,
			success: function(html){
				jQuery('#mdr-subscription-content').html(html);
				jQuery('#mdr-subscription-content').show();
				
				var h = 1070;
				var w = jQuery('body').width();
				jQuery('.mdr-subscription-overlay').css({
					'height': h
				});
				jQuery('.mdr-subscription-overlay').show();
			}
		});
		e.preventDefault();
	});
	
	jQuery('#mdr-professional-subscription').click(function(e){
		jQuery.ajax({
			url: '/ajax/mdr_subscription.php',
			type: "GET",
		    data: "mdr_subscription=subscription_professional",
			cache: false,
			success: function(html){
				jQuery('#mdr-subscription-content').html(html);
				jQuery('#mdr-subscription-content').show();
				var h = 1070;
				var w = jQuery('body').width();
				jQuery('.mdr-subscription-overlay').css({
					'height': h,
					'width': w
				});
				jQuery('.mdr-subscription-overlay').show();
			}
		});
		e.preventDefault();
	});
	
	jQuery('#mdr-premium-subscription').click(function(e){
		jQuery.ajax({
			url: '/ajax/mdr_subscription.php',
			type: "GET",
		    data: "mdr_subscription=subscription_premium",
			cache: false,
			success: function(html){
				jQuery('#mdr-subscription-content').html(html);
				jQuery('#mdr-subscription-content').show();
				var h = 1070;
				var w = jQuery('body').width();
				jQuery('.mdr-subscription-overlay').css({
					'height': h,
					'width': w
				});
				jQuery('.mdr-subscription-overlay').show();
			}
		});
		e.preventDefault();
	});
	
	jQuery('#subscription-close').live('click', function(){
		jQuery('#mdr-subscription-content').hide();
		jQuery('.mdr-subscription-overlay').hide();
	});
	
	jQuery('#mdr-free-trail').click(function(){
		window.open ("http://corporate.morningstar.com/us/asp/requestforinformation.aspx?product=eqprod","Trail","menubar=1,resizable=1,width=600,height=600");
	});
	
	jQuery('#login-run-search').click(function(){
		var company = jQuery('#sample-company').val();
		var keyword = jQuery('#sample-keyword').val();
		var docType = jQuery('#sample-document-type').val();
		
		var status= true;
		
		if(company == '' && keyword == '' && docType == '')
			status  = false; 
		if(status){
			var url = 'http://www.10kwizard.com/sample_search.php?' + 'company=' + company + '&keyword=' + keyword + '&doctype=' + docType; 
		
			window.open (url,"Trail","menubar=1,resizable=1,width=1000,height=600");
		}
		else
			alert('You must select at least one component for your search');
	});
	
	
	jQuery('#recent-documents-select').change(function(){
		jQuery('.recent-documents-div').hide();
		
		jQuery('#' + jQuery(this).val()).slideDown();
	});
	
});

function reminderRET( msg )
{
	if( msg.length > 0)
	{
		eval(msg);
		URL_ForgotMSG(ret_email);
	}
}

function SendReminder( idForm )
{
	//var form = GetTARGET(idForm);

	if(idForm.forgot_email.value.length > 0)
	{
		var param = 'forgot_email='+idForm.forgot_email.value+'&reminder=1';
		jQuery.ajax({
			   type: "GET",
			   url: 'corp_email.php',
			   data: param,
			   success: function(req){
				   reminderRET( req );
			   },
			   error: function(req){
				   alert('Error!\nStatusText='+req.status+'\nContents='+req.response);
				}
			 });

		//JSConnect(url);
	}
	else
	{
		alert("Please Enter an email address");
	}

	return(false);
}

var orig_dropin_msg = "";

function URL_ForgotMSG( msg )
{
	if(msg == 1)
	{
		var str = "<font class=\"txt\"><b><center>Your Password has been emailed</center></b></font>";

		str += "<BR><center><font class=\"txt\">Want to enter a new email address? Click <a class=\"filesLink\" href=\"#\" onClick=\"URL_ForgotMSG(-3)\">here</a></font></center>";
	}
	else if(msg == -2)
	{
		var str = orig_dropin_msg;
	}
	else if(msg == -3)
	{
		//FORGOT_BOX();

		//$('dropinbox_msg').innerHTML = orig_dropin_msg;
		
		jQuery('#dropinbox_msg').html(orig_dropin_msg);

		return;
	}
	else
	{
		var str = "<font class=\"txt\"><br /><b>Email address not found.<BR> Click <a href=\"https://secure.10kwizard.com/subscribe.php\" class=\"filesLink\">here</a> to learn more about subscription options.</b></font>";

		str += "<BR><BR><font class=\"txt\">Want to enter a new Email Address? Click <a class=\"filesLink\" href=\"#\" onClick=\"URL_ForgotMSG(-2)\">here</a></font>";
	}


	//orig_dropin_msg = $('dropinbox_msg').innerHTML;
	
	orig_dropin_msg = jQuery('#dropinbox_msg').html();


	//$('dropinbox_msg').innerHTML = str;
	
	jQuery('#dropinbox_msg').html(str);
}
