		var timerID = 0;
		var tStart  = null;

		function Reset() {
		   tStart = null;

		   document.getElementById('q').focus();

		   tStart   = new Date();
		}

		function setDefaultCountry() {
		   var country = readCookie('country');
		   var selected = false;
		   for (i=0; i < document.getElementById('country').length; i++)
		   {
		   	if (document.getElementById('country').options[i].value == country)
		   	{
		      	   document.getElementById('country').selectedIndex = i;
		      	   selected = true;
		   	}
		   }
		   if (!selected) document.getElementById('country').selectedIndex = 0;
		};


		function SetRangeToCountry() {
		   document.getElementById('range').checked = true;
		}
		

		function SetCountry() {
		   var countryCode = "";
		   if (document.getElementById('range').checked)
		   {
		      countryCode = document.getElementById('country').options[document.getElementById('country').selectedIndex].value;
		      createCookie('country',countryCode,300);
		   }

		   document.getElementById('meta').value = "cr=" + countryCode;
		}

		function createCookie(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}

		function readCookie(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}

        function SetColours(bgColour, mainColour, linkColour) {
            if (changingPage) return;
            window.document.bgColor = bgColour;
            
            if (bgColour == '#FFFFFF')
            {
            	document.getElementById('swapperNote').innerHTML = "<font size=\"0\" color=\"" + mainColour + "\">Black? </font>";
            	document.getElementById('imgName').src = "swapper_black.gif";
		        createCookie('bgColour','#FFFFFF',300);
            }
            else
            {
            	document.getElementById('swapperNote').innerHTML = "<font size=\"0\" color=\"" + mainColour + "\">Vanilla? </font>";
            	document.getElementById('imgName').src = "swapper_white.gif";
		        createCookie('bgColour','#000000',300);
            }
        	if (bgColour == '#FFFFFF') document.getElementById('logo').src = "givlevanilla.gif";
        	else document.getElementById('logo').src = "givlelogo.gif";
        	document.getElementById('mainlinks_text').style.color = mainColour;
        	document.getElementById('footer_text').style.color = mainColour;
        	document.getElementById('searchrange_text').style.color = mainColour;
        	document.getElementById('foot').style.color = mainColour;
        	document.getElementById('country').style.backgroundColor  = bgColour;
        	document.getElementById('country').style.color = linkColour;

			for(var i=1;i < 9;i++) {
        	   document.getElementById('link_' + i).style.color = linkColour;
			}
        	window.document.linkColor = linkColour;
        	window.document.vlinkColor = linkColour;


            SetSearchStyle();
        }
        
        function swapTest() {
            if (document.body.className == 'blacktheme') document.body.className = 'whitetheme';
            else document.body.className = 'blacktheme';
        }

        function SwapBW() {
            document.body.className = 'whitetheme';
        
        
        
            if (window.document.bgColor == "#000000") SetColours('#FFFFFF','#000000', '#0000FF');
            else SetColours('#000000','#FFFFFF', '#33CCFF');
        }

        var changingPage = false;

        function GoToWhite() {
           changingPage = true;
		   createCookie('bgColour','#FFFFFF',300);
           window.location = "http://white.givle.com/";
        }

        function GoToBlack() {
           changingPage = true;
		   createCookie('bgColour','#000000',300);
           window.location = "http://www.givle.com/test/";
        }
        
	function CheckForImagesSearch(form)
	{
		if (document.getElementById('images').checked)
		{
		   var query = document.getElementById('q').value;
		   window.location = "http://images.google.com/images?q=" + query ;
		   return false;
		}
		return true;
	}

        function SetSearchStyle() {
            if (window.document.bgColor == '#FFFFFF' | window.document.bgColor == '#ffffff')
            {
                document.forms[0].action = "http://www.google.com/custom";
//		        document.getElementById('searchbox_003000986505175330489:pu1ifawhi-e').action = "http://www.google.com/custom");
		        document.getElementById('cof').value = "AH:left;ALC:#FFFFFF;BGC:#FFFFFF;CX:Givle;DIV:#002200;FORID:1;GALT:#009900;GFNT:#000000;GIMP:#FF0000;L:http://www.givle.com/givlevanilla.gif;LC:#0000AA;LH:100;LP:1;S:http://www.givle.com;BT:#000000;VLC:#0000FF;";
            }
            else
            {
                document.forms[0].action = "http://www.google.com/cse";
//		        document.getElementById('searchbox_003000986505175330489:pu1ifawhi-e').action = "http://www.google.com/cse");
		        document.getElementById('cof').value = "FORID:1";
            }
        }