﻿var bulletIndex=0;
var gtcomm;

function goTo(selectBoxID, newWindow) 
{
	var sE = null, url;
	if(document.getElementById) 
	{
		sE = document.getElementById(selectBoxID);
	} 
	else if(document.all) 
	{
		sE = document.all[selectBoxID];
	}
	if(sE && (url = sE.options[sE.selectedIndex].value)) 
	{
		if(newWindow==true)
			window.open(url,'_blank');
		else
		{
			try
			{
				document.location.href=url;
				/*window.open(url);*/
			}
			catch(err) {}
		}
	}
}
// Create a cookie with the specified name and value.
function SetCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue);
  // Expires the cookie in one month
  var date = new Date();
  date.setMonth(date.getMonth()+1);
  document.cookie += ("; expires=" + date.toUTCString()); 
}

function setBackgroundImage()
{
	var randomnumber=Math.floor(Math.random()*7);
	var contentPanel = document.getElementById('content');
	var sPath = window.location.pathname;
	var pageName = sPath.substring(sPath.lastIndexOf('/') + 1);

	var pageExclusions='ourhistory.htm,register.htm,privateservices.htm,meettheteam.htm,catchmentarea.htm';
	var backImage = new Array();
	var image;
	
	if(pageExclusions.indexOf(pageName) == -1)
	{
		backImage[0] = "bgContent1.png";
		backImage[1] = "bgContent2.png";
		backImage[2] = "bgContent3.png";
		backImage[3] = "bgContent4.png";
		backImage[4] = "bgContent5.png";
		backImage[5] = "bgContent6.png";
		backImage[6] = "bgContent7.png";

		image='images/' + backImage[randomnumber];
		content.background=image;
	}
}
function breakout_of_frame()
{
  // see http://www.thesitewizard.com/archive/framebreak.shtml
  // for an explanation of this script and how to use it on your
  // own website
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}


function createCollapse(divID, linkTitle)
{
  	document.writeln('<br /><a href=\"javascript:unhide(\'' + divID + '\');\"> <img id= \"' + divID + '_arrow\" src="images/arrow_right.gif" /> ' +  linkTitle + ' </a>');
	document.writeln('<span id=\"' + divID +'\" name= \"' + divID +'\" class=\"hidden\">');

}
function unhide(divID) {
  var item = document.getElementById(divID);
  if (item) {
    item.className=(item.className=='hidden')?'unhidden':'hidden'; 
  
    if(item.className=='hidden')
    	document.images[divID + '_arrow'].src="images/arrow_right.gif";
    else	 
	    document.images[divID + '_arrow'].src="images/arrow_down.gif";
      }
}

function createDownloadsCombo()
{
	var combo = document.getElementById('ourdownloads');
	var image='images/ourdownloads.png';
	

	document.writeln('<b>Our Downloads</b><br/>');

	document.writeln('<select id="downloadsList" size="1" class="downloadsCombo">');
	document.writeln('<option value="">Downloads ? ...</option>');
	document.writeln('<option value="download/pricelist.pdf">Price List</option>');
	document.writeln('<option value="download/practicebooklet.pdf">Practice Booklet</option>');
	document.writeln('<option value="download/complaint.pdf">Complaint Form</option>');
	document.writeln('<option value="download/patientquestionnaire.pdf">New Patient Questionnaire</option>');
	document.writeln('<option value="download/newsletter.pdf">Practice Newsletter</option>');
	document.writeln('<option value="download/travelquestionnaire.pdf">Travel Risk Assessment Form</option>');
	document.writeln('<option value="download/gms1.pdf">Registration Form</option>');	
	document.writeln('<option value="download/swineflu.pdf">Swine Flu Information Sheet</option>');	
	document.writeln('</select>');
	document.writeln('<input type="button" value="Go!" onclick="goTo(' + "'downloadsList',true" + ');" class="goBtn">');

	combo.style.backgroundImage = "url('"+image+"')"; 
}

function extractURL(url)
{
	var startIdx=url.indexOf('u=',1);
	var extractedUrl='';

	if(startIdx!=-1)
	{
		startIdx+=2;
		 extractedUrl=url.substring(startIdx,url.indexOf('&',startIdx));
		 }
	else
	{
		extractedUrl=url;
	}		 
	return extractedUrl;
}


function createSearchBox()
{
	document.writeln('<input name="Text1" type="text" style="width: 115px" />');
	document.writeln('<input type="button" value="Search!" class="goBtn" >');
//	document.writeln('<input type="button" value="Go!" onclick="goTo(' + "'downloadsList'" + ');" class="goBtn">');
}




 dropDown = function() 
 {  
	 var menuItems = document.getElementById("navBar").getElementsByTagName("li");  
	 for (var i=0; i<menuItems.length; i++) 
	 {  
	 	menuItems[i].onmouseover=function() {  
	 										this.className=" dropDown";  
	 									}  
	 	menuItems[i].onmouseout=function() {  
	 										this.className=this.className.replace(new RegExp(" dropDown\\b"), "");  
	 									}  
	 }  
 }  
 if (window.attachEvent) window.attachEvent("onload", dropDown); 



