// JavaScript Document
window.onload = function () {
	
	
	var menu_home = document.getElementById('menu_home');
	if(menu_home) {
		menu_home.onmouseover = function () {
			menu_home.src = '/images/menu_home_over.png';
		}
		menu_home.onmouseout = function () {
			menu_home.src = '/images/menu_home.png';
		}
	}
	
	var menu_features = document.getElementById('menu_unique_features');
	if(menu_features) {
		menu_features.onmouseover = function () {
			menu_features.src = '/images/menu_unique_features_over.png';
		}
		menu_features.onmouseout = function () {
			menu_features.src = '/images/menu_unique_features.png';
		}
	}
	
	var menu_all_features = document.getElementById('menu_all_features');
	if(menu_all_features) {
		menu_all_features.onmouseover = function () {
			menu_all_features.src = '/images/menu_all_features_over.png';
		}
		menu_all_features.onmouseout = function () {
			menu_all_features.src = '/images/menu_all_features.png';
		}
	}
	
	var menu_pricing = document.getElementById('menu_pricing');
	if(menu_pricing) {
		menu_pricing.onmouseover = function () {
			menu_pricing.src = '/images/menu_pricing_over.png';
		}
		menu_pricing.onmouseout = function () {
			menu_pricing.src = '/images/menu_pricing.png';
		}
	}
	
	var menu_sign_up = document.getElementById('menu_sign_up');
	if(menu_sign_up) {
		menu_sign_up.onmouseover = function () {
			menu_sign_up.src = '/images/menu_sign_up_over.png';
		}
		menu_sign_up.onmouseout = function () {
			menu_sign_up.src = '/images/menu_sign_up.png';
		}
	}
	
	var try_now = document.getElementById('img_try_now');
	if(try_now) {
		try_now.onmouseover = function () {
			try_now.src = '/images/try_now_on.png';
		}
		
		try_now.onmouseout = function () {
			try_now.src = '/images/try_now.png';	
		}
	}
	
	if(_current_page == 'home') {
		if(menu_home) {
		menu_home.src = '/images/menu_home_on.png';
		menu_home.onmouseover = null;
		menu_home.onmouseout = null;
		}
	}
	
	if(_current_page == 'unique_features') {
		if(menu_features) {
		menu_features.src = '/images/menu_unique_features_on.png';
		menu_features.onmouseover = null;
		menu_features.onmouseout = null;
		}
		setTimeout("showAnywhereProductsImage2()",4000);
		setTimeout("showAnywhereProductsImage3()",8000);
		setTimeout("showAnywhereProductsImage4()",12000);
		setTimeout("showAnywhereProductsImage1()",16000);
	}
	
	if(_current_page == 'all_features') {
		if(menu_all_features) {
		menu_all_features.src = '/images/menu_all_features_on.png';
		menu_all_features.onmouseover = null;
		menu_all_features.onmouseout = null;
		}
	}

	if(_current_page == 'pricing') {
		if(menu_pricing) {
		menu_pricing.src = '/images/menu_pricing_on.png';
		menu_pricing.onmouseover = null;
		menu_pricing.onmouseout = null;
		}
	}
	
	
	//document.write("<style type='text/css'>#img_anywhere_products_2 {visibility:hidden;} #img_anywhere_products_3 {visibility:hidden;} #img_anywhere_products_4 {visibility:hidden;}</style>");
}

function showAnywhereProductsImage2() {
  document.getElementById("div_anywhere_products_caption").innerHTML = 'Step 2: We want to add ecommerce enabled products here.';	
  imageId = 'img_anywhere_products_2';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function showAnywhereProductsImage3() {
  document.getElementById("div_anywhere_products_caption").innerHTML = 'Step 3: Enable Anywhere Products.';		
  imageId = 'img_anywhere_products_3';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function showAnywhereProductsImage4() {
  document.getElementById("div_anywhere_products_caption").innerHTML = 'Step 4: Products can now be bought on the existing website.';		
  imageId = 'img_anywhere_products_4';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function showAnywhereProductsImage1() {
  //hide images 2 and 3
  document.getElementById('img_anywhere_products_2').style.visibility = 'hidden';
  document.getElementById('img_anywhere_products_3').style.visibility = 'hidden';
  document.getElementById("div_anywhere_products_caption").innerHTML = 'Step 1: Here is an existing website without ecommerce.';	
  imageId = 'img_anywhere_products_4';
  image = document.getElementById(imageId);
  setOpacity(image, 100);
  image.style.visibility = 'visible';
  fadeOut(imageId,100);
  
	setTimeout("showAnywhereProductsImage2()",4000);
	setTimeout("showAnywhereProductsImage3()",8000);
	setTimeout("showAnywhereProductsImage4()",12000);
	setTimeout("showAnywhereProductsImage1()",16000);  
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj, opacity);
      opacity -= 10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
    }
  }
}
