//-- CONSTANTS --//
var CONST_STANDARD='http://www.liveunitedblount.org/standard.php';
var CONST_PDF='http://dev.liveunitedblount.org/pdfs/';
//-- CONSTANTS END --//

document.onkeypress=fnKeyPress;

function fnKeyPress(e){
  
	if(document.getElementById('idSearch').value){

  var KeyID = (window.event) ? event.keyCode : e.keyCode;
	//alert(KeyID); //Need a keyCode?

  if(KeyID==13){
	 ajaxSearch();
	}

	}

}

 function fnNewRollIn(button, file){
  document.getElementById(button).src="images/redesign/2_"+ file;
 }

 function fnNewRollOut(button, file){
  document.getElementById(button).src="images/redesign/"+ file;
 }

 function fnRollIn(button, file){
  document.getElementById(button).src="images/2_"+ file;
 }

 function fnRollOut(button, file){
  document.getElementById(button).src="images/"+ file;
 }
 
 /*
 function fnMouseDown(button, file){
  document.getElementById(button).src="images/3_"+ file;
 }
 */
 
//--- DIV ---//
 function fnRollInDIV(button, file){
  //document.getElementById(button).style.backgroundImage="url('images/2_"+ file +"')";
 }

 function fnRollOutDIV(button, file){
  //document.getElementById(button).style.backgroundImage="url('images/"+ file +"')";
 }
//--- DIV ---//

function fnShowSub(dropId){
  if(
	   (document.getElementById('idJac'))&&
	   (document.getElementById('idJac').innerHTML=="ON")
	  ){
		} else {

   if(document.getElementById('idSub_'+dropId).style.display=="none"){
    document.getElementById('idSub_'+dropId).style.display="block";
   } else {
    document.getElementById('idSub_'+dropId).style.display="none";
   } 
 
  }
}

 function fnArrow(button, tmpId){
  if(
	   (document.getElementById('idJac'))&&
	   (document.getElementById('idJac').innerHTML=="ON")
	  ){
		} else {
		
    if(document.getElementById(button).src==document.getElementById('idCONST_IMAGES').value+"arrow_down.jpg"){
     document.getElementById(button).src=document.getElementById('idCONST_IMAGES').value+"arrow_side.jpg";
     document.getElementById('idMenu_'+tmpId).style.display="none";
  	} else {
     document.getElementById(button).src=document.getElementById('idCONST_IMAGES').value+"arrow_down.jpg";
     ajaxGetMenu(tmpId);
  	}
		
		}	
 }


function ajaxSearch()
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

			 //alert(xmlHttp.responseText);
			 document.getElementById('idMiddle').innerHTML=xmlHttp.responseText; //'test123';//iframeDocument.body.innerHTML +'<br/><br/>';
			 document.getElementById('idSearch').value='';
			 window.scroll(0,0);			 
			 
      }
    }
	xmlHttp.open("GET","search/search.php?srch="+document.getElementById('idSearch').value,true); //8smart.php
	
  xmlHttp.send(null);
}


 
function fnIframeReload()
{

tmpId=document.getElementById('idIframe').value;

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

			 //alert(xmlHttp.responseText);
			 document.getElementById('idMiddle').innerHTML=xmlHttp.responseText; //'test123';//iframeDocument.body.innerHTML +'<br/><br/>';
			 window.scroll(0,0);			 
			 
      }
    }
	xmlHttp.open("GET","xml/xml_get_content.php?id="+tmpId,true);
	
  xmlHttp.send(null);
 
 /*
  var iframe=document.getElementById('idIframe');
  if (iframe.contentDocument) { // For NS6
    iframeDocument = iframe.contentDocument; 
  } else if (iframe.contentWindow) { // For IE5.5 and IE6
    iframeDocument = iframe.contentWindow.document;
  } else if (iframe.document) { // For IE5
    iframeDocument = iframe.document;
  } else { // We got nothin.
    alert("Error: could not find IFRAME document");
  }
 */
//  document.getElementById('idMiddle').innerHTML='test123';//iframeDocument.body.innerHTML +'<br/><br/>';
//	window.scroll(0,0);
 }

//-- IFRAME

 function fnIframeLoaded(){
 /*
  var iframe=document.getElementById('idIframe');
  if (iframe.contentDocument) { // For NS6
    iframeDocument = iframe.contentDocument; 
  } else if (iframe.contentWindow) { // For IE5.5 and IE6
    iframeDocument = iframe.contentWindow.document;
  } else if (iframe.document) { // For IE5
    iframeDocument = iframe.document;
  } else { // We got nothin.
    alert("Error: could not find IFRAME document");
  }
	*/
  var redirect_script_uri=document.getElementById('idREDIRECT_SCRIPT_URI').value;
	var tmpRoot=document.getElementById('idCONST_ROOT').value + redirect_script_uri;
	//alert(iframe.src);	
	//alert(tmpRoot);	
  	if((iframe.src!="")&&(iframe.src!=tmpRoot)){
	   tmpPgCheck=iframe.src.indexOf('/display/');
	   if(tmpPgCheck!=-1){
		  document.getElementById('idMiddle').innerHTML='test456';//iframeDocument.body.innerHTML +'<br/><br/>';
			window.scroll(0,0);
	   }
  	}	//alert(iframeDocument.body.innerHTML);

 }

function fnOpenPDF(pdf){
	window.open(CONST_PDF +""+ pdf);	
} 
 
function fnGoStandard(pg,target){
  if(target=="_self"){
	 document.location=CONST_STANDARD +"?pg="+ pg;
	} else {
	 window.open(CONST_STANDARD +"?pg="+ pg);	
	}
}
 
function fnMenuSelection(selection, id, url){

  if(
	   (document.getElementById('idJac'))&&
	   (document.getElementById('idJac').innerHTML=="ON")
	  ){
		} else {

	 if(url==0){
	  //alert('Regular page link.');
		//alert(selection);
	  //document.getElementById('idIframe').src='admin/cms/display/'+ selection;
		document.getElementById('idIframe').value=selection;
		fnIframeReload();
		/*
		//TURN ON FORMS
		if(document.getElementById('idBrowserPage').value=='contact_us.php'){
		 arrSelection=selection.split('_');
		 //alert(arrSelection);
		 tmpSelection=arrSelection[1];
		 for(x=2;x<arrSelection.lenght;x++){
		  tmpSelection=tmpSelection+'_'+arrSelection[x];
		 }
		 //alert(tmpSelection);
		 if(tmpSelection=='home.html'){ //home.html
	 	  //alert('Form ON.');
		  document.getElementById('idOnOffForm').style.display='block';
		 } else {
	 	  //alert('Form OFF.');		 
		  document.getElementById('idOnOffForm').style.display='none';
		 }
		}
		//TURN ON FORMS END
		*/
	 } else {
	  tmpSelection=selection.search('http:');
	  if(tmpSelection>-1){
     window.open(selection, '')
	   //document.location=selection;
	  } else {
	   document.location=selection;
	  }
	 }
	 	 
   //ajaxBreadCrumbs(selection); 
	 } //if jac
} 

//-- AJAX FOR GET MENU --//
function ajaxGetMenu(tmpId)
{
//alert('ajaxShowPrompt');

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

			 //alert(xmlHttp.responseText);
			 document.getElementById('idMenu_'+tmpId).innerHTML=xmlHttp.responseText;
			 document.getElementById('idMenu_'+tmpId).style.display="block";			 
			 
      }
    }
	xmlHttp.open("GET","xml/xml_get_menu.php?id="+tmpId,true);
	
  xmlHttp.send(null);
  }
//-- AJAX FOR GET MENU END --//


//-- AJAX FOR GET MENU --//
function ajaxBreadCrumbs(tmpFilename)
{
//alert('ajaxShowPrompt');

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
			 //alert(xmlHttp.responseText);
       document.getElementById('idBreadCrumbs').innerHTML=xmlHttp.responseText;

    	 if(document.getElementById('idBreadCrumbsOn').value==1){
          document.getElementById('idBreadCrumbsWrap').style.display="block";
    	 } else {
    	  document.getElementById('idBreadCrumbsWrap').style.display="none";			 
    	 }			 
			 
      }
    }
	xmlHttp.open("GET","xml/xml_bread_crumbs.php?id="+tmpFilename,true);
	
  xmlHttp.send(null);
  }
//-- AJAX FOR GET MENU END --//
