﻿
var guidelines; // guidelines forms

/* Initialization */
window.addEvent("domready", function() {
	// Append the guidelines container
	$(document.body).adopt(
		$$(
			guidelines = new Element("div", {id: "frmGuidelines"})
		).setStyles({ display:"none" })
	);
	guidelines.innerHTML = "<h2>Guidelines</h2>";
    // background load the comments-reviews guidelines
    var guidelineReq = new Request.JSON({ url: '/AjaxFormProcessor.aspx',
        // SUCCESS HANDLER
        onSuccess: function(response, reponsetxt) {
            guidelines.innerHTML += response.success=="true" ? response.message : 
                "<p>Please check back later for the guidelines.</p>";
        }, 
        // FAIL HANDLER
        onFailure: function(txt) {
            guidelines.innerHTML += "<p>Please check back later for the guidelines.</p>";
        }
    });
    var guidelineReqData={};
    guidelineReqData.formtype="getCommentsGuidelines";
    guidelineReq.send({data:guidelineReqData}); 

}); // END DOMREADY

function showreport(reportlinkid, commentid) {
    var coords = $(reportlinkid).getCoordinates();
    var xspot = coords.left - 150;//(formcoords.width * .5);
    var yspot = coords.top - 50;//(coords.height * .5);
    
    $('reportForm').setStyles({display:'',position:'absolute', left:xspot, top:yspot });
    txtRptCommentID.value=commentid;         
}    
function closereport() {
    txtRptCommentID.value='';
    $("reportForm").setStyle("display","none");
}
function showguidelines() {
    ModalBox.open(guidelines);
}


var howtowrite, htwhead, htwcontent, scroller, scrollerhandle;


function guidelinesOnClose() {
    $(howtowrite).destroy();
}
var reqHowtowrite = new Request.JSON({
    url: '/AjaxFormProcessor.aspx',
    // REQUEST HANDLER - START LAODING GIF
    onRequest: function() {},
    // SUCCESS HANDLER
    onSuccess: function(response, reponsetext) {
        if( response.success=="true" ) {
            $(document.body).adopt( $$(
                howtowrite = new Element("div", { id: "guidelines" } ).adopt( 
                    $$(
                        htwhead = new Element("h4", { text: "How to Write an Online Business Review" }),
                        htwcontent = new Element("div", { id: "gdlcontent", html: response.message} ).addClass("content"),
                        scroller = new Element("div", {id:"vertscroll"} ).adopt( scrollerhandle = new Element("div", {id:"handle"}) )
                    )
                ).setStyles({ display:"none" })
            ));
            // show the guidelines in the modal popup
            ModalBox.open(howtowrite, {onCloseFunction: guidelinesOnClose} );
            // setup the scroll bar
            makeScrollbar( $(htwcontent), $(scroller), $(scrollerhandle) );
        }
    },
    // FAIL HANDLER
    onFailure: function(txt) {
        $('testdataresultarea').value= "There was an error submitting your request";
    }
});