﻿function showImage(image){document.getElementById('videoFiles').style.display='none';document.getElementById('imageFiles').style.display='block';document.getElementById('thePhoto').src="web_assets/"+image+"";document.getElementById('tip').innerHTML=document.getElementById('web_assets/'+image+'').title;document.getElementById('web_assets/'+image+'').className="active";}

function toggleSearch(searchID) {
	var search	= document.getElementById(searchID).value;
	if(search=='Search Site') {
		document.getElementById(searchID).value='';
		document.getElementById(searchID).style.color='#333333';
		} else {
		document.getElementById(searchID).style.color='silver';		
		}
	if(search=='') {
		document.getElementById(searchID).value='Search Site';
		document.getElementById(searchID).style.color='silver';
		}

}
function doSearch(searchID) {
	var searchString	= document.getElementById(searchID).value.replace(/[&|#|*|.]/ig,"");
	if (searchString.length == 0 || searchString=='Search Site') {
		alert('Please enter a search term!')} else {
		document.location.href='search-results.asp?search='+searchString;}
}

/*
Author: Robert Hashemian
http://www.hashemian.com/

You can use this code in any manner so long as the author's
name, Web address and this disclaimer is kept intact.
********************************************************
Usage Sample:

<script language="JavaScript">
TargetDate = "12/31/2020 5:00 AM";
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "It is finally here!";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>
*/
function bookmark(url,title){  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) { window.external.AddFavorite(url,title);} else if (navigator.appName == "Netscape") {window.sidebar.addPanel(title,url,"");  } else {alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");  }} 

function getQuote() {
	var vehicle	= document.getElementById('selQuote').value;
	document.location.href='get-a-limo-quote.asp?vehicle='+vehicle;
	}

function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountBack(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
  }
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
 document.write("<span id='cntdwn' " +  
                "></span>");
}

if (typeof(BackColor)=="undefined")
  BackColor = "white";
if (typeof(ForeColor)=="undefined")
  ForeColor= "black";
if (typeof(TargetDate)=="undefined")
  TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
  CountActive = true;
if (typeof(FinishMessage)=="undefined")
  FinishMessage = "";
if (typeof(CountStepper)!="number")
  CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
  LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
  CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
//putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
//CountBack(gsecs);

function bubble(id,x,y){
 $(id+'-bubble').setStyle({left:x+'px',top:y+'px'});
        new Effect.Scale(id+'-bubble',100, Object.extend({
          beforeStart:function(effect){
            $(effect.element).style.display = 'block';
            $(effect.element).setOpacity(0);
            $$('#'+id+'-bubble p').each(function(p){p.hide()});
          },
          afterUpdate:function(effect){
            $(effect.element).setOpacity(effect.position);
          },
          scaleFrom:0,
          scaleFromCenter:true,
          afterFinish:function(effect){
            $$('#'+id+'-bubble p').each(function(p){
              new Effect.Appear(p,{duration:0.4});
            });
          }
        }, arguments[3] || {}));        
      }
      
function openMenu(menu) {var submenu = menu+"Content";document.getElementById(submenu).style.display='block';}
function hideMenu(menu) {var submenu = menu+"Content";document.getElementById(submenu).style.display='none';}


function showVideo(videoID) {
document.getElementById('videoFiles').style.display='block';document.getElementById('imageFiles').style.display='none';document.getElementById('videoFiles').innerHTML="Loading...";var xmlhttp=false;if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){try{xmlhttp=new XMLHttpRequest();}catch(e){xmlhttp=false;}}
if(!xmlhttp&&window.createRequest){try{xmlhttp=window.createRequest();}catch(e){xmlhttp=false;}}
xmlhttp.open("GET","admin/open_media.asp?fileid="+videoID,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if (xmlhttp.responseText != "") {document.getElementById('videoFiles').innerHTML=""+xmlhttp.responseText;} else {document.getElementById('videoFiles').innerHTML="Error";}}};xmlhttp.send(null);} 
//* format phone number //
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.loginForm.homenumber.value="";	document.loginForm.homenumber.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
	document.loginForm.homenumber.value="";	document.loginForm.homenumber.value=pp;	}	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.loginForm.homenumber.value="";
	pp="("+p13+")"+p14+p15;
	document.loginForm.homenumber.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.loginForm.homenumber.value="";
	document.loginForm.homenumber.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
//* fade script *//
var TimeToFade = 300.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() 
        + ",'" + eid + "')", 33);
  }  
}
function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 
      'alpha(opacity = ' + (newOpVal*100) + ')';
  
  setTimeout("animateFade(" + curTick 
      + ",'" + eid + "')", 33);
}

//*end fade script //