﻿function getVariationCode()
{
	var url = window.top.location.href.toLowerCase();
	url=url.replace("://","");
	var removehost = url.substring(0, url.indexOf("/")+1);
	url=url.replace(removehost, "");
	var sitename="sites/familyfirst/";
	url=url.substring( url.indexOf(sitename),sitename.length + 2);
	url=url.replace(sitename, "");	
	return url;
}

function VariationRedirect(redirectTo)
{
  window.location = "/" + getVariationCode() + redirectTo;
}

function VariationCurrrentRedirect(redirectTo)
{
  window.location = "/"  + "sites/familyfirst/"+ getVariationCode() + redirectTo;
}

function VariationCurrrentRedirectNew(redirectTo)
{
  window.open( "/"  + "sites/familyfirst/" + getVariationCode() + redirectTo);
}


function VariationRedirectNew(redirectTo)
{
  window.open( "/" + getVariationCode() + redirectTo);
}

//Pop out new small security form
function securityPopUp(url) {
		var curUrl = "/_layouts/CorporateWebsite/popupconfirmation.asp?url=" + url;
		window.open(curUrl ,'','width=400,height=280,scrollbars=no,resizable=no,top=100,left=200');
	}

function printContent(id){
str=document.getElementById(id).innerHTML;
newwin=window.open('','printwin','left=100,top=100,width=580,height=400');
newwin.document.write('<HTML>\n<HEAD><meta name="WebPartPageExpansion" content="full" /><meta name="WebPartPageExpansion" content="full" /><meta name="WebPartPageExpansion" content="full" /><meta name="WebPartPageExpansion" content="full" /><meta name="WebPartPageExpansion" content="full" /><meta name="WebPartPageExpansion" content="full" />\n');
newwin.document.write('<TITLE>Print Page</TITLE>\n');
newwin.document.write('<scr'+ 'ipt>\n');
newwin.document.write('function chkstate(){\n');
newwin.document.write('if(document.readyState=="complete"){\n');
newwin.document.write('window.close()\n');
newwin.document.write('}\n');
newwin.document.write('else{\n');
newwin.document.write('setTimeout("chkstate()",2000)\n');
newwin.document.write('}\n');
newwin.document.write('}\n');
newwin.document.write('function print_win(){\n');
newwin.document.write('window.print();\n');
newwin.document.write('}\n');
newwin.document.write('<\/script>\n');
newwin.document.write('<style>\n');
newwin.document.write('.fx-MainContents{padding:13px;padding-top:5px;}\n');
newwin.document.write('<\/style>\n');
newwin.document.write('</HEAD>\n');
newwin.document.write('<BODY onload="print_win();close();">\n');
newwin.document.write(str);
newwin.document.write('</BODY>\n');
newwin.document.write('</HTML>\n');
newwin.document.close();
}
	


//please put in the list at the arry "thelists" 0 to 9 if need add more .. just create start from 10 to number needed
    var thelists = new Array();
    thelists[0] = "A budget planner will help you tabulate your total income and organize your expenses. It gives you an idea of where your money goes and how to make changes to plan and manage your finances better.";
    thelists[1] = "Simply by flashing your Family First Card at selected merchants, you will be rewarded with exciting privileges.";
    thelists[2] = "If you issue a standing instruction to transfer a small amount of fund directly from your salary to a Savings Account, your savings will grow automatically every month!";
    thelists[3] = "Keep your expenses in check so that you do not fall into the debt trap.";
    thelists[4] = "Think about how you want to live your life and set some goals. You'll be surprised how motivated you'll be when you have something to look forward to.";
    thelists[5] = "Saving will be easier than you think when you have a budget to tell you where your money is going.";
    thelists[6] = "It is always a good idea to have separate accounts to manage your transactional and saving funds. When you do this, you are more likely to keep to your budget and not dip into your savings.";
    thelists[7] = "Children learn from their parents. Teach your child the value of money by being open about how you manage your finances.";

    var tNum = thelists.length;
    var nums = new Array();
    var a = 0;
    while (nums.length != tNum) {
        thisNum = Math.round(Math.random() * ((tNum - 1) - 0)) + 0;
        found = false;
        var b = 0;
        for (b = 0; b < nums.length; b++) {
            if (thisNum == nums[b]) {
                found = true;
            }
        }
        if (found != true) {
            nums[a] = thisNum;
            a++;
        }
    }
    var c = 0;
    function callNext() {
        c++;
        if (c >= tNum) {
            c = 0;
        }
        var n = nums[c];
        document.getElementById('nlist').innerHTML = thelists[n];
    }
    function callPrev() {
        c--;
        if (c < 0) {
            c = tNum - 1;
        }
        var n = nums[c];
        document.getElementById('nlist').innerHTML = thelists[n];
    }
    //setTimeout("callNext()", 100);
    function mailpage() {
        mail_str = "mailto:?subject=AmBank Family First Solution";
        mail_str += "&body=Hi there, %0D%0A %0D%0AI find AmBank Family First really interesting and helpful. Check it out at the following link http://www.familyfirst.com.my ";
        location.href = mail_str;
    }

