﻿// JScript File
function doRedirect(obj, lang)
{
	if(obj.innerHTML)
	{
		var url = "CreatedLink.aspx?lang=" + lang + "&fi=" + document.getElementById("fi").value + "&code=" + obj.innerHTML;
		window.location = url;
	}
}

function place()
{
	window.open("","place","width=560,height=460,resizable=yes,status=no,scrollbars=yes,menubar=no,directories=no,toolbar=no")
}

var OnlineOrderingLink = "<a href=\"http://reorder.libertysite.com\" target=\"_blank\"REPLACETITLE>REPLACETHIS</a>";;
var FraudLink = "<a href=\"http://www.cuu.com/liberty/fraud_series.htm\" target=\"_blank\"REPLACETITLE>REPLACETHIS</a>";
var myUrl;

function MakeFraudLinks(obj, lang, sitelink)
{
    if(obj.innerHTML)
    {
        // get the innerHTML of what was clicked on
        var myStr = obj.innerHTML;

        // this is the link we will be working with
        if (sitelink == 'onlineordering') {
            myUrl = OnlineOrderingLink;
        } else {
            myUrl = FraudLink;
        }

        if (myStr.indexOf('<img') > -1 || myStr.indexOf('<IMG') > -1)  {
             // they clicked on an image, replace some text
             myUrl = myUrl.replace('REPLACETITLE', '');
             if (document.URL.indexOf('localhost') > 0) {
                // don't replace the str
             } else if (document.URL.indexOf('dev') > 0) {
                // dev site
                myStr = myStr.replace('src="', 'src="http://dev.linktoliberty.com');
             } else if (document.URL.indexOf('test') > 0) {
                // test site
                myStr = myStr.replace('src="', 'src="http://test.linktoliberty.com');
             } else {
                myStr = myStr.replace('src="', 'src="http://www.linktoliberty.com');
             }
             
             
        } else {
            // they clicked on a text link, replace some text
            var myTitle = ' title=\"' + myStr + '\"'
            myUrl = myUrl.replace('REPLACETITLE', myTitle);
        }
        // replace the inner text
        myUrl = myUrl.replace('REPLACETHIS', myStr);
        // update the textarea with the next string
        document.getElementById("taCode").value = myUrl;
        // update the displayed example
        document.getElementById("logo-td").innerHTML = myUrl;
    }
}