if(document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

//function PlaySound(embedName)
//{
//	var sndObj = document.getElementById(embedName);
//	if (sndObj != undefined) {
//		sndObj.play();
//	}
//}

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com
///////////////////////////////////

var message="Please keep in mind that all work here (including graphics) is PROTECTED BY COPYRIGHT!";

function clickIE4(){
	if (event.srcElement.tagName == "IMG" && event.button==2){
		alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

/////////////////////////////////////////////////////////////////////
function cancelRightMouse() {
    if (event.srcElement.tagName == "IMG" && event.button == 2/*right button*/) {
			event.cancelBubble = true;
      event.returnValue = true;
			alert("The content is copyrighted. You can not save it.");
			return false;
    }
    return true;
}
function checkCancel()
{
    if (event.shiftKey)
        event.cancelBubble = true;
}
function showSrc()
{
    if (event.srcElement.tagName == "IMG")
        alert(event.srcElement.src);
}

//////////////////////////////////////////////////////////////////////
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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

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_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];}
}

browserOk = (
		((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 ))
		||
		((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
		||
		((navigator.appName == "Opera") && (parseInt(navigator.appVersion) >= 7 ))
);
		
//alert(navigator.appName);

imgon=new Array();
imgoff=new Array();

imgNames = new Array("nav_top_home","nav_top_outoftown","nav_top_started","nav_top_contact","nav_left_mission","nav_left_aboutus", "nav_left_success", "nav_left_vision", "nav_left_testveh", "nav_left_links", "nav_left_hightech");

for(i = 0; i < imgNames.length; i++){
	var imgname = imgNames[i];
	imgon[imgname] = new Image();
	imgon[imgname].src = "images/"+imgname+"_on.gif";
	imgoff[imgname] = new Image();
	imgoff[imgname].src = "images/"+imgname+"_off.gif";
}

imageRef="document.images";

function msover(which) {
	if (browserOk) {
		//eval(imageRef + '["' + which + '"].src = imgon["' + which + '"].src');
		var imgOnSrc = eval('imgon["' + which + '"].src');
		imgOnSrc = imgOnSrc.replace("%5C", "/");	// bug fix: replace "%5C" in URL to "/"
		eval(imageRef + '["' + which + '"].src = "' + imgOnSrc + '"');
		//alert(document.images[which].src);
	}
}

function msout(which) {
	if (browserOk) {
		//eval(imageRef + '["' + which + '"].src = imgoff["' + which + '"].src');
		var imgOffSrc = eval('imgoff["' + which + '"].src');
		imgOffSrc = imgOffSrc.replace("%5C", "/");	// bug fix: replace "%5C" in URL to "/"
		eval(imageRef + '["' + which + '"].src = "' + imgOffSrc + '"');
		//alert(document.images[which].src);
	}
}

function SetPage(loc, topOrBot)
{
	 var str = loc.toString();
  //alert(str);
  var items = str.split('?');
  if (items.length < 2) return;
  //alert("params = " + items[1]);
  var nameValue = items[1];
  var name, value;
  if (nameValue.indexOf('=')==-1) return;
  name = nameValue.substring(0, nameValue.indexOf('='));
  value = nameValue.substring(nameValue.indexOf('=')+1);
  //alert("name="+name+" value="+value);
  if (name == "page")
  {
   if (topOrBot == "top")
   {
//alert("TOP");
    var el_top = document.getElementById("nav_top_"+value);
    if (el_top)
    {
     el_top.src = "images/nav_top_" + value + "_on.gif";
     el_top = document.getElementById("a_nav_top_"+value);
     el_top.onmouseover = "";
     el_top.onmouseout = "";
    }
   }
   else if (topOrBot == "left")
   {
//alert("LEFT");
    var el_left = document.getElementById("nav_left_"+value);
    if (el_left)
    {
     el_left.src = "images/nav_left_" + value + "_on.gif";
     el_left = document.getElementById("a_nav_left_"+value);
     el_left.onmouseover = "";
     el_left.onmouseout = "";
    }
   }
   else
   {
//alert("BOT");
    var el_bot = document.getElementById("nav_bot_"+value);
    if (el_bot)
    {
     el_bot.src = "images/nav_bot_" + value + "_on.gif";
     el_bot = document.getElementById("a_nav_bot_"+value);
     el_bot.onmouseover = "";
     el_bot.onmouseout = "";
    }
   }
  }
  
//  while (str!='') {
//	   var name, value;
//	  // strip off leading ? or &
//	  if ((str.charAt(0)=='?')||(str.charAt(0)=='&')) str = str.substring(1,loc.length-1);
//	  // find name
//	  name = str.substring(0,str.indexOf('='));
//	  alert("name = " + name);
//	  // find value
//	  if (str.indexOf('&')!=-1) value = str.substring(str.indexOf('=')+1,str.indexOf('&'));
//	  else value = str.substring(str.indexOf('=')+1,str.length);
//	  // add pair to an associative array
//	  //searchArray[name] = value;
//	  // cut first pair from string
//	  if (str.indexOf('&')!=-1) str =  str.substring(str.indexOf('&')+1,str.length);
//	  else str = '';
//	  alert("value = " + value);
//	  // debug step
//	  //document.write(name + ': ' + value + ': ' + searchStr + '<br>');
//  }
}
		
function send_email()
{
	var to = "vbaidoon@eegsoft.com";
	var subj = "customer request";
	var from = document.getElementById("e-mail").value;
	if (from != null && from != "" && from != "undefined")
	{
		var msg = "company_name=" + document.getElementById("company_name").value;
		msg += "\ncustomer_name=" + document.getElementById("your_name").value;
		msg += "\nphone=" + document.getElementById("phone").value;
		msg += "\ncomments=" + document.getElementById("comments").value;
		msg += "\nfrom=" + from;
		var myMail = Server.CreateObject("CDO.Message");
		//var myMail = new CDO.Message();
		myMail.Subject = subj;
		myMail.From = from;
		myMail.To = to;
		myMail.TextBody = msg;
		myMail.Send();
		from = "";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
  
//function onDownloadDone1(s) {
//	oText.value=s;
//}

//function msclick(link) {
//	if (browserOk) {
//		alert(link);
//		eval('<a href='+link+'></a>');
//	}
//}

/***********************************************
* Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
		
var tipwidth='150px' //default tooltip width
var tipbgcolor='lightyellow'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="0px" //horizontal offset of tooltip from anchor link
var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!="" && tipwidth != undefined){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidetip()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
dropmenuobj.innerHTML=menucontents

if (tipwidth=="" || tipwidth == undefined) {
	tipwidth = new String(menucontents.length * 6.8);
}
if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidetip(){
if (ie4||ns6)
delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function CurrentYear (year) {  
var exp = new Date();  
var newYear = exp.getYear();
if (!year) return newYear;
if (newYear == year) return year;
else return year.toString() + "-" + newYear.toString();
}
