//Swap and Restore Code

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// -------------------------------------------------------------------------------------------------  //

//On Mouse over Write to Layer

function writeToLayer(id, sHTML) {
  var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
  if (!el) return;
  var cntnt =  sHTML ;
  if (typeof el.innerHTML!="undefined") {
    el.innerHTML = cntnt;
  } else if (document.layers) {
	el.document.write(cntnt);
	el.document.close();
  }
}

function writeToLayerLoading(id) {
  var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
  if (!el) return;
	var cntnt = "<img src=\"http://www.ratemypub.ie/images/loading.gif\" alt=\"Pubs Loading From Database\" border=\"0\"><b>&nbsp;&nbsp;Pubs Loading</b>"  ;
  if (typeof el.innerHTML!="undefined") {
    el.innerHTML = cntnt;
  } else if (document.layers) {
	el.document.write(cntnt);
	el.document.close();
  }
}
// -------------------------------------------------------------------------------------------------  //

//Ajax Code here

// Ajax Show Pub List  //

var xmlHttpPubList;

function showPubList(query)
{ 
xmlHttpPubList=GetXmlHttpObject()
if (xmlHttpPubList==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var PubListUrl="http://www.ratemypub.ie/ajax.php?publist=1"
PubListUrl=PubListUrl+"&query="+query
PubListUrl=PubListUrl+"&sid="+Math.random()
xmlHttpPubList.onreadystatechange=stateChangedPubList
xmlHttpPubList.open("GET",PubListUrl,true)
xmlHttpPubList.send(null)
}
 
function stateChangedPubList() 
{ 
if (xmlHttpPubList.readyState==4 || xmlHttpPubList.readyState=="complete")
 { 
 document.getElementById("txtPubList").innerHTML=xmlHttpPubList.responseText;
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax Show Calendar  //

var xmlHttpCalendar;

function showCalendar(countyid,pubid,month,year)
{ 
xmlHttpCalendar=GetXmlHttpObject()
if (xmlHttpCalendar==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var CalendarUrl="http://www.ratemypub.ie/ajax.php?calendar=1"
CalendarUrl=CalendarUrl+"&countyid="+countyid
CalendarUrl=CalendarUrl+"&pubid="+pubid
CalendarUrl=CalendarUrl+"&month="+month
CalendarUrl=CalendarUrl+"&year="+year
CalendarUrl=CalendarUrl+"&sid="+Math.random()
xmlHttpCalendar.onreadystatechange=stateChangedCalendar
xmlHttpCalendar.open("GET",CalendarUrl,true)
xmlHttpCalendar.send(null)
}

function stateChangedCalendar() 
{ 
if (xmlHttpCalendar.readyState==4 || xmlHttpCalendar.readyState=="complete")
 { 
 document.getElementById("txtCalendar").innerHTML=xmlHttpCalendar.responseText;
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax Show Pub Location  //

var xmlHttpshowPubLoc;

function showPubLoc(query)
{ 
xmlHttpshowPubLoc=GetXmlHttpObject()
if (xmlHttpshowPubLoc==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var showPubLocUrl="http://www.ratemypub.ie/ajax.php?showpubloc=1"
showPubLocUrl=showPubLocUrl+"&query="+query
showPubLocUrl=showPubLocUrl+"&sid="+Math.random()
xmlHttpshowPubLoc.onreadystatechange=stateChangedshowPubLoc
xmlHttpshowPubLoc.open("GET",showPubLocUrl,true)
xmlHttpshowPubLoc.send(null)
}

function stateChangedshowPubLoc() 
{ 
if (xmlHttpshowPubLoc.readyState==4 || xmlHttpshowPubLoc.readyState=="complete")
 { 
 eval( xmlHttpshowPubLoc.responseText  )
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax Show Pub Name  //

var xmlHttpshowPubName;

function showPubName(query)
{ 
xmlHttpshowPubName=GetXmlHttpObject()
if (xmlHttpshowPubName==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var showPubNameUrl="http://www.ratemypub.ie/ajax.php?showpubname=1"
showPubNameUrl=showPubNameUrl+"&query="+query
showPubNameUrl=showPubNameUrl+"&sid="+Math.random()
xmlHttpshowPubName.onreadystatechange=stateChangedshowPubName
xmlHttpshowPubName.open("GET",showPubNameUrl,true)
xmlHttpshowPubName.send(null)
}

function stateChangedshowPubName() 
{ 
if (xmlHttpshowPubName.readyState==4 || xmlHttpshowPubName.readyState=="complete")
 { 
 document.getElementById("txtPubName").innerHTML=xmlHttpshowPubName.responseText;
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax Show Date  //

var xmlHttpshowDate;

function showDate(countyid,date)
{ 
xmlHttpshowDate=GetXmlHttpObject()
if (xmlHttpshowDate==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var showDateUrl="http://www.ratemypub.ie/ajax.php?showdate=1"
showDateUrl=showDateUrl+"&countyid="+countyid
showDateUrl=showDateUrl+"&date="+date
showDateUrl=showDateUrl+"&sid="+Math.random()
xmlHttpshowDate.onreadystatechange=stateChangedshowDate
xmlHttpshowDate.open("GET",showDateUrl,true)
xmlHttpshowDate.send(null)
}

function stateChangedshowDate() 
{ 
if (xmlHttpshowDate.readyState==4 || xmlHttpshowDate.readyState=="complete")
 { 
 document.getElementById("txtDate").innerHTML=xmlHttpshowDate.responseText;
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax Rate Crawl //

var xmlHttpaddCrawlRate;

function addCrawlRate(crawlid,rating)
{ 
xmlHttpaddCrawlRate=GetXmlHttpObject()
if (xmlHttpaddCrawlRate==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var addCrawlRateUrl="http://www.ratemypub.ie/ajax.php?addcrawlrate=1"
addCrawlRateUrl=addCrawlRateUrl+"&crawlid="+crawlid
addCrawlRateUrl=addCrawlRateUrl+"&rating="+rating
addCrawlRateUrl=addCrawlRateUrl+"&sid="+Math.random()
xmlHttpaddCrawlRate.onreadystatechange=stateChangedaddCrawlRate
xmlHttpaddCrawlRate.open("GET",addCrawlRateUrl,true)
xmlHttpaddCrawlRate.send(null)
}

function stateChangedaddCrawlRate() 
{ 
if (xmlHttpaddCrawlRate.readyState==4 || xmlHttpaddCrawlRate.readyState=="complete")
 { 
 document.getElementById("txtCrawlRate").innerHTML=xmlHttpaddCrawlRate.responseText;
 } 
}

// -------------------------------------------------------------------------------------------------  //

// Ajax //

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

// -------------------------------------------------------------------------------------------------  //


//JQuery Code




$(document).ready(function(){
        $("a.toggle").click(function(){
                var $this = $(this);
                if( $this.is('.txtDate') ) {
                        $this.next().slideUp("slow");
                        $this.removeClass('txtDate');
                }
                else {
                        $this.next().slideDown("slow");
                        $this.addClass('txtDate');
                }
                return false;
        });
		
		$("a.toggleday").click(function(){
                var $this = $(this);
                if( $this.is('.txtDate') ) {
                        $this.next().slideUp("slow");
                        $this.removeClass('txtDate');
                }
                else {
                        $this.next().slideDown("slow");
                        $this.addClass('txtDate');
                }
                return false;
        });
});


// -------------------------------------------------------------------------------------------------  //

//Show Div

function showDiv(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.visibility="visible"; 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'visible'; 
else // IE 4 
document.all.hideshow.divs[i].visibility = 'visible'; 
} 
} 
} 

//-->


// -------------------------------------------------------------------------------------------------  //