

function isEmail(str) 
{  // are regular expressions supported?
	var supported = 0; 
	if (window.RegExp) 
	{    
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		var tmp;
		if (tempReg.test(tempStr)) supported = 1;  
	}
		
	if (!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function SearchCheck(strTest)
	{
		var i=0;
		
		if ((strTest==''))
		{
			i=1;
		}
		
		if (i==0)
		{	
			Form1.action='Searcher.aspx';
			Form1.submit();
		} else
		{
			alert('Please enter search criteria');
		}
	}

function LogCheckLogin(strEmail)
	{
		//alert(isEmail(strEmail));
		if (isEmail(strEmail)==true)
			{
				Form1.action='Login.aspx?T=1';
				//alert(Form1.action);
				Form1.submit();
			} else {
				alert("Our login process has recently changed.\n\nPlease provide your email address that you\nregistered with and password.");
			}
	}
	
function LogCheckForget()
	{
		var i=0;
		
		if ((Form1.LogintxtForget.value=='Your email address') || (Form1.LogintxtForget.value==''))
		{			
			i=1;
		}
		
		var strTemp = Form1.LogintxtForget.value;
		if (isEmail(strTemp)==false)
		{	
			i=1;	
		} 
		
		if (i==0)
		{	
			Form1.action='Login.aspx?T=5';
			Form1.submit();
		} else
		{
			alert('Please enter a valid email address');
		}
	}
	
function GetWindow(strURL)
	{
		var mywindow;
		var wH = 500;
		var wW = 640;
		//alert(strURL);
		mywindow = window.open (strURL,"","location=0,status=0,scrollbars=1,toolbar=0,resizable,width=640,height=500");
	
		mywindow.resizeTo(wW,wH);
	    	mywindow.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2));
	}

function NewWindow(strURL)
	{
		var mywindow;
		mywindow = window.open (strURL,"","location=1,status=0,scrollbars=1,toolbar=1,resizable,width=800,height=600");
	
	}
	
function GetComment(strID)
	{
		var wH = 400;
		var wW = 640;
		
		var commentwindow = window.open ("Popups/CommentsPop.aspx?id=" + strID,"","location=0,status=0,scrollbars=1,toolbar=0,resizable,width=640,height=400");
	
		commentwindow.resizeTo(wW,wH);
	    	commentwindow.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2));
	}	

function GetTestimonial()
	{
		var wH = 400;
		var wW = 640;
		
		var testimonialwindow = window.open ("Popups/AffirmationPop.aspx","","location=0,status=0,scrollbars=1,toolbar=0,resizable,width=640,height=400");
	
		testimonialwindow.resizeTo(wW,wH);
	    	testimonialwindow.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2));
	}	
	
function EmailPage(strURL)
	{
		var strText = new String();
		var strValue = new String();
		strText = strURL;
		strText = strText.replace('?','!');
		strText = strText.replace('&','~');
		strText = strText.replace('=','^');
		
		var EWindow;
		var wH = 500;
		var wW = 640;
		//alert(strURL);
		EWindow = window.open ("Popups/EmailPage.aspx?Tag="+strText,"","location=0,status=0,scrollbars=1,toolbar=0,resizable,width=640,height=500");

		EWindow.resizeTo(wW,wH);
		EWindow.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2));
	}

function Go(strTemp)
	{			
		var win;
		var wH = 500;
		var wW = 640;
		win = window.open ("","","location=0,status=0,scrollbars=1,toolbar=0,resizable,width=640,height=500");

		win.resizeTo(wW,wH);
		win.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2))
		
		strTemp = strTemp.replace(/<DIV[\s\S]*?>[\s\S]*?<\/DIV>/g, "");

		win.document.open("text/html","replace");
		win.document.write("<HTML><HEAD>")
			win.document.write("<LINK href=core_Styles.css type=text/css rel=stylesheet><LINK href=../sp_Styles.css type=text/css rel=stylesheet>")
		win.document.write("</HEAD><BODY class=TerrapinnBody><table class=Base width=580>");
			win.document.write(strTemp);
			win.document.write("<tr><td valign=top class=tbContent colspan=2><div style=text-align:center><b>Copyright &copy; Terrapinn Limited  2003.  All rights reserved.</b></div></td></tr>");
			win.document.write("<tr><td valign=top class=tbContent colspan=2><input class=NewAgeButton type=button value='Print >' onclick='window.print();'><br>");
			win.document.write("<input class=NewAgeButton type=button value='Back >' onclick='parent.opener.window.focus();window.close();'></td></tr>");
		win.document.write("</table></BODY></HTML>");
		win.document.close();
		win.window.print();
		//win.window.close();
	}		
	
function LogSubscribe(strKey)
	{
	//alert('This service is currently unavailable.\n\nOur apologies for any inconvenience caused.\nPlease try again in 60 minutes.');
	var SubWindow = window.open("https://secure.terrapinn.com/Frm_StartPage.aspx?PRK=" + strKey,"","fullscreen=no,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,directories=yes,location=yes,width=640,height=500");
	}
	
function LogFreeTrial(strKey)
	{
	//alert('This service is currently unavailable.\n\nOur apologies for any inconvenience caused.\nPlease try again in 60 minutes.');
	var TrialWindow = window.open("https://secure.terrapinn.com/Frm_StartPage.aspx?PRK=" + strKey,"","fullscreen=no,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,directories=yes,location=yes,width=640,height=500");
	}
	
	
	
function LogForgetPWD()
	{
	window.location='Login.aspx?T=5';
	}
function LogCheckLogout()
	{
	window.location='Login.aspx?T=2';
	}
function LoginChange()
	{
	window.location='Login.aspx?T=4';
	}
	
	
function CommitPoll(intPollID,intResults)
	{
		var flgOK=0;
		var theOne=0;
		if (intResults==1)
		{
			for (var i=0;i<Form1.Polls.length;i++)
				{
				if (Form1.Polls(i).checked)
					{
						flgOK=1;
						theOne=Form1.Polls(i).value;
					}
				}
		} else
		{
			theOne=0;
			flgOK=1;
		}

		if (flgOK==1) 
		{	
			// Pop up new window......
			var PollWindow = window.open("Popups/PollPop.aspx?ID=" + intPollID + "&Option=" + theOne,"","location=0,status=0,scrollbars=1,toolbar=0,resizable");

			var wW = 450;
			var wH = 350;

			PollWindow.resizeTo(wW,wH);
			PollWindow.moveTo((screen.availWidth/2)-(wW/2),(screen.availHeight/2)-(wH/2))


		} else {
			// Tell user failed......
			alert("Please select an option to vote for");
		}
			
	}
	
function DoHassle(intDays, strKey)
	{
	
	if (intDays<31)
		{
		
		if (confirm('Your subscription will expire in ' + intDays + ' days.\n\nIf you want to continue to learn from best practice case studies\nand have access to the full archive you need to renew your subscription.\n\nClick OK to renew.\n\nPlus it will stop this message interrupting your research!'))
			{
				LogSubscribe(strKey);
			}
		}
	
	}
	
function WriteCookieText()
	{
	
	alert('A cookie has been written to your machine!');
	
	}


function GetMPWindow(strURL)
	{
		//var mywindow;
		//mywindow = window.open (strURL,"","location=1,status=1,scrollbars=1,toolbar=1,resizable,width=790,height=590");
		//alert('hello');
		//mywindow.resizeTo(790,590);
	    	
	    	window.location=strURL
	    	//mywindow.moveTo((screen.availWidth/2)-(790/2),(screen.availHeight/2)-(590/2));
	}
