/*from /v4/reg/regwelcomeDyn.html */
var random_number = Math.floor(Math.random() * 99999999);
if((navigator.userAgent.indexOf('Mozilla/4.') != -1) && (navigator.userAgent.indexOf('MSIE') == -1)) {
	d.write('<scr' + 'ipt script="text\/script" src="http://www.theglobeandmail.com/servlet/Page/document/v4/reg/regwelcomeTemplate.js?ord=' + random_number +'"></scr' + 'ipt>');
} else {
	if(window.parent != null) { 
		d.write('<div style="position:relative" align="right"><iframe marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="15" width="500"  src="http://www.theglobeandmail.com/v4/reg/regwelcomeIFrame.html?ord=' + random_number +'" ></iframe></div>');
	}
}

/* from /v4/reg/checkCookies.js.html */
function SetCookie(cookieName,cookieValue,nSec) {
	var today = new Date();
	var expire = new Date();
	if (nSec==null || nSec==0) { nSec=1; }
	expire.setTime(today.getTime() + 1000*nSec);
	dd.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
}

function TestCookies(failURL) {
	var cookieName = "QADcookie";
	SetCookie(cookieName, "1", 60*1);
	cookieEnabled = (d.cookie.indexOf(cookieName) >= 0 ? true : false);
	if (!cookieEnabled) {	newWindow = window.open(failURL, "Window1", 'height=580,width=500'); }
}	

/* does cookie check and fixed widths on portfolio registration pages*/
function isPortReg(){
	TestCookies('http://www.theglobeandmail.com/services/site/RegCookies.html');
	if(d.getElementById) {
		var sections = ["header","chewy","footer"];
		for(x=0;sections.length>x;x++){	d.getElementById(sections[x]).style.width = "770px"; }
	}
}
