// JScript File


// This function will open a DHTML popup for do the login.
function openAbusePop()
{
    //sw_resetReportAbuseForm();
	YAHOO.reportPanel.show();
}

//This function will close yahoo login popup
function closeAbusePop()
{
    YAHOO.reportPanel.hide();
	
	
}



// This function will initialize the yahoo widgets components.
function initYahooReport()
{
     var x = 490;//document.width / 2 - 100;
    //var y = 100;//document.height / 2 - 200;    
	var y = 426;//document.height / 2 - 200;    
                                                                  
    YAHOO.reportPanel = new YAHOO.widget.Overlay("reportPanel", { xy:[x,y],
                visible:false,
                width:"300px",
                effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } );
    YAHOO.reportPanel.render(); 
	

}

function sw_reportAbuse()
{
    	

	var reportername = document.getElementById("reportername").value
	var username = document.getElementById("username").value
	var reason = document.getElementById("reason").value
	var url = base_path+"popup/reportMail.php"; 
	var formDiv = document.getElementById("popup_cont");
	//capture the current form html for later use when we reset the form upon submission
	sw_oldhtml = formDiv.innerHTML;
		
    ajaxReportMail = new sack();
	ajaxReportMail.setVar("reportername", reportername); 
	ajaxReportMail.setVar("username", username);
	ajaxReportMail.setVar("reason", reason);
	ajaxReportMail.setVar("chat_ReportAbuseEmailAddress", chat_ReportAbuseEmailAddress);
	
	ajaxReportMail.method='GET';
    ajaxReportMail.requestFile = url;        // Specifying which file to get
	ajaxReportMail.onLoading = sw_showReportAbuseLoading;
    ajaxReportMail.onCompletion = sw_showReportAbuseThanks;      // Specify function that will be executed after file has been found
    ajaxReportMail.runAJAX();                // Execute AJAX function
}

function sw_showReportAbuseThanks()
{
	
	var errorDiv = document.getElementById("errorDiv");
	var formDiv = document.getElementById("popup_cont");
	var html;
	if (ajaxReportMail.response == 1) {
		//Success! Replace the form with a thank you message
		html = "Your comments have been submitted.";
		if ( formDiv )
		{
			formDiv.innerHTML = html;
		}
		//Close the thank you message 
		sw_closeReportAbuseThanks();
	}
	else
	{
		//If there is an error, show the error message below the form
		html = ajaxReportMail.response;
		if ( errorDiv )
		{
			errorDiv.innerHTML = html;
		}
	}
		
    

}

function sw_closeReportAbuseThanks() 
{
	//After a short delay, close the popup and reset the form
	setTimeout("closeAbusePop()",3000);
	setTimeout("sw_resetReportAbuseForm()",3250);
}

function sw_showReportAbuseLoading()
{
	
	var errorDiv = document.getElementById("errorDiv");
	var html = "Sending..."
    if ( errorDiv )
    {
        errorDiv.innerHTML = html;
    }

}


function sw_resetReportAbuseForm()
{
	
	var formDiv = document.getElementById("popup_cont");
		
    if ( formDiv )
    {
        formDiv.innerHTML = sw_oldhtml;
    }

}