
var pages = new Array();
var titles = new Array();
var pageTitles = new Array();


pages["home"] = "home.htm";
pages["biography"] = "biography.htm";
pages["services"] = "services.htm";
pages["hire"] = "hire.htm";
pages["contact"] = "contact.htm";

pages["info"] = "info.htm";
pages["locate"] = "locate.htm";
//pages["missing"] = "locate.htm#missing";
pages["asset"] = "asset.htm";
pages["matrimonial"] = "matrimonial.htm";
pages["exec"] = "exec.htm";
pages["criminal"] = "criminal.htm";
pages["identity"] = "identity.htm";
pages["surveillance"] = "surveillance.htm";
pages["technology"] = "technology.htm";
pages["restaurant"] = "restaurant.htm";

pageTitles["home"] = "Craig Investigations, Inc. Home page";
pageTitles["biography"] = "Craig Investigations, Inc. Biography";
pageTitles["services"] = "Craig Investigations, Inc. Services";
pageTitles["hire"] = "Craig Investigations, Inc. Hire";
pageTitles["contact"] = "Craig Investigations, Inc. Contact";

pageTitles["info"] = "Craig Investigations, Inc. Information";
pageTitles["locate"] = "Craig Investigations, Inc. Locate Search";
//pageTitles["missing"] = "locate.htm#missing";
pageTitles["asset"] = "Craig Investigations, Inc. Assest";
pageTitles["matrimonial"] = "Craig Investigations, Inc. Matrimonial";
pageTitles["exec"] = "Craig Investigations, Inc. Exec";
pageTitles["criminal"] = "Craig Investigations, Inc. Criminal";
pageTitles["identity"] = "Craig Investigations, Inc. Identity";
pageTitles["surveillance"] = "Craig Investigations, Inc. Surveillance";
pageTitles["technology"] = "Craig Investigations, Inc. Technology";
pageTitles["restaurant"] = "Craig Investigations, Inc. Restaurant";

titles["home"] = "<p align='center'><b><font face='Arial' style='font-size: 11pt'>Welcome to Craig Investigations, Inc.<br> </font><font face='Arial' size='2'><i>&quot;Your leader in the Investigative &amp; Surveillance Fields&quot;</i></font></b>";
titles["biography"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>BIOGRAPHY</b></font></span>";
titles["services"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>SERVICES</b></font></span>";
titles["hire"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>HIRING US</b></font></span>";
titles["contact"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>CONTACT CRAIG INVESTIGATIONS</b></font></span>";
titles["locate"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>CONTACT CRAIG INVESTIGATIONS</b></font></span>";

titles["info"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>INFORMATION RESEARCH</b></font></span>";
titles["locate"] = "<b><span style='text-decoration: underline; letter-spacing: 1pt;'><font style='font-size: 11pt;' face='Arial'>LOCATE SEARCH</font></span><font style='font-size: 11pt;' face='Arial'><span style='letter-spacing: 1pt;'>&nbsp;&nbsp;&nbsp;</span></font><img src='images/dot.jpg'></img><font color='#000000' size='3'><a href='#locate'><font color='#000080'>Locating People</font></a><br><font face='Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><img src='images/dot.jpg'></img><a href='#missing'><font color='#000080'>Missing People</font></a></font></font></font></b>";
titles["asset"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>ASSET INVESTIGATIONS</b></font></span>";
titles["matrimonial"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>MATRIMONIAL SERVICES</b></font></span>";
titles["exec"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>EXECUTIVE PROTECTION</b></font></span>";
titles["criminal"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>CRIMINAL SERVICES</b></font></span>";
titles["identity"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>IDENTITY THEFT</b></font></span>";
titles["surveillance"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>CORPORATE OBSERVATION</b></font></span>";
titles["technology"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>TECHNOLOGY</b></font></span>";
titles["restaurant"] = "<p align='center'><span style='letter-spacing: 1pt'><font style='font-size: 11pt; text-decoration: underline;' face='Arial'><b>RESTAURANT SPOTTERS</b></font></span>";

function gotoAnchor(anchor){
	document.getElementById('mainContent').location = "#missing";
}

function adjustHeight() {
   var myWidth = 0, myHeight = 0;
   if( typeof( window.innerWidth ) == 'number' ) {
     //Non-IE
     myWidth = window.innerWidth;
     myHeight = window.innerHeight;
   } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
     //IE 6+ in 'standards compliant mode'
     myWidth = document.documentElement.clientWidth;
     myHeight = document.documentElement.clientHeight;
   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
     //IE 4 compatible
     myWidth = document.body.clientWidth;
     myHeight = document.body.clientHeight;
   }
   if (myHeight < 400) myHeight = 300;
   document.getElementById('mainContent').style.height = (myHeight - 300) + "px";
   
}

function historyChange(newLocation, historyData) {	
	if (newLocation == "") {
		newLocation = "home";
	}
	if (newLocation.length == 1) return;
	ajaxCall.loadPage(newLocation);
}

var ajaxCall = {
	isLoading : false,
	loadPage : function(pageId) {
		if (ajaxCall.isLoading) return;
		ajaxCall.isLoading = true;
		var page = pages[pageId];
		var title = titles[pageId];
		var pageTitle = pageTitles[pageId];
		//alert(page);
		if (page == undefined) {
			pageId = "home";
			page = pages[pageId];
			title = titles[pageId];
			pageTitle = pageTitles[pageId];
		}  // not a page
		
		dhtmlHistory.add(pageId, page);
		
		var loadingIndicator = document.getElementById('loading');
		var mainContentArea = document.getElementById('mainContent');
		var myTitle = document.getElementById('divTitle');
		mainContentArea.innerHTML = loadingIndicator.innerHTML;
		myTitle.innerHTML = "";//loadingIndicator.innerHTML;
		loadingIndicator.style.visibility="visible";
		
		var handleSuccess = function(o) {
			mainContentArea.innerHTML = o.responseText;
			loadingIndicator.style.visibility="hidden";	
			ajaxCall.isLoading = false;
			myTitle.innerHTML = title;
			document.title = pageTitle;
		};
		
		var handleFailure = function(o) {
			alert("Connection failure. Please try again later.");
			loadingIndicator.style.visibility="hidden";	
			ajaxCall.isLoading = false;
		};
		
		var callBack = {success:handleSuccess, failure:handleFailure};
		
		YAHOO.util.Connect.asyncRequest('GET', page +'?nocache=' + Math.random(), callBack);
		
		
	}
};


function init() {
	document.getElementById('loading').style.display="none";
    //adjustHeight();
    dhtmlHistory.initialize();
    dhtmlHistory.addListener(historyChange);

    var currentLocation = dhtmlHistory.getCurrentLocation();

    if (currentLocation == "") {
       currentLocation = "home";
    }
   
    ajaxCall.loadPage(currentLocation);
}

function preloadImages() {

	var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
	
	for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }

}



/*Check character?*/



function FrontPage_Form1_Validator(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Your Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Your Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length > 200)
  {
    alert("Please enter at most 200 characters in the \"Your Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Your Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Your Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length > 200)
  {
    alert("Please enter at most 200 characters in the \"Your Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Comment.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.Comment.focus();
    return (false);
  }

  if (theForm.Comment.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Comments\" field.");
    theForm.Comment.focus();
    return (false);
  }

  if (theForm.Tele.value != "")
  {
      if (theForm.Tele.value.length < 6)
	  {
	    alert("Please enter at least 6 characters in the \"Telephone\" field.");
	    theForm.Tele.focus();
	    return (false);
	  }
	
	  if (theForm.Tele.value.length > 50)
	  {
	    alert("Please enter at most 50 characters in the \"Telephone\" field.");
	    theForm.Tele.focus();
	    return (false);
	  }
	
	  var checkOK = "0123456789-- \t\r\n\f";
	  var checkStr = theForm.Tele.value;
	  var allValid = true;
	  var validGroups = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length)
	    {
	      allValid = false;
	      break;
	    }
	  }
	  if (!allValid)
	  {
	    alert("Please enter only digit, whitespace and \"-\" characters in the \"Telephone\" field.");
	    theForm.Tele.focus();
	    return (false);
	  }
  }

  
  return (true);
}

YAHOO.util.Event.on(window, 'load', init);
//YAHOO.util.Event.on(window, 'resize', adjustHeight);
