﻿///<reference path="http://data.lancefisher.net/jquery-1.2.3-intellisense.js" />
var wsRatings = "/Tips-And-Articles/wsRatings.asmx";
var wsRecipeBox = "/Meals-Tools/wsRecipeBox.asmx";
function Sanitize(inputString)
{
    return inputString.replace(/<\/?[^>]+>/gi, '');
}
function FlagInappropriate_Click(commentId, comment, reviewTypeId, linkId, thankyouId)
{   
    var data = new Object();
    data.CommentId = commentId;
    data.Comment = comment;
    data.ReviewType = reviewTypeId;
    CallWebService(wsRatings, "FlagAsInappropriate", data, null, null);
    
    $("#" + linkId).fadeOut(function(){    
        $("div.ierevealfix iframe").each(
            function(){
                $(this).hide();
            }
        );
        $("#" + thankyouId).fadeIn();
    });
}
function Helpful_Click(commentId, bIsHelpful, reviewTypeId, containerId, thankyouId)
{
    var data = new Object();
    data.CommentId = commentId;
    data.IsHelpful = bIsHelpful;
    data.ReviewType = reviewTypeId;
    CallWebService(wsRatings, "IsReviewHelpful", data, null, null);
        
    $("#" + containerId).fadeOut(function() {
        $("#" + thankyouId).fadeIn();
    });            
}


function CallWebService(serviceUrl, serviceName, data, OnSuccess, OnFailed)
{
    if(data == null || data == "")  
        data = "{}";
    else 
        data = $.toJSON(data);

    $.ajax( {
        type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: data, 
        url: serviceUrl + "/" + serviceName, 
        success: function(data) { if(OnSuccess != null) OnSuccess(data.d); }, 
        error: function(XMLHttpRequest, textStatus, errorThrown) { if(OnFailed != null) OnFailed(); }                        
    });       
}

function SaveInteraction(interactionType, sourceId)
{

}

// LEFTNAV HOVER FOR IE
lnHover = function() {
	var topNav = document.getElementById("leftNav");
	if (topNav == null) return;
	
	var tnEls = topNav.getElementsByTagName("LI");
	if (tnEls == null) return;
	
	for (var i=0; i<tnEls.length; i++) {
		tnEls[i].onmouseover=function() {
			this.className+=" lnhover";
		}
		tnEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" lnhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", lnHover);


