
<!--
function SetCookie(name,value,expires,path,domain,secure) {
var expDate = new Date();
expDate.setTime(expDate.getTime() + expires);
var expString = ((expires == null) ? "" : ("; expires=" + expDate.toGMTString()))
var pathString = ((path == null) ? " " : ("; path=" + path))
var domainString = ((domain == null) ? " " : ("; domain=" + domain))
var secureString = ((secure == true) ? "; secure" : " ")
document.cookie = name + "=" + escape(value) + expString + pathString + domainString + secureString;
} // end of function 'generic set cookie'

// eg WriteCookie("PetlynEshop","Order1",asx1) 


function WriteCookie(w,n,v) {     // v is the data
// w = name of the website  n=variable name  v=value
n = w+" "+n
// set to expire in 30 days
var e = 30 * 24 * 60 * 60 * 1000;
SetCookie(n,v,e,null,null,null);        
} // end of WriteCookie function



function DisplayMostRecent (searchName) {
var result = null;
var myCookie = " " + unescape(document.cookie) + ";" ;   
//var searchName = "ShopOrder " ;       
var StartOfCookie = myCookie.indexOf(searchName)  
var EndOfCookie;
if (StartOfCookie != -1) {    //no cookies at all  returns null
StartOfCookie += searchName.length;  
EndOfCookie = myCookie.indexOf(";",StartOfCookie);  
result = unescape(myCookie.substring(StartOfCookie,EndOfCookie));
}
if (result !== null) {
var equ = result.indexOf("=")    
result = result.substring(equ+1)
}
return result;   // null if no cookie otherwise value returned                  
} //end of function


/*

// SECTION FOR NAME (COMMENTS ON 2nd run)
res1 = DisplayMostRecent("NickName");
if (res1 == null) {
var n = prompt("Could We have your Nickname for this website so we can say hi to you next  time you visit - any name will do","Andy");
if (n == null) { n = "No Name" }
var e = 30 * 24 * 60 * 60 * 1000;
SetCookie("NickName",n,e,null,null,null);         //  n= eg Andy,  e=expires[30 days] 
}                          
res1 = DisplayMostRecent("NickName")
nickname = res1

*/

document.write("<B><FONT FACE=ARIAL><CENTER>")  // set the initial font etc
// document.write("<FONT COLOR=Brown>Welcome Back " + res1 + ",</FONT>" )





// SECTION FOR LAST DATE VISITOR

var ddx = new Date() ;                    //todays date and time on opening file
ddx = ddx.toLocaleString() ;        //06 February 2004 19:36:26  (with UTC removed)
res = DisplayMostRecent("QuizDate");  //check if there is a QuizDate cookie in variable res
if (res == null) {
WriteCookie("Website","QuizDate",ddx)    // first time
res = DisplayMostRecent("QuizDate") }  
WriteCookie("Website","QuizDate",ddx)                     // write todays date of visit for next time
document.write("<font color = 'blue'> You last visited us on "+ res + ",</font>")
LastVisit = res    // for sending stats


// SECTION FOR VISIT COUNT
var res=""
var v = 0
res = DisplayMostRecent("VisitQuiz");  
if (res == null) {
WriteCookie("Website","VisitQuiz",0)                            
res = DisplayMostRecent("VisitQuiz") }  
v = Number(res)
v = v + 1
WriteCookie("Website","VisitQuiz",v)
document.write("<font color = 'green'> And you have visited us "+v+" times now</font>")
visits = v   // needed to count visits to start the comments prompt box later


/*
res2=""
if (visits > 1) {  // Trigger this on the 2nd visit
res2 = DisplayMostRecent("Comments");  
if (res2 == null) {
var v = prompt("Hi " + nickname+", this is your "+visits+"[t] Visit to our website, can we ask how you rated it last time - be nice!","Brill!");
if (v == null) { v = "No Comment" }
var e = 30 * 24 * 60 * 60 * 1000;
SetCookie("Comments",v,e,null,null,null);        // v = eg Brill
}                          
res2 = DisplayMostRecent("Comments")
document.write("<BR><FONT COLOR=Purple>And you think our website is "+res2+"</FONT>")
}
YourComments = res2   // comments for sending
*/


document.write("</B></CENTER></FONT>")  // close the initial font etc



function showIT(cookie) {
document.write("<h4><center><font color = 'blue'>" + cookie + "</font></center></h4><br>")
}



document.writeln('<FORM NAME = "Comments" METHOD="POST" ACTION = "http://www.andywrob.co.uk/Comments/common3.php" TARGET="SomewhereElse">')
document.writeln('<INPUT TYPE = "Hidden" Name = "Website" Value = " ">')
document.writeln('<INPUT TYPE = "Hidden" Name = "VisitComments"  Value=" ">')
document.writeln('<INPUT TYPE = "Hidden" Name = "Referrer" Value =" ">')
document.writeln('<INPUT TYPE = "Hidden" name = "AntiFlood" value = "22FF2230PHP60HI">')
// document.writeln('<INPUT TYPE = "SUBMIT" VALUE = "submit">')
document.writeln('</FORM>')



var thi$ = window.location.href
var qy = thi$.indexOf("?",0)
thi$ = thi$.substring(qy)
// document.write(qy + " : " + thi$)
// qy is -1 if ?not found, and therefore prints the whole url
var ColDepth = screen.colorDepth ;
var ScrSize = screen.availWidth+" x "+screen.availHeight ;


var WebSite = "QUIZ"
var nickname = "NOT USED"
var YourComments = "NOT USED";
var WholeString = WebSite + " :: User - " + nickname + " :: Last Visit - " + LastVisit + " :: No of visits - " + visits + " :: Comments - " + YourComments + " :: Color Depth - " + ColDepth + " :: Screen - " + ScrSize + " :: Query String - " + thi$
document.Comments.Website.value = WebSite;
document.Comments.VisitComments.value = WholeString;
if (document.referrer) {
var CameFrom = document.referrer ;
}
else
{
var CameFrom = "No Previous Referrer";
}
document.Comments.Referrer.value = CameFrom;

document.writeln("<iframe  width = 5 height = 5 name = \"SomewhereElse\"></iframe>");

document.Comments.submit();


//-->

