//var globalStatus = 0;


var pageFocus=9999;

function ajaxFunction()
{

  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)
      {
      	document.getElementById("mainBody").innerHTML=xmlHttp.responseText;
      }
    }
    xmlHttp.open("GET","results2.php",true);
    xmlHttp.send(null);
}




function getPage(pg)
{

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;
	  }
	}
     }
     
        var url= window.location.href + pg + ".html";

        xmlHttp.onreadystatechange=function()
  	{
  		if(xmlHttp.readyState==4)
    		{
    			if (document.getElementById("mainBody").innerHTML)
			{
				document.getElementById("mainBody").innerHTML = xmlHttp.responseText;
			}
    		}
  	}
  	
  	
  	
        xmlHttp.open("GET",url,false);
        xmlHttp.send(null);

       xmlHttp.onreadystatechange=function()
  	{
  		if(xmlHttp.readyState==4)
    		{
    			if (document.getElementById("mainBody").innerHTML)
			{
				document.getElementById("mainBody").innerHTML = xmlHttp.responseText;
			}
    		}
  	}
        xmlHttp.open("GET",url,false);
        xmlHttp.send(null);
        
      
        document.getElementById("footer").style.display = "none";
      
        if((pg.indexOf('bio')>-1)||(pg.indexOf('customerService')>-1)||(pg.indexOf('contactUs')>-1)||(pg.indexOf('shipping')>-1)||(pg.indexOf('store')>-1)||(pg.indexOf('press')>-1))
      {
        document.img1.src='/img/necklace.png';
        document.img2.src='/img/earrings.png';
        document.img3.src='/img/wedding.png';
        document.img4.src='/img/rings.png';
        document.img5.src='/img/baby.png';
        document.img5.src='/img/blog.png';
      }
      else
      {
        if (pg.indexOf('WE') > -1)
        {
          document.img3.src='/img/wedding2.png';
        }
        else if (pg.indexOf('EA') > -1)
        {
          document.img2.src='/img/earrings2.png';

        }
        else if (pg.indexOf('nec') > -1)
        {
          document.img1.src='/img/necklace2.png';
        }
      }
      
}
	


function processReqChange()
{
	alert(xmlHttp.readyState);
  	if(xmlHttp.readyState==4)
    	{
    	  if (document.getElementById("mainBody").innerHTML)
          {
            document.getElementById("mainBody").innerHTML = xmlHttp.responseText;
          }
    	}

}

function processReqChange2()
{
     
		  if(xmlHttp.readyState==4)
		  {
			  if (document.getElementById("footer").innerHTML)
			  {
				  document.getElementById("footer").innerHTML = xmlHttp.responseText;
			  }
		  }

}

function setFocus(num)
{
	pageFocus = num;
	
	//alert('setFocus: ' + pageFocus);
	
	off();
}



var newwindow = ''
function popup(url) 
{
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,'zoomPic','width=500,height=700,resizable=1');} 
}


function tidy() 
{
if (newwindow.location && !newwindow.closed) { 
   newwindow.close(); } 
}




// ******************************************************
// Script from Stefan Koch - Voodoo's Intro to JavaScript
//     http://rummelplatz.uni-mannheim.de/~skoch/js/
//       JS-book: http://www.dpunkt.de/javascript
//    You can use this code if you leave this message
// ******************************************************

// ok, we have a JavaScript browser
var browserOK = false;
var pics;



// JavaScript 1.1 browser - oh yes!
browserOK = true;
pics = new Array();


var objCount = 0; // number of (changing) images on web-page

function preload(name, first, second) {

  // preload images and place them in an array

  if (browserOK) {
    pics[objCount] = new Array(3);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
  }
}

function on(name)
{
  if (browserOK) 
  {
     for (i = 0; i < objCount; i++) 
     {
      if (document.images[pics[i][2]] != null)
      
      	
        if (name != pics[i][2])
        {
          	// set back all other pictures
          	if (i!=pageFocusinfo())
          	{
          		document.images[pics[i][2]].src = pics[i][0].src;
          	}
        } 
        else 
        {  
           
           // show the second image because cursor moves across this image
           document.images[pics[i][2]].src = pics[i][1].src;
           
        }
     }
  }
}

function off(){
  
  if (browserOK) {
           
           
    	 for (i = 0; i < objCount; i++) 
    	 {
    	  // set back all pictures
		  if (document.images[pics[i][2]] != null)
		  {	
			//alert('i: '+i);
			//hacky code!!!

			if (i!=pageFocusinfo())
			{
				
				document.images[pics[i][2]].src = pics[i][0].src;
			} 

		  }
    	 }
      
  }
  
  
  ///alert('off');
}

function pageFocusinfo()
{
        var Rawurl = document.location.href
        
        //alert(Rawurl);
	
	if (Rawurl.indexOf('ne')>0)
	{
		return 0;
	}
	else if (Rawurl.indexOf('ea')>0)
	{
		return 1;
	}
	else if (Rawurl.indexOf('we')>0)
	{
		return 2;
	}
	else if (Rawurl.indexOf('ri')>0)
	{
		return 3;
	}
	else if (Rawurl.indexOf('ba')>0)
	{
		return 4;
	}	
	return -1
}

// preload images - you have to specify which images should be preloaded
// and which Image-object on the wep-page they belong to (this is the first
// argument). Change this part if you want to use different images (of course
// you have to change the body part of the document as well)


preload("img1", "/img/necklace.png", "/img/necklace2.png");
preload("img2", "/img/earrings.png", "/img/earrings2.png");
preload("img3", "/img/wedding.png", "/img/wedding2.png");
preload("img4", "/img/rings.png", "/img/rings2.png");
preload("img5", "/img/baby.png", "/img/baby2.png");
preload("img6", "/img/blog.png", "/img/blog2.png");

