// Postcard
function thisURL(url) {
	localurl = "/philippinespostcards";
	s = window.location.pathname;
	if (s.slice(0, localurl.length) != localurl)
		return url;
	else {
		if (url.indexOf("/") == 0)		// relative to root
			s = s.slice(0, s.indexOf("/", 1));
		else {												// relative to current directory
			s = s.slice(0, s.lastIndexOf("/") + 1);
			while (url.indexOf("../") == 0) {
				url = url.slice(3, url.length);
				if (s.lastIndexOf("/", s.length-2) >= localurl.length)
					s = s.slice(0, s.lastIndexOf("/", s.length-2) + 1);
			}
		}
		return ("http://" + window.location.host + s + url);
	}
}
function viewPostcard(code) {
  url = "/postcards/view.php?code=" + code;
  swin = window.open(thisURL(url), "Postcard", "width=500,height=460,scrollbars=yes,dependent=no");
  swin.focus();
}
function viewEPostcard(code) {
  url = "/epostcards/view.php?code=" + code;
  swin = window.open(thisURL(url), "Postcard", "width=500,height=460,scrollbars=yes,dependent=no");
  swin.focus();
}
function addPostcard(code, qty) {
  url = "/postcards/add_postcard.php?code=" + code + "&qty=" + qty;
  swin = window.open(thisURL(url), "ShoppingCart", "width=315,height=260,scrollbars=no,dependent=no");
  swin.focus();
}
function addPersonalized(code) {
  url = "/postcards/add_personalized.php?code=" + code;
  swin = window.open(thisURL(url), "ShoppingCart", "width=315,height=260,scrollbars=no,dependent=no");
  swin.focus();
}
// Greeting Cart
function viewGreetingCard(code) {
  url = "/greeting_cards/view.php?code=" + code;
  swin = window.open(thisURL(url), "GreetingCard", "width=500,height=460,scrollbars=yes,dependent=no");
  swin.focus();
}  
function addGreetingCard(code, qty) {
  url = "/greeting_cards/add_greeting_card.php?category=2&code=" + code + "&qty=" + qty;
  swin = window.open(thisURL(url), "ShoppingCart", "width=315,height=280,scrollbars=no,dependent=no");
  swin.focus();
}
// Others
function viewItemInCart(category, id) {
  if (category == 'P') {
    url = "/postcards/view_postcard.php?id=" + id;
    swin = window.open(thisURL(url), "ShoppingCart", "width=315,height=260,scrollbars=no,dependent=no");
    swin.focus();
  } else if (category == 'PP') {
    url = "/postcards/view_personalized.php?id=" + id;
    swin = window.open(thisURL(url), "Preview", "width=500,height=530,scrollbars=no,dependent=no");
    swin.focus();
  }
}
function GE_findObj(obj, d) {
  var i, x; if (!d) d=document;
  x = d[obj]; for (i=0; !x && d.layers && i < d.layers.length; i++) x = GE_findObj(obj, d.layers[i].document);
  if (!x && d.getElementById) x = d.getElementById(obj); return x;
}
function submenuOver(obj) {
  obj.style.backgroundColor = "#FF9900";
}
function submenuOut(obj) {
  obj.style.backgroundColor = "#FFCC00";
}
function gotoURL(url) {
  window.location = thisURL(url);
}
function flashfix() {
  objects = document.getElementsByTagName("object");
  for (var i = 0; i < objects.length; i++) {
    objects[i].outerHTML = objects[i].outerHTML;
  }
}
