// JavaScript Document
/*
Created by Aftab Bharmal

[rain ] [aftab] [19/03/2009]

for showing lightboxes. slides of light box.. and ..handling the clicks events.. ;) 

*/
			
   
	//googlemap api key ..  for ringinghost.com
	//ABQIAAAAcRr8xB4JATs0f0XyapjSfRR6tFKaqMSx1fql9fkwHE3sixcKdRRC0YIKb1LMUrbwI73Fdfi4KOG5-g
	
	 
/*if (/msie/i.test (navigator.userAgent)) //only override IE
{
	document.nativeGetElementById = document.getElementById;
	document.getElementById = function(id)
	{
		var elem = document.nativeGetElementById(id);
		if(elem)
		{
			//make sure that it is a valid match on id
			if(elem.attributes['id'].value == id)
			{
				return elem;
			}
			else
			{
				//otherwise find the correct element
				for(var i=1;i<document.all[id].length;i++)
				{
					if(document.all[id][i].attributes['id'].value == id)
					{
						return document.all[id][i];
					}
				}
			}
		}
		return null;
	};
}*/


	
	 function getAbsolutePosition(element) {
    var r = { x: element.offsetLeft, y: element.offsetTop };
    if (element.offsetParent) {
      var tmp = getAbsolutePosition(element.offsetParent);
      r.x += tmp.x;
      r.y += tmp.y;
    }
	 
	
    return r;
  };
 
	
 function getpos(ele)
  {
  	
   
  }
function showmap(id,di)
{
  //google.load("maps", "2.x");
   
  // Call this function when the page has been loaded
  
  //google.setOnLoadCallback(initialize);
  initialize(id,di);
 }
  function initialize(id,di) {
  
    var map = new google.maps.Map2(document.getElementById("map"));
	var latlong = document.getElementById('latlong'+id).innerHTML;
	var html = document.getElementById('latlongadd'+id).innerHTML;
	//alert(latlong);
	latlon  = latlong.split(",");
	if(di =='yes')
	{
		html = html +	'<div><form class="mapdirform" onsubmit="DirectionMarkersubmit46_g4eiu_0(this);return false;" target="_blank" method="get" action="http://maps.google.com/maps" id="directionform46_g4eiu_0"><br/>Directions:<input type="radio" value="to" name="dir" checked=""/> <b>To here</b> <input type="radio" value="from" name="dir"/><b>From here</b><br/>Address:<input type="text" value="" id="saddr" name="saddr" size="20" class="inputbox"/><br/><input type="submit" style="margin-top: 2px;" class="button" value="Get Directions"/><input type="hidden" value="en" name="hl"/><input type="hidden" value="Arcadia Circle 723, 35810 Huntsville, AL (, )" name="daddr"/></form></div>';
		
		}
	
	  // var marker = new GMarker(new GLatLng(37.4228, -122.085));
	 var marker = new GMarker(new GLatLng(latlon[0], latlon[1]));
      //var html = '<div style="width:210px; padding-right:10px;">'+
          
			
	 map.setCenter(new GLatLng(latlon[0], latlon[1]), 16);
     map.addControl(new GSmallMapControl());
     map.addOverlay(marker);
     marker.openInfoWindowHtml(html);
    map.setCenter(new google.maps.LatLng(latlon[0], latlon[1]),16);
  }
  
    function searchnearby(id)
	   {
				   var postcode = document.getElementById('postcode'+id).innerHTML;
					postcode = trim(postcode);				   
				   document.getElementById('zip').value = postcode
				   document.getElementById('miles').value = '5';
				   document.getElementById('srch_zip').click(); ;
				   frim_clicked('zip'); 
				   //document.sobiSearchFormContainer.submit();
		  }
				   
				   function trim(s)
						{
							return rtrim(ltrim(s));
						}
						
						function ltrim(s)
						{
							var l=0;
							while(l < s.length && s[l] == ' ')
							{	l++; }
							return s.substring(l, s.length);
						}
						
						function rtrim(s)
						{
							var r=s.length -1;
							while(r > 0 && s[r] == ' ')
							{	r-=1;	}
							return s.substring(0, r+1);
						}

				   
						 function hidebox(){
											 document.getElementById('light').style.display = 'none';
											// document.getElementById('light1').style.display = 'none';
											// document.getElementById('light2').style.display = 'none';
											// document.getElementById('light3').style.display = 'none';
										//	document.getElementById('light4').style.display = 'none';
											 document.body.removeChild(document.getElementById('layer'));
										  }
					
			function getserver()
			{
				return 'http://ringinghost.com/707eats/';
				}
function getlink(id)
{
	
	var server = getserver();
	var  linkref = server + trim(document.getElementById('href'+id).innerHTML);
	linkref = linkref.replace("&amp;","&");
	linkref = linkref.replace("&amp;","&");
	linkref = linkref.replace("&amp;","&");
	linkref = linkref.replace("&amp;","&");
	linkref = linkref.replace("&amp;","&");
	
	return linkref;
	}
function showBox(ele,id)
   {
  	var di = 'nodirection';
	
   	showBox(ele,id,di)
   }
   
   
   function showBox(ele,id,di)
   {
					  
  var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
 r = getAbsolutePosition(ele)
 
  Ymouse = r.y;
  Ymouse  = Ymouse -120;
  
  
  var layer = document.createElement('div');
  layer.style.zIndex = 2;
  layer.id = 'layer';
  layer.style.position = 'absolute';
  layer.style.top = '0px';
  layer.style.left = '0px';
  layer.style.height = document.documentElement.scrollHeight + 'px';
  layer.style.width = width + 'px';
  layer.style.backgroundColor = 'black';
  layer.style.opacity = '.6';
  layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
  document.body.appendChild(layer);

 // var div = document.createElement('div');
  var div = document.getElementById('light');
  if(di =='save')
  {
  div = document.getElementById('light');
  
    var testFrame = document.getElementById("lightframe");
        var doc = testFrame.contentDocument;
		var server =   getserver();
		
		//var data = document.getElementById('name'+id).innerHTML
		//alert(ele.href);
		 testFrame.src = ele.href;
		//linkref = server + 'index2.php?option=com_mylinks&task=save&Itemid=&data=' + data;
//		http://localhost/joomlatest/index2.php?option=com_mylinks&Itemid=
       // window.frames["sobifav"].src = linkref;
          //document.getElementById('sobifav').src=linkref;
 
	    //linkref = getlink(id);
		// window.frames["sobidetails"].src = 
		//
		   
        // msg.innerHTML = "Hello World from Frame Page 1";

   mn = 'light';
  }else if(di=='myfav')
  {
	  div = document.getElementById('light2');
	  //parent.sobifav.
	  
	   mn = 'light2';
  }else if(di=='sobidetails')
  {
  	 
	  div = document.getElementById('light3');
	
//	document.getElementById('sobidetails').src = linkref;
	linkref = getlink(id);
	//linkref = linkref.replace("","=");
	window.frames["sobidetails"].src = linkref;
	document.getElementById('sobidetails').src=linkref;
	 //lert(window.frames["sobidetails"].src);
	mn = 'light3' ;
	
  }else if(di=='Email')
  {
	 
	var server =   getserver();
		///joomlatest/index2.php?option=com_mailto&tmpl=component&link=ppp.php&from=punit
	  var data = document.getElementById('name'+id).innerHTML
	  linkref = server + 'index2.php?option=com_mailto&task=save&Itemid=&data=' + data;
	  div = document.getElementById('light4');
	  window.frames["sobiEmail"].src = linkref;
		document.getElementById('sobiEmail').src=linkref;
	  mn = 'light4' ;
	}
  
  //div.style.position = 'absolute';
  //alert(Ymouse + 'px');
  //div.style.top = Ymouse + 'px';
  //changed By Sunil Patel[for display light box div][5/05/2009]
  div.style.top = '20%';
  //alert(div.style.top);
  div.style.zIndex = 3;
  /*div.id = 'box';
  div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
  div.style.top = '150px';
  div.style.left = (width / 2) - (400 / 2) + 'px'; 
  //div.style.height = '250px';
  //div.style.width = '400px';
  div.style.backgroundColor = 'black';
  div.style.border = '1px solid blue';
  div.style.padding = '10px';*/
  //document.body.appendChild(div);

  /*var p = document.createElement('p');
  p.innerHTML = 'coming Soon Request a Quote form and Newsletter';
  div.appendChild(p);*/

 /* var a = document.createElement('a');
  a.innerHTML = 'Close window';
  a.href = 'javascript:void(0)';
  a.onclick = function()
  {
    document.body.removeChild(document.getElementById('layer'));
    document.body.removeChild(document.getElementById('box'));
  };
 
  div.appendChild(a);*/
  div.style.display = 'block';
  
  if(di =='yes' || di == 'nodirection')
  	{

		 mn = 'light';
  		showmap(id,di);
 	 }
  }
   
				
				function frim_clicked(val)
				{
					document.getElementById('search_type').value = val;
					
				
				}
				function div_showhide(str)
				{
					if(str=='hide')
					{
					document.getElementById('search_outer').style.display = 'none';
					document.getElementById('top_search').style.display = 'block';
					}else if(str=='show')
					{
					document.getElementById('search_outer').style.display = 'block';
					document.getElementById('top_search').style.display = 'none';
					}
					
					
				
				}
				
				// Sliding Menu Script

// copyright Stephen Chapman, 6th July 2005

// you may copy this code but please keep the copyright notice as well

var speed = 6;



var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;

if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else {

var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)

&& (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}

function xDOM(objectId, wS) {

if (stdDOM) return wS ? document.getElementById(objectId).style:

document.getElementById(objectId);

if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];

if (nsDOM) return document.layers[objectId];

}

function objWidth(objectID) {var obj = xDOM(objectID,0); if(obj.offsetWidth) return obj.offsetWidth; if (obj.clip) return obj.clip.width; return 0;}

function objHeight(objectID) {var obj = xDOM(objectID,0); if(obj.offsetHeight) return obj.offsetHeight; if (obj.clip) return obj.clip.height; return 0;}

function setObjVis(objectID,vis) {var objs = xDOM(objectID,1); objs.visibility = vis;}

function moveObjTo(objectID,x,y) {var objs = xDOM(objectID,1); 
//objs.left = x;
 objs.top = y;
 }

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}

function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset: document.documentElement.scrollLeft? document.documentElement.scrollLeft: document.body.scrollLeft? document.body.scrollLeft:0;}

function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0;}


var xxx = 0; 

var yyy = 0; 

var dist =0; 

var distX = 0;

var distY = 0; 

var stepx = 2; 

var stepy = 0; 

var mn = 'light';

function distance(s,e) {return Math.abs(s-e)}

function direction(s,e) {return s>e?-1:1}

function rate(a,b) {return a<b?a/b:1}

function start() {xxx = -225; yyy = 100; var eX = 0; var eY = 100; dist = distX = distance(xxx,eX); distY = distance(yyy,eY); stepx *= -direction(xxx,eX) * rate(distX,distY); stepy *= direction(yyy,eY) * rate(distY,distX); moveit();

setObjVis(mn,'visible');}

function moveit() {var x = (posLeft()+xxx) + 'px'; var y = (posTop()+yyy) + 'px'; moveObjTo(mn,x,y);}

function mover() {if (dist > 0) {xxx += stepx; yyy += stepy; dist -= Math.abs(stepx);} moveit(); setTimeout('mover()',speed);

}

function slide() {dist = distX; stepx = -stepx; moveit(); setTimeout('mover()',speed*2);return false;}

onload = start;

window.onscroll = moveit;

	 
 