﻿//Preload Images
var browser = new Browser;

var tempX = 0;
var tempY = 0;

var newWidth;
var newHeight;
var changeSizeID;

var PinID = 0;

var dragObj = new Object();
dragObj.zIndex = 0;

function ShowDivBack()
{
   var wp = document.getElementById("divWholePage");
   wp.style.display = "block";
   wp.style.width = (screen.availWidth - 20) + "px";
   wp.style.height = (screen.availHeight) + "px";
   wp.style.top = 0;
   wp.style.left = 0;
}

function HideDivBack()
{
    var wp = document.getElementById("divWholePage");
    wp.style.display = "none";   
}


function LoadStats()
{
   var tzo = readCookie("GTGTimeZoneOffset");
   if(tzo == null)
   {
        createCookie("GTGTimeZoneOffset", checkTimeZone(),300);
   } 
   document.getElementById("divTimeZone").innerHTML = "GMT Offset: " + checkTimeZone() + " hours";
}  

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function checkTimeZone() 
{
   var rightNow = new Date();
   var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
   var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
   var temp = date1.toGMTString();
   var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   var temp = date2.toGMTString();
   var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
   var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
   var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
   return hoursDiffStdTime;   
}

function ViewDayStats(shortDate,longDate)
{
   document.getElementById("txtDaySelect").value = shortDate;
   document.getElementById("form1").submit();
}

function OpenLinkNewWindow(link)
{
    window.open(link,"newLinkWin","toolbars=no,address=no,resizable=1,scrollbars=1");
}

function WriteTestimonial()
{
    if(document.getElementById("divBlogTable").style.display == "block")
   {
        document.getElementById("divBlogTable").style.display = "none";
   }
   else
   {
        document.getElementById("divBlogTable").style.display = "block";
   } 
    
}

function ChangeSize(id, width, height)
{
   changeSizeID = id;
   newWidth = width;
   newHeight = height;
   
     
   workerChangeSize();
    
}

function ContactUs()
{
    var contact1 = document.getElementById("divContactUs");
    contact1.style.display = "block";
    contact1.style.left = "100px";
    contact1.style.top = "10px";    
    
}

function CancelEmail()
{
    var contact1 = document.getElementById("divContactUs");
    var success1 = document.getElementById("divSuccess"); 
    contact1.style.display = "none";
    success1.style.left = "100px";
    success1.style.top = "-1000px";  
    document.getElementById(txtEmailFrom).value = "";  
    document.getElementById(txtEmailSubject).value = ""; 
    document.getElementById(txtEmailBody).value = "";  
    document.getElementById(chkSendMeCopy).checked = false;
    //changeOpac(0, "divSuccess");
    success1.style.display = "none";
        
    
}



function ShowMap()
{
    window.open("usMap.aspx","usMap","toolbars=no,status=no,menubar=no,resizable=no,address=no,width=800,height=535");
}

function ViewPinInfo(event,city,state,caption)
{
    var html1 = "<table class='PinInfoTableStyle' border='0' cellpadding='2' cellspacing='0'><tr><td class='PinInfoTableCityRow'>" + city + ", " + state + "</td></tr>";
    html1 = html1 + "<tr><td class='PinLinkCaption'>" + caption + "</td></tr></table>";    
    BuildCalendarTable(event,0,0,html1,'PinInfoTable');
    
}

function ClosePinInfo()
{
    try{
    var t1 = document.getElementById("PinInfoTable");
    document.body.removeChild(t1);
    }catch(e){}
}

function GetMouseCoord()
{
   document.getElementById("txtMouseX").value = event.offsetX;
   document.getElementById("txtMouseY").value = event.offsetY; 
   var img1 = document.getElementById("divmap");
}

function SaveNewPin()
{
    
}

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;      
    
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
      
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
      
      document.getElementById("txtMouseX").value = x;
    document.getElementById("txtMouseY").value = y; 
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
   
   document.getElementById("txtMouseX").value = x;
    document.getElementById("txtMouseY").value = y;  
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) 
{
 // Clear the drag element global.

  dragObj.elNode = null;

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}


function HoverLink(field,state)
{
    var header1=document.getElementById(field);
    if(state=="on")
    {
        header1.className = "MenuHeaderHover";
    }
    if(state=="off")
    {
        header1.className = "MenuHeader";
    }
}


function workerChangeSize()
{
   var obj = document.getElementById(changeSizeID);
   var w0 = obj.style.width;
   var h0 = obj.style.height;
   //alert(w0 + "," + h0);
   window.status = w0;
   
   var w0a = w0.replace("px","");
   var h0a = h0.replace("px","");
   
   var wDir;
   var hDir;
   
   if(parseFloat(w0a) < parseFloat(newWidth.replace("px","")))
   {
        wDir = "plus";
   }
   if(parseFloat(w0a) > parseFloat(newWidth.replace("px","")))
   {
        wDir = "minus";
   }
   
   if(parseFloat(h0a) < parseFloat(newHeight.replace("px","")))
   {
        hDir = "plus";
   }
   if(parseFloat(h0a) > parseFloat(newHeight.replace("px","")))
   {
        hDir = "minus";
   }
   
   if(w0 != newWidth )
   {
        if(wDir == "plus")
        {
            obj.style.width = parseFloat(w0.replace("px","")) + 5 + "px";
        }
        if(wDir == "minus")
        {
            obj.style.width = parseFloat(w0.replace("px","")) - 5 + "px";
        }
        
        window.setTimeout("workerChangeSize()",0);
        
        return false;
   }
   
   if(h0 != newHeight )
   {
        if(hDir == "plus")
        {
            obj.style.height = parseFloat(h0.replace("px","")) + 5 + "px";
        }
        if(hDir == "minus")
        {
            obj.style.height = parseFloat(h0.replace("px","")) - 5 + "px";
        }
        window.setTimeout("workerChangeSize()",0);
        return false;
   }
   
   
}

function NavLocal(page)
{
     if (browser.isIE)
      {
            window.navigate(page);
      }
    if (browser.isNS)
      {
            window.location = page;
      }
}
   

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;
  
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

function ShowFullImage(imageID,imgDescTextbox,fixedDim)
{
   //get scrolling offset
   var x,y;
    if (self.pageYOffset) // all except Explorer
    {
	    x = self.pageXOffset;
	    y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
	    // Explorer 6 Strict
    {
	    x = document.documentElement.scrollLeft;
	    y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
	    x = document.body.scrollLeft;
	    y = document.body.scrollTop;
    }

   var tempX;
   var tempY; 
   var IE = document.all?true:false;
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    try{ 
    if (IE)
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else 
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }  
   }catch(e){} 
   
   htmlWindowOpen = true;
   var img1 = document.getElementById(imageID);
   //var div1 = document.getElementById(div1);
   var screenWidth = screen.availWidth;
   var screenHeight = screen.availHeight;
   
   var top1;
   var left1;
   
   if(fixedDim == "fixed")
   {
        top1 = screen.availHeight/2 - 480/2 - 100;
        left1 = screen.availWidth/2 - 640/2;
   }
   else
   {
        top1 = screen.availHeight/2 - getElementHeight(imageID)/2 - 100;
        left1 = screen.availWidth/2 - getElementWidth(imageID)/2;
   }
   
   var imgContainer1 = document.getElementById("imgContainer");
   var imgTable1 = document.getElementById("imgTable");
   try
   {
       var imgDesc = document.getElementById("imgDescription");
       imgDesc.innerText = document.getElementById(imgDescTextbox).value;
   }catch(e){}
   
   imgContainer1.src = img1.src;
   //imgContainer1.style.display = "block";
   //imgContainer1.style.position = "absolute";
   
   imgTable1.style.display = "block";
   imgTable1.style.position = "absolute";
   imgTable1.style.left = left1 + "px";
   imgTable1.style.top = (top1 + y) + "px";
   imgTable1.style.zIndex = 0;
   
   //alert(left1 + " , " + top1);
   
   //var desc1 = document.getElementById(desc);
   //document.getElementById("spanDescription").innerText = desc1.value;
}

function ShowFullImage2(imageID,imgDescTextbox,fixedDim)
{
   //get scrolling offset
   var x,y;
    if (self.pageYOffset) // all except Explorer
    {
	    x = self.pageXOffset;
	    y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
	    // Explorer 6 Strict
    {
	    x = document.documentElement.scrollLeft;
	    y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
	    x = document.body.scrollLeft;
	    y = document.body.scrollTop;
    }

   var tempX;
   var tempY; 
   var IE = document.all?true:false;
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    try{ 
    if (IE)
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else 
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }  
   }catch(e){} 
   
   htmlWindowOpen = true;
   var img1 = document.getElementById(imageID);
   //var div1 = document.getElementById(div1);
   var screenWidth = screen.availWidth;
   var screenHeight = screen.availHeight;
   
   var top1;
   var left1;
   
   if(fixedDim == "fixed")
   {
        top1 = screen.availHeight/2 - 480/2 - 100;
        left1 = screen.availWidth/2 - 640/2;
   }
   else
   {
        top1 = screen.availHeight/2 - getElementHeight(imageID)/2 - 100;
        left1 = screen.availWidth/2 - getElementWidth(imageID)/2;
   }
   
   var imgContainer1 = document.getElementById("imgContainer");
   var imgTable1 = document.getElementById("imgTable");
   try
   {
       var imgDesc = document.getElementById("imgDescription");
       imgDesc.innerHTML = document.getElementById(imgDescTextbox).value;
   }catch(e){}
   
   imgContainer1.src = img1.src;
   //imgContainer1.style.display = "block";
   //imgContainer1.style.position = "absolute";
   
   imgTable1.style.display = "block";
   imgTable1.style.position = "absolute";
   imgTable1.style.left = left1 + "px";
   imgTable1.style.top = (top1 + y) + "px";
   imgTable1.style.zIndex = 12;
   imgTable1.style.height = imgContainer1.offsetHeight + 60 + "px";
   
   // show IFRAME
   try{
        if(browser.isIE)
        {
        var iframe = document.getElementById('iframe');
        iframe.style.display = 'block';
        iframe.style.width = imgTable1.offsetWidth;
        iframe.style.height = imgTable1.offsetHeight;
        iframe.style.left = imgTable1.offsetLeft;
        iframe.style.top = imgTable1.offsetTop;
        }
       }catch(e){}
   
   //alert(left1 + " , " + top1);
   
   //var desc1 = document.getElementById(desc);
   //document.getElementById("spanDescription").innerText = desc1.value;
}

function RestoreImage()
{
    try{
   var imgTable1 = document.getElementById("imgTable"); 
   imgTable1.style.display = "none";
   }catch(e){}
   try
   {
   var imgContainer1 = document.getElementById("imgContainer");
   imgContainer1.src = "images/black.jpg";
   }catch(e){}
   
   try
      {
        var iframe = document.getElementById('iframe');
        iframe.style.display = 'none';
        }catch(e){}
   
   
   htmlWindowOpen = false;  
}



function BuildCalendarTable(event,adjustX,adjustY,html1,name1,origin)
{
    //if(htmlWindowOpen == true){return "";}
	if(document.getElementById(name1)){return "";}
	
	//htmlWindowOpen = true;
	
	var body1 = document.getElementsByTagName("body")[0];
	
	//tbl0 = document.createElement("table");
	//mytablebody0 = document.createElement("tbody");
	//rowa = document.createElement("tr");	
	//cella = document.createElement("td");	
	
	tbl1 = document.createElement("table");
	mytablebody = document.createElement("tbody");
	
	row0 = document.createElement("tr");	
	row1 = document.createElement("tr");
	row2 = document.createElement("tr");
	
	cell0 = document.createElement("td");
	cell1 = document.createElement("td");
	cell2 = document.createElement("td");
	
	cellspace0 = document.createTextNode("");
	cellspace = document.createTextNode("");
	currentText = document.createTextNode("");
	
	//cell0.appendChild(cellspace0);
	//cell0.innerHTML = "&nbsp;";
	cell1.appendChild(currentText);
	cell1.setAttribute("align","center");
	cell1.setAttribute("valign","top");
	//cell1.setAttribute("style","overflow:auto;");
	cell1.innerHTML = html1;
	//cell2.appendChild(cellspace);
	//cell2.innerHTML = "&nbsp;";
	//row0.appendChild(cell0);
	row1.appendChild(cell1);
	//row2.appendChild(cell2);
	
	//mytablebody.appendChild(row2);
	mytablebody.appendChild(row1);
	//mytablebody.appendChild(row0);
	
	
	tbl1.appendChild(mytablebody);
	tbl1.setAttribute("border","0");
	//tbl1.setAttribute("width","650px");
	//tbl1.setAttribute("height","350");
	
	//cella.appendChild(tbl1);
	//rowa.appendChild(cella);
	//mytablebody0.appendChild(rowa);
	//tbl1.appendChild(mytablebody0);
	//tbl1.setAttribute("border","1");
	tbl1.setAttribute("borderColor","#000000");
	//tbl0.setAttribute("bgColor","skyblue");
	//tbl0.setAttribute("background","images/processingBackground.jpg");
	tbl1.setAttribute("id",name1);
	//tbl0.setAttribute("onmouseover","Javascript:alert(1)");
	body1.appendChild(tbl1);
	//alert(tbl1.innerHTML);
	var left1 = "0";
	var top1 = "0";
	
	
	
	//document.getElementById(name1).style.position = "absolute";
	////document.getElementById("tblProcessing").style.left = (screen.availWidth/2) - 150 + parseFloat(left1);
	////document.getElementById("tblProcessing").style.top = (screen.availHeight/2) - 150 + parseFloat(top1);
	//document.getElementById(name1).style.left = 40;
	//document.getElementById(name1).style.top = 40;
	//document.getElementById(name1).style.zIndex = 200;
	
	
    var IE = document.all?true:false;
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    
    
   try
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    catch(e)
    {  // grab the x-y pos.s if browser is NS
        //tempX = e.pageX;
        //tempY = e.pageY;
        tempX = mouseX(event);
        tempY = mouseY(event);
        //alert(tempX);
    }  
  
   left1 = tempX + 5;
   top1 = tempY;
   
    if(adjustX != ""){left1 = adjustX;}
	if(adjustY != ""){top1 = adjustY;}

	
	document.getElementById(name1).style.position = "absolute";
	//document.getElementById(name1).style.left = (screen.availWidth/2) - 500 + parseFloat(left1);
	//document.getElementById(name1).style.top = (screen.availHeight/2) - 300 + parseFloat(top1);
	if(origin != "1")
	{
	    if(left1 + 200 > 800)
	    {
	        
	        left1 = left1 - 220;
	        
	    }
	    document.getElementById(name1).style.left = left1 + "px";
	    document.getElementById(name1).style.top = top1 + "px";
	    document.getElementById(name1).style.zIndex = 200;
	}
	else
	{
	    document.getElementById(name1).style.left = 0 + "px";
	    document.getElementById(name1).style.top = 0 + "px";
	    document.getElementById(name1).style.zIndex = 200;
	}
	
	//var selects = document.getElementsByTagName("select");
	//for(i=0;i < selects.length ; i++)
	//{
	//	selects[i].style.display = "none";
	//}
	
		
}



function mouseX(evt) 
{
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)
       return evt.clientX + (document.documentElement.scrollLeft ?
       document.documentElement.scrollLeft :
       document.body.scrollLeft);
    else return null;
}
        
function mouseY(evt) 
{
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
       return evt.clientY + (document.documentElement.scrollTop ?
       document.documentElement.scrollTop :
       document.body.scrollTop);
    else return null;
}

function getElementWidth(Elem) 
{
	var img1;
    img1 = new Image();
    img1.src = document.getElementById(Elem).src;
    return img1.width;
}


function getElementHeight(Elem) 
{
	var img1;
    img1 = new Image();
    img1.src = document.getElementById(Elem).src;
    return img1.height;
}

