String.prototype.replaceAll = function(pcFrom, pcTo){
    var i = this.indexOf(pcFrom);
    var c = this;
     
    while (i > -1){
        c = c.replace(pcFrom, pcTo);
        i = c.indexOf(pcFrom);
    }

    return c;
}

function f_showOnlineRatailor(target, url) {
    if(target == "link") {
        document.location.href = url;
    } else if(target == "popup") {
        var win = window.open(url,"POP","");
        win.focus();
    } else if(target == "iframe") {
    	if ( $("#layQuick").length ) $("#layQuick").hide();
        if($("#onlineRatailor").length) {
            $("#onlineRatailor > div > iframe").attr("src", url);
            $("#onlineRatailor").show();
        } else {
            var html = "";
            html += "<div class=\"layPop\" id=\"onlineRatailor\" style=\"position:absolute;\">";
            html += "  <div>";
            html += "    <h3>Buy this product online now at:</h3>";
            html += "    <iframe height=\"450\" frameborder=\"0\" width=\"824\" scrolling=\"no\" src=\"" + url + "\" allowtransparency=\"True\"></iframe>";
            html += "  </div>";
            html += "  <p class=\"btnClose\"><a href=\"#none\"><img src=\"/common/img/btn_layTip_close.png\" alt=\"close\" /></a></p>";
            html += "</div>";

            $("body").append(html);
            
            var object = $("#onlineRatailor");
            if ( $.browser.webkit ) {
				var scrollLeft = document.body.scrollLeft;
				var scrollTop = document.body.scrollTop;
			} else {
				var scrollLeft = document.documentElement.scrollLeft;
				var scrollTop = document.documentElement.scrollTop;
			}
            
            var left  = ((document.documentElement.clientWidth - object.width()) / 2)  + scrollLeft;
            var top = ((document.documentElement.clientHeight - object.height()) / 2)  + scrollTop;

            object.css({
            	"left" : left,
            	"top" : top,
            	"z-index" : 990
            });
            
            object.find(".btnClose").find("a").click(function(event) {
				// Add jys
				if (event.preventDefault) 
					event.preventDefault();
				
            	object.fadeOut(200).remove();
            });
            
            $("#onlineRatailor").show();
        }
    }
}

function f_CDRuleGroupLink(target, url) {
	manu_CDRuleGroupLink('samsung',target,'2724',350,320,null,'');
}

function f_SCPNoticePop(target, url) {
	if (notice_getCookie( "scp_notice" ) != "check"){
        var width = 350;
        var height = 480;
        var left = (window.screen.availWidth - width) / 2;
        var top = (window.screen.availHeight - height) / 2;
        var windowName = "noticePop";
        var win = window.open(url+"?modelCode="+target, windowName, "top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ", toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0");
        win.window.focus();
    } else {
        sendDirect(target);
    }
}

function notice_getCookie( name ){
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie.length ) {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                endOfCookie = document.cookie.length;
                return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf( " ", x ) + 1;
        if ( x == 0 )
            break;
    }
    return "";
}

function sendDirect(modelCode) {
    var url = "http://www.samsungcanadaparts.com/model/"+modelCode;
    var windowName = "SCP";
    window.open(url, windowName, "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes");
}

