// INTERACTION SCRIPTS - all rights delimit.net - revision 20100120

// Objects
function Client(){
	this.browser = false
	this.date = ""
	this.interact = false
	this.lastdate = ""
	this.lastvisit = "Unknown"
	this.name = ""
	this.email = ""
	this.lastno = 0
	this.tips = ""
	this.gender = ""
	this.newbie = true
	}
function Catalog( page, lastid ){
	this.version = "04"
	this.name = page
	this.contents = ""
	this.past = ""
	this.newfrom = "" 
	this.open = openCatalog
	this.save = saveCatalog
	this.ap = applyCatalog
	this.to = toggleCatalog
	this.alt = statusCatalog
	this.init = initCatalog
	this.init( lastid )
	this.checklist = ""
	this.changed = false
	this.wait = 6000
	this.clean = cleanCatalog
	}
function CatList( page ){
	this.version = "04"
	this.name = page
	this.contents = ""
	this.past = ""
	this.open = openCatalog
	this.open()
	}

checkbox = new Image(); checkbox.src="pages/cb/cb.gif"
checknew = new Image(); checknew.src="pages/cb/checknew.gif"
checkyes = new Image(); checkyes.src="pages/cb/checkyes.gif"
checknot = new Image(); checknot.src="pages/cb/checknot.gif"
checktip = new Image(); checktip.src="pages/cb/checktip.gif"
	
// Catalog Methods
function initCatalog( lastid ){
	if (!visitor.interact){
		right.document.write('<p align="center"><a href="cockpit.htm" target="right">Click here if you want to use our check boxes <img src="cb/checknot.gif" width=13 height=12 border=0> to mark your favorites</a></p>')
		this.newfrom="Zzz"; return
		}
	this.open()
	if (this.past==""){
		this.past = lastid+"зв"+lastid+"зв"+lastid+"зв"+lastid
		right.document.write('<p align="center"><b>From your next visit at this page, new additions <u>from today</u> will be highlighted with <img src="cb/checknew.gif" width=13 height=12 border=0></b><br>You can mark your favorite web sites for future visits by clicking the check boxes <img src="cb/checknot.gif" width=13 height=12 border=0></p>')
		} 
	else right.document.write('<p align="center">Simply mark your favorite web sites by clicking the yellow check boxes <img src="cb/checknot.gif" width=13 height=12 border=0></p>')
	var list = this.past.split("зв")
	var from = list[3]
	if (visitor.date-parent.visitor.lastdate>Math.exp(16)) {
		from = list[2]
		this.past = lastid+"зв"+list[0]+"зв"+list[1]+"зв"+list[2]
		}
	this.newfrom = from
	this.save()
	}
function openCatalog(){
	if (!parent.visitor.interact) return
	var allstuff = readCookie( this.name )
	if (allstuff.substring(0,2)!=this.version) allstuff = this.version+"звзвзвзв"
	var list = allstuff.split("звзв")
	this.past = list[1]
	this.contents = list[2]
	writeCookie( this.name, allstuff )
	}
function saveCatalog(){
	if (!parent.visitor.interact) return
	writeCookie( this.name, this.version+"звзв"+this.past+"звзв"+this.contents )
	}
function toggleCatalog( site ){
	img="right.document."+site
	if (!visitor.interact){
		window.alert("Enable this feature at our Control Center.\nClick on the link above this table.")
		return
		}
	this.changed=true
	var n = this.contents.indexOf( site )
	if ( n<0) this.contents += site
	else this.contents = this.contents.substring(0,n) + this.contents.substring(n+3,this.contents.length)
	this.save()
	eval(img+".src=checkbox.src")
	eval(img+".onload()")
	}
function applyCatalog( site ){
	img="right.document."+site
	if (!parent.visitor.interact) return
	if (eval(img+".src").indexOf('cb.gif')>=0){
		var n = this.contents.indexOf( site )
		if ( n<0 ) {
			if (site>this.newfrom) eval(img+".src=checknew.src")
			else {
				if (parent.visitor.tips.indexOf(site)>=0 )
					eval(img+".src=checktip.src")
					else eval(img+".src=checknot.src")
				}
			}
		else {
			this.checklist+=site
			eval(img+".src=checkyes.src")
			}
		}
	}
function statusCatalog( alt ){
	return alt
	}
function showCatalogs( chance ){
	var draw = Math.random()
	if (draw<chance){
		lin = new CatList("links")
		art = new CatList("art")
		mee = new CatList("meeting")
		fiw = new CatList("fitwomen")
		bbw = new CatList("bbwomen")
		com = new CatList("commerce")
		eve = new CatList("event")
		fit = new CatList("fitness")
		oth = new CatList("other")
		blg = new CatList("blogs")
		all = lin.contents+art.contents+mee.contents+fiw.contents+bbw.contents+com.contents+eve.contents+fit.contents+oth.contents+blg.contents
		all = all.replace('undefined','')
		all = all.replace('NaN','')
		if (all.length>0){
			dummy = new Image()
			dummy.src = "http://www.delimit.net/cgi-bin/catalogs.pl?contents="+all
			}
		else request="NoLinksChecked"
		}
	}
function cleanCatalog( ){
	if (!this.changed && this.contents.length>this.checklist.length){
		this.contents=this.checklist
		this.save()
		}
	}

// Client Settings functions
function loadSettings(){
	time = new Date()
	visitor = new Client()
	var browser = navigator.appName
	var version = parseInt(navigator.appVersion)
	if ( browser.indexOf("Netscape") >=0 && version >= 3 || browser.indexOf("Explorer") >=0 && version >=4 ) visitor.browser=true
	if (visitor.browser){
		line = readCookie( "settings" )
		if (line=="") return
		list = line.split("зв")
		visitor.date = time.getTime()
		if (list[0] == "true") visitor.interact = true
		visitor.lastdate = list[1]
		time.setTime(visitor.lastdate)
		visitor.lastvisit = time.toLocaleString()
		visitor.name = list[2]
		visitor.email = list[3]
		if (list[4]>0) visitor.lastno = list[4]
		if (list.length>5) visitor.gender = list[5]
		saveSettings()
		showCatalogs(1)
		}
	}
function applySettings(){
	right.document.cockpit.enable.checked = visitor.interact
	right.document.cockpit.person.value = visitor.name
	right.document.cockpit.email.value = visitor.email
	if (visitor.gender=="F") right.document.cockpit.gender[0].checked = true 
	else if (visitor.gender=="M") right.document.cockpit.gender[1].checked = true
	}
function updateSettings() {
	if (visitor.browser) visitor.interact = right.document.cockpit.enable.checked
	if (right.document.cockpit.person.value.indexOf("зв")<0) visitor.name = right.document.cockpit.person.value
	if (right.document.cockpit.email.value.indexOf("зв")<0) visitor.email = right.document.cockpit.email.value
	if (right.document.cockpit.gender[0].checked) visitor.gender="F"
	else if (right.document.cockpit.gender[1].checked) visitor.gender="M"
	saveSettings()
	}
function saveSettings() {
	if (visitor.browser)
		writeCookie( "settings", visitor.interact+"зв"+visitor.date+"зв"+visitor.name+"зв"+visitor.email+"зв"+visitor.lastno+"зв"+visitor.gender )
	else window.alert("Your browser does not support this feature")
	}
function copySetting( target, proprty ){
	if (!visitor.interact) return
	eval("right.document."+target+"= visitor."+proprty)
	}
function fillSettings( form ){
	copySetting( form+".realname.value", "name" )
	copySetting( form+".email.value", "email" ) 
	copySetting( form+".interact.value", "interact")
	copySetting( form+".gender.value", "gender")
	copySetting( form+".lastvisit.value", "lastvisit")
	eval( "right.document."+form+".appname.value = navigator.appName" ) 
	eval( "right.document."+form+".appversion.value = navigator.appVersion" ) 
	}
function checkNewbie(){
	if (visitor.browser && !visitor.interact && visitor.name==""){
   		visitor.name = "Visitor"
	  	visitor.interact = true
	  	saveSettings()
   	  	}
	else visitor.newbie = false
	}	   
function setGender( gender ){
	if (right.document.askgender.gender[0].checked) visitor.gender="F"
	else if (right.document.askgender.gender[1].checked) visitor.gender="M"
	saveSettings()
	}	   
	
// Functions for cookies
function writeCookie( name, contents ){
	var expired = new Date(); expired.setYear(1900)
	document.cookie = name+"= ; expires="+expired.toGMTString()
	var expiry = new Date()
	expiry.setTime(expiry.getTime()+Math.exp(24))
	document.cookie = name+"="+escape(contents)+"; expires="+expiry.toGMTString()+"; domain=delimit.net; path= "
	}
function readCookie( name ){
	var list = document.cookie.split(';')
	var contents = ""
	for (i=0; i<list.length; i++){
		n = list[i].indexOf( name+"=" )
		if ( n>=0 ) contents = list[i].substring( n+name.length+1, list[i].length )
		}
	return unescape(contents)
	}

//Message functions
function stopMessage(number){
	if (number>0) { visitor.lastno = number; saveSettings() }
	}
function showMessage(number){
	if (todaysMessage=='' || visitor.newbie) return ''
	if (number>0 && (visitor.lastno>=number || !visitor.interact)) return ''
	var but=''
	if (todaysLink!='') { 
		but=todaysButton; if (but=='') but='OK';
		but='<input type="button" value="'+but+'" onClick="parent.stopMessage('+number+');if(parent.todaysCafe!=\'\')parent.tempCafe=parent.todaysCafe;if(parent.todaysMenu!=\'\')parent.left.location.href=parent.todaysMenu;if(parent.todaysLink!=\'\')parent.right.location.href=parent.todaysLink">' 
		}
	if (number>0) but=but+'&nbsp;<input type="button" value="Clear" onClick="parent.stopMessage('+number+');location.reload()">'
	var msg='<form name="message"><table width=570 cellpadding=5 border=0 bgcolor="gold"><tr><td><center><font size=3 color="#003300"><b>'+todaysMessage+'</b></font><br>'+but+' </center></td></tr></table></form>'
	return msg
	}
function resetMessage(){
	if (visitor.lastno<todaysNumber || todaysNumber<=0) return false
	visitor.lastno=todaysNumber-1 
	saveSettings()
	return true
	}