/* ----------------------------GENERAL---------------------------- */

function guestbook(){
	document.write('<a href="javascript:void(0)" onclick="open(\'http://scripts.dsl.pipex.net/guestread/?username=atjq80\',\'gemstuffguest\',\'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=500,height=450\')" id="menulink_guestbook" title="Guestbook" accesskey="7">Guestbook</a>');
}

function nojava(){
	document.write('');
}

function blocking(nr, cookie, vis_state){
	if (document.layers) {
		current = (document.layers[nr].display == 'none') ? vis_state : 'none';
		document.layers[nr].display = current;
	} else if (document.all) {
		current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
		document.all[nr].style.display = current;
	} else if (document.getElementById) {
		display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
		document.getElementById(nr).style.display = display;
	}
}

function linkaddy(start, end, subject, text){
	code = ( start + '@' + end ); 
	document.write('<a href="mailto:' + code);
	if (subject != 0) {
		code2 = subject;
		document.write( '?subject=' + code2);
	}
	document.write('" title="Send e-mail">' + text + '</a>');
}

function gemcontact() {
	code = ('gem' + '@' + 'gemstuff.co.uk'); 
	document.write( '<a href="mailto:' + code + '" title="E-mail Gem">E-mail Gem</a> | ' );
}

function selectThis(src) {
	document.selection.clear;
	txt = eval(src +".innerText");
	theObj = document.all(txt);
	txtRange = document.body.createTextRange();
	txtRange.moveToElementText(eval(src));
	txtRange.select();
	txtRange.execCommand("Copy");
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function delineate(str) {
	theleft = str.indexOf("=") + 1;
	theright = str.lastIndexOf("&");
	return(str.substring(theleft, theright));
}

function delineate2(str) {
	point = str.lastIndexOf("=");
	return(str.substring(point+1,str.length));
}

function adjust_popup(){
	var w, h, fixedW, fixedH, diffW, diffH;
	if (document.documentElement && document.body.clientHeight==0) {
		fixedW = document.documentElement.clientWidth;
		fixedH = document.documentElement.clientHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - document.documentElement.clientWidth;
		diffH = fixedH - document.documentElement.clientHeight;
		w = fixedW + diffW + 16;
		h = fixedH + diffH;
		if (w >= screen.availWidth) h += 16;
	} else if (document.all) {
		fixedW = document.body.clientWidth;
		fixedH = document.body.clientHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - document.body.clientWidth;
		diffH = fixedH - document.body.clientHeight;
		w = fixedW + diffW;
		h = fixedH + diffH;
		if (h >= screen.availHeight) w += 16;
		if (w >= screen.availWidth)  h += 16;
	} else {
		fixedW = window.innerWidth;
		fixedH = window.innerHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - window.innerWidth;
		diffH = fixedH - window.innerHeight;
		w = fixedW + diffW;
		h = fixedH + diffH;
		if (w >= screen.availWidth)  h += 16;
		if (h >= screen.availHeight) w += 16;
	}
	w = Math.min(w,screen.availWidth);
	h = Math.min(h,screen.availHeight);
	window.resizeTo(w,h);
	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

function viewvideo(vidname, text, current) {
	if(navigator.userAgent.indexOf("Opera")!=-1) {
		var versionindex=navigator.userAgent.indexOf("Opera")+6
		if (parseInt(navigator.userAgent.charAt(versionindex))>=8) {
			var windwidth = 336;
			var windheight = 326;
		} else {
			var windwidth = 320;
			var windheight = 309;
		}
	} else {
		var windwidth = 320;
		var windheight = 309;
	}
	if(current != "yes") {
		var directory = "../";
	} else {
		var directory = "";
	}
	var randomnumber = Math.floor(Math.random()*10001);
	document.write( '<a href="javascript:;" onClick="MM_openBrWindow(\'' + directory + 'videos/viewvideo.html?Dir=babblings&amp;name=' + vidname + '\',\'gemstuffvideo' + randomnumber + '\',\'scrollbars=no,toolbar=no,status=no,location=no,menubar=no,resizable=no,width=' + windwidth + ',height=' + windheight + '\')" title="View video">' + text + '</a>' );
}

/* ----------------------------HOME---------------------------- */

function updates(){
	document.write('<div id="home_lastupdated" style="display: none;" class="home_last_update">');
	document.write('<strong>&rsaquo;</strong> <a href="babblings.html#b16" title="1 new Babbling">1 new Babbling</a><br />');
	document.write('<strong>&rsaquo;</strong> <a href="photos/danovision07.html" title="1 new Photo Album">1 new Photo Album</a></div>');
}

function lastupdated(){
	document.write('<strong><a href="javascript:void(0)" onclick="blocking(\'home_lastupdated\',\'no\',\'block\'); return false;" title="See the latest updates">Last updated</a>:</strong>');
}

function date() {
	date = new Date();
	
	var day_of_week_number = date.getDay();
	var day_of_month = date.getDate();
	var month_number = date.getMonth();
	var year = date.getYear();
	var day_of_week = '';
	var month = '';
	var dayadd = 'th'
	
	if(month_number == 0){month = 'January';}
	if(month_number == 1){month = 'February';}
	if(month_number == 2){month = 'March';}
	if(month_number == 3){month = 'April';}
	if(month_number == 4){month = 'May';} 
	if(month_number == 5){month = 'June';}
	if(month_number == 6){month = 'July';}
	if(month_number == 7){month = 'August';}
	if(month_number == 8){month = 'September';}
	if(month_number == 9){month = 'October';}
	if(month_number == 10){month = 'November';}
	if(month_number == 11){month = 'December';}
	
	if(day_of_week_number == 0){day_of_week = 'Sunday';}
	if(day_of_week_number == 1){day_of_week = 'Monday';}
	if(day_of_week_number == 2){day_of_week = 'Tuesday';}
	if(day_of_week_number == 3){day_of_week = 'Wednesday';}
	if(day_of_week_number == 4){day_of_week = 'Thursday';}
	if(day_of_week_number == 5){day_of_week = 'Friday';}
	if(day_of_week_number == 6){day_of_week = 'Saturday';}
	
	if(day_of_month == 1){dayadd = 'st';}
	if(day_of_month == 2){dayadd = 'nd';}
	if(day_of_month == 3){dayadd = 'rd';}
	if(day_of_month == 21){dayadd = 'st';}
	if(day_of_month == 22){dayadd = 'nd';}
	if(day_of_month == 23){dayadd = 'rd';}
	if(day_of_month == 31){dayadd = 'st';}
	
	if(year == 106){fullyear = '2006';}
	if(year == 2006){fullyear = '2006';}
	if(year == 107){fullyear = '2007';}
	if(year == 2007){fullyear = '2007';}
	if(year == 108){fullyear = '2008';}
	if(year == 2008){fullyear = '2008';}
	
	var date_to_show = day_of_week + ', ' + day_of_month + dayadd + ' ' + month + ' ' + fullyear;
	document.write(date_to_show);
}

function sitetracker(){

	id="dankett"

	if(showme==null) var showme='n'
	if(st==null)     var st='js'

	s=0;c=0
	f=""+escape(top.document.referrer)
	sw=screen.width;sh=screen.height;s=sw+"x"+sh
	v=navigator.appName
	if (v != "Netscape") c=screen.colorDepth
	else c=screen.pixelDepth

	r="?id="+id+"&referer="+f+"&r="+s+"&c="+c+"&showme="+showme+"&st="+st

	if (st=='js') {
		if (v != "Microsoft Internet Explorer") {
			r = r+"&url="+document.URL
		}
		document.open()
		document.write('<script language="JavaScript" src="http://scripts.dsl.pipex.net/sitetracker/sitetracker.php'+r+'\"></script><noscript>&nbsp;</noscript>')
		document.close()
	} else {
		rand=Math.round(1000*Math.random())
		r = r+"&b="+rand
		document.open()
		document.write('<img src="http://scripts.dsl.pipex.net/sitetracker/sitetracker.php'+r+'">')
		document.close()
	}
}

/* ----------------------------BABBLINGS---------------------------- */

function babblingheader(year){
	document.write('&rsaquo; <a href="javascript:void(0)" onclick="blocking(\'babblings_' + year + '\',\'no\',\'block\'); return false;" title="View the ' + year + ' archive">' + year + '</a><br />');
}

function babblinglist_2006(current){
	if(current != "yes") {
		var directory = "";
	} else {
		var directory = "babblings/";
	}
	document.write('<div id="babblings_2006" style="display: none;">');
	document.write('<div id="babbling_archive0612">0</div>December<br />');
	document.write('<div id="babbling_archive0611">2</div><a href="' + directory + '0611november.html" title="Go to November 2006">November</a><br />');
	document.write('<div id="babbling_archive0610">2</div><a href="' + directory + '0610october.html" title="Go to October 2006">October</a><br />');
	document.write('<div id="babbling_archive0609">2</div><a href="' + directory + '0609september.html" title="Go to September 2006">September</a><br />');
	document.write('<div id="babbling_archive0608">5</div><a href="' + directory + '0608august.html" title="Go to August 2006">August</a><br />');
	document.write('<div id="babbling_archive0607">3</div><a href="' + directory + '0607july.html" title="Go to July 2006">July</a><br />');
	document.write('<div id="babbling_archive0606">6</div><a href="' + directory + '0606june.html" title="Go to June 2006">June</a><br />');
	document.write('<div id="babbling_archive0605">6</div><a href="' + directory + '0605may.html" title="Go to May 2006">May</a><br />');
	document.write('<div id="babbling_archive0604">3</div><a href="' + directory + '0604april.html" title="Go to April 2006">April</a><br />');
	document.write('<div id="babbling_archive0603">6</div><a href="' + directory + '0603march.html" title="Go to March 2006">March</a><br />');
	document.write('<div id="babbling_archive0602">4</div><a href="' + directory + '0602february.html" title="Go to February 2006">February</a><br />');
	document.write('<div id="babbling_archive0601">6</div><a href="' + directory + '0601january.html" title="Go to January 2006">January</a></div>');
}

function babblinglist_2005(current){
	if(current != "yes") {
		var directory = "";
	} else {
		var directory = "babblings/";
	}
	document.write('<div id="babblings_2005" style="display: none;">');
	document.write('<div id="babbling_archive0512">6</div><a href="' + directory + '0512december.html" title="Go to December 2005">December</a><br />');
	document.write('<div id="babbling_archive0511">6</div><a href="' + directory + '0511november.html" title="Go to November 2005">November</a><br />');
	document.write('<div id="babbling_archive0510">4</div><a href="' + directory + '0510october.html" title="Go to October 2005">October</a><br />');
	document.write('<div id="babbling_archive0509">7</div><a href="' + directory + '0509september.html" title="Go to September 2005">September</a><br />');
	document.write('<div id="babbling_archive0508">7</div><a href="' + directory + '0508august.html" title="Go to August 2005">August</a><br />');
	document.write('<div id="babbling_archive0507">8</div><a href="' + directory + '0507july.html" title="Go to July 2005">July</a><br />');
	document.write('<div id="babbling_archive0506">4</div><a href="' + directory + '0506june.html" title="Go to June 2005">June</a><br />');
	document.write('<div id="babbling_archive0505">6</div><a href="' + directory + '0505may.html" title="Go to May 2005">May</a><br />');
	document.write('<div id="babbling_archive0504">8</div><a href="' + directory + '0504april.html" title="Go to April 2005">April</a><br />');
	document.write('<div id="babbling_archive0503">8</div><a href="' + directory + '0503march.html" title="Go to March 2005">March</a><br />');
	document.write('<div id="babbling_archive0502">11</div><a href="' + directory + '0502february.html" title="Go to February 2005">February</a><br />');
	document.write('<div id="babbling_archive0501">12</div><a href="' + directory + '0501january.html" title="Go to January 2005">January</a></div>');
}

function babblinglist_2004(current){
	if(current != "yes") {
		var directory = "";
	} else {
		var directory = "babblings/";
	}
	document.write('<div id="babblings_2004" style="display: none;">');
	document.write('<div id="babbling_archive0412">9</div><a href="' + directory + '0412december.html" title="Go to December 2004">December</a><br />');
	document.write('<div id="babbling_archive0411">9</div><a href="' + directory + '0411november.html" title="Go to November 2004">November</a></div>');
}

function babblingsphoto(file, width, height, text, current){
	if(navigator.userAgent.indexOf("Opera")!=-1) {
		var versionindex=navigator.userAgent.indexOf("Opera")+6
		if (parseInt(navigator.userAgent.charAt(versionindex))>=8) {
			var windwidth = width + 16;
			var windheight = height + 25;
		} else {
			var windwidth = width + 16;
			var windheight = height + 16;
		}
	} else {
		var windwidth = width + 16;
		var windheight = height + 16;
	}
	if(current == "yes") {
		var directory = "babblings/";
	} else {
		var directory = "";
	}
	var randomnumber = Math.floor(Math.random()*10001);
	document.write( '<a href="javascript:;" onClick="MM_openBrWindow(\'' + directory + 'viewphoto.html?Dir=babblings&amp;PhotoID=' + file + '\',\'gemstuffphoto' + randomnumber + '\',\'scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,width=' + windwidth + ',height=' + windheight + '\')" title="Click to see photo">' + text + '</a>' );
}

function babblingsphotogallery(folder, file, width, height, text, current){
	if(navigator.userAgent.indexOf("Opera")!=-1) {
		var versionindex=navigator.userAgent.indexOf("Opera")+6
		if (parseInt(navigator.userAgent.charAt(versionindex))>=8) {
			var windwidth = width + 16;
			var windheight = height + 25;
		} else {
			var windwidth = width + 16;
			var windheight = height + 16;			
		}
	} else {
		var windwidth = width + 16;
		var windheight = height + 16;		
	}
	if(current != "yes") {
		var directory = "../";
	} else {
		var directory = "";
	}
	var randomnumber = Math.floor(Math.random()*10001);
	document.write( '<a href="javascript:;" onClick="MM_openBrWindow(\'' + directory + 'photos/viewphoto.html?Dir=' + folder + '&amp;PhotoID=' + file + '\',\'gemstuffphoto' + randomnumber + '\',\'scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,width=' + windwidth + ',height=' + windheight + '\')" title="Click to see photo">' + text + '</a>' );
}

/* ----------------------------PHOTOS---------------------------- */

function viewphoto(directory, file, width, height){
	if(navigator.userAgent.indexOf("Opera")!=-1) {
		var versionindex=navigator.userAgent.indexOf("Opera")+6
		if (parseInt(navigator.userAgent.charAt(versionindex))>=8) {
			var windwidth = width + 16;
			var windheight = height + 25;
		} else {
			var windwidth = width + 16;
			var windheight = height + 16;
		}
	} else {
		var windwidth = width + 16;
		var windheight = height + 16;
	}
	var randomnumber = Math.floor(Math.random()*10001);
	document.write('<a href="javascript:;" onClick="MM_openBrWindow(\'viewphoto.html?Dir=' + directory + '&amp;PhotoID=' + file + '\',\'gemstuffphoto' + randomnumber + '\',\'scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,width=' + windwidth + ',height=' + windheight + '\')" title="Click to see full photo"><img src="' + directory + '/thumbs/' + file + '" alt="Click to see full photo" width="73" height="73" class="photo_thumb" /></a>');
}

/* ----------------------------GEMCAST---------------------------- */

function gemcastcontact(){
	document.write('<br />If you have any complaints regarding the show, or an issue you\'d like us to discuss, drop us an e-mail at ');
	document.write('<a href="mailto:gemcast@gemstuff.co.uk" title="E-mail us about Gemcast">gemcast@gemstuff.co.uk</a>.<br /><br />');
}

/* ----------------------------JAVASCRIPT---------------------------- */

function javamessage(){
	document.write('You currently <strong>do</strong> have JavaScript enabled.<br /><br />This means you can view Gemstuff as it is intended, with features such as photos being easier to use with JavaScript enabled.');
}
