function writeBannerURL(refr,banner,w,h) {
	sLink="http://www.membersequitybank.com.au/";	
	if (banner.indexOf('.swf') !=-1) {	
		sURL="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+w+"\" height=\""+h+"\">";
		sURL=sURL+"<param name=\"movie\" value=\""+sLink+banner+"?url="+sLink+refr+"\"/>";
		sURL=sURL+"<param name=\"quality\" value=\"high\" />";
		sURL=sURL+"<embed src=\""+sLink+banner+"?url="+sLink+refr+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\" /></object>";
   } else {
		sBanner="<img border=\"0\" src=\""+sLink+banner + "\">";
		sURL="<a target=\"_blank\" href=\""+sLink+refr+"\">"+sBanner+"</a>";
	}
	document.writeln(sURL);	
	if (refr.indexOf('-TEST') !=-1) {
		document.writeln("<br>Javscript generated code:<br><textarea cols='120' rows='8'>"+sURL+"</textarea>");
	}
}

/* Code to capture "CID" from URL into session cookie and pass to iApply */

//Default values - user vars

var lookfor = "cid"; /* look for this name in the string */
var defaultvalue = ""; /* default 'lookfor' value - will set to this if not found or zero */
var cookietime = ""; /* in days */

//end user changed vars

// reset values to null
var val = null;

function findCid() {
        //get url search string
        var sURL = location.search.substring(1);

        //do only if param string exist
        if (sURL) {

                // split it name,value pairs
                var argArray = sURL.split('&');

                //loop through pairs looking for cid
                var sloop = 0;
                while (sloop <= argArray.length) {
                        if (argArray[sloop].substring(0).indexOf(lookfor) > -1) {
                                val = argArray[sloop].split('=');
                                // if found stop running loop
                                break;
                        } else if (sloop == argArray.length-1) {
                                // if not element found in search string and last element found then set default values
                                defaultvalues();
                                break;
                        }
                        sloop++;
                }

        } else {
                defaultvalues();
        }

        //CID found at this point

        // write cookie
        createCookie(val[0],val[1],cookietime);
}

function defaultvalues () {
        // if not element found in search string and last element found then set default values
        var defaults = "null=" + defaultvalue;
        val = defaults.split('=');
}

function loadiApply(file) {
        var iscookie = readCookie(lookfor);

 		 if ((screen.Height >=0) && (screen.Width >=0))
        {
                var sWidth2 = screen.Width -40;
                var sHeight2 = screen.Height -95;
        }
        else if ((screen.availHeight >= 0) && (screen.availWidth >= 0))
        {
                var sWidth2 = screen.availWidth -40;
                var sHeight2 = screen.availHeight - 75;
        }

        sOptions2 = "toolbar=no,status=yes,location=no,menubar=no,directories=no,scrollbars=yes,";
        sOptions2 = sOptions2 + "resizable=yes,screenX=0,screenY=0,left=10,top=10,";
        sOptions2 = sOptions2 + "height=" + sHeight2 + ",width=" + sWidth2;
		sTitle2 = "Members_Equity_Application_Form";
		sLoc2 = file;   
		
	// this would redirect the browser and pass your cid
	if (iscookie) {
		//alert('cookie found\ncid = ' + readCookie(lookfor));
			openwindow = window.open(sLoc2 + "?cid=" + readCookie(lookfor),sTitle2,sOptions2);
		} else {
		//alert('no cookie found');
			openwindow = window.open (sLoc2 + location.search,sTitle2,sOptions2);
		}
}

/* cookie handling */

function createCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}

/* end cookie handling */

/* End code to capture "CID" in session cookie and pass to iApply */