<!--

function act(s_id,p_id,title,price,frm_id,lyr) {
	var link='/cgi-bin/mpw8/addtocart2.cgi?id='+s_id+'&pid='+p_id+'&title='+title+'&price='+price+'&lyr='+lyr;
	if (frm_id) link = link + '&fid=' + frm_id;
	if (document.all!=null) { // ie
		var iev = /MSIE 5\.2[123]/;
		var iphone = /iPhone/;
		var iep = /PowerPC/;
		var iestr = navigator.userAgent;
		var toppx = 0;
		var leftpx = 0;

		if(iphone.test(iestr)) {
			alert("here");
			toppx = 100;
			leftpx = 100;
		}

		if (iev.test(iestr) && iep.test(iestr)) {
			link = '/cgi-bin/mpw8/addtocartlite.cgi?id='+s_id+'&pid='+p_id+'&title='+title+'&price='+price+'&lyr='+lyr;
			if (frm_id) link = link + '&fid=' + frm_id;
			window.location = link;
		} else {
			var myregex = /MSIE 7\.0/i;
			if(myregex.test(iestr)) scrollY = document.documentElement.scrollTop;
			else scrollY = document.body.scrollTop;
			document.all['shoppingcart'].style.display = 'block';
			if(toppx != 0 && leftpx != 0) {
				document.all['shoppingcart'].style.top = toppx + 'px';
				document.all['shoppingcart'].style.left = leftpx + 'px';
			} else {
				document.all['shoppingcart'].style.top = (screen.height/2 + scrollY - parseInt(document.getElementById('shoppingcart').clientHeight)) + 'px';
				document.all['shoppingcart'].style.left = '175px';
			}
			document.all['shoppingcart'].style.visibility = 'visible';
			document.all['shoppingcart'].src=link;
		}
	} else { // nn4 or nn6
		var nsstr = navigator.userAgent;
		var iphone = /iPhone/;
		var toppx = 0;
		var leftpx = 0;

		if(iphone.test(nsstr)) {
			toppx = 100;
			leftpx = 100;
		}
		var nn6=(document.getElementById != null)
		if (nn6) {	// nn6
			document.getElementById('shoppingcart').style.display = 'block';
			if(toppx != 0 && leftpx != 0) {
				document.getElementById('shoppingcart').style.fontSize = 10 + 'px';
				document.getElementById('shoppingcart').style.width = 425 + 'px';
				document.getElementById('shoppingcart').style.height = 250 + 'px';
				document.getElementById('shoppingcart').style.top = toppx + 'px';
				document.getElementById('shoppingcart').style.left = leftpx + 'px';
			} else {
				document.getElementById('shoppingcart').style.top = (screen.height/2 + window.pageYOffset - parseInt(document.getElementById('shoppingcart').clientHeight)) + 'px';
				document.getElementById('shoppingcart').style.left = (screen.width/2 - parseInt(document.getElementById('shoppingcart').clientWidth)) + 'px';
			}
			document.getElementById('shoppingcart').style.visibility = 'visible';
			document.getElementById('shoppingcart').src=link;
		} else { // we are in NN4
			popupWin=window.open(link+'&pl=1','remote','menubar=no,toolbar=no,location=no,directives=no,status,scrollbars,resizable=no,width=250,height=300');
			popupWin.focus();
		}
	}
}

function atw(s_id,p_id,title,price,frm_id) {	
	var link='/cgi-bin/mpw8/addtowishlist.cgi?id='+s_id+'&pid='+p_id+'&title='+title+'&price='+price;
	if (frm_id) link = link + '&fid=' + frm_id;
	if (document.all!=null) { // ie
		var iev = /MSIE 5\.2[123]/;
		var iep = /PowerPC/;
		var iestr = navigator.userAgent;
		if (iev.test(iestr) && iep.test(iestr)) {
			link = '/cgi-bin/mpw8/addtowishlist.cgi?id='+s_id+'&pid='+p_id+'&title='+title+'&price='+price;
			if (frm_id) link = link + '&fid=' + frm_id;
			window.location = link;
		} else {
			var myregex = /MSIE 7\.0/i;
			if(myregex.test(iestr)) scrollY = document.documentElement.scrollTop;
			else scrollY = document.body.scrollTop;
			document.all['wishlist'].style.top = (screen.height/2 + scrollY - parseInt(document.getElementById('wishlist').clientHeight)) + 'px';
			document.all['wishlist'].style.left = '175px';
			document.all['wishlist'].style.visibility = 'visible';
			document.all['wishlist'].style.display = 'block';
			document.all['wishlist'].src=link;
		}
	} else { // nn4 or nn6
		var nsstr = navigator.userAgent;
		var iphone = /iPhone/;
		var toppx = 0;
		var leftpx = 0;

		if(iphone.test(nsstr)) {
			toppx = 100;
			leftpx = 100;
		}
		var nn6=(document.getElementById != null)
		if (nn6) {	// nn6
			document.getElementById('wishlist').style.display = 'block';
			if(toppx != 0 && leftpx != 0) {
				document.getElementById('wishlist').style.fontSize = 10 + 'px';
				document.getElementById('wishlist').style.width = 425 + 'px';
				document.getElementById('wishlist').style.height = 250 + 'px';
				document.getElementById('wishlist').style.top = toppx + 'px';
				document.getElementById('wishlist').style.left = leftpx + 'px';
			} else {
				document.getElementById('wishlist').style.top = (screen.height/2 + window.pageYOffset - parseInt(document.getElementById('wishlist').clientHeight)) + 'px';
				document.getElementById('wishlist').style.left = (screen.width/2 - parseInt(document.getElementById('wishlist').clientWidth)) + 'px';
			}
			document.getElementById('wishlist').style.visibility = 'visible';			
			document.getElementById('wishlist').src=link;
		} else { // we are in NN4
			popupWin=window.open(link+'&pl=1','remote','menubar=no,toolbar=no,location=no,directives=no,status,scrollbars,resizable=no,width=250,height=300');
			popupWin.focus();
		}
	}
}

function replace(string,text,by) {
// Replaces text with by in string
    var i = string.indexOf(text);
    if (string.length == 0) return string;
    if ((!i) && (text != string.substring(0,text.length))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+text.length < string.length)
        newstr +=
        replace(string.substring(i+text.length,string.length),text,by);

    return newstr;
}

function WM_checkIn(id) {

  // This function checks for DOM strategy, then
  // returns an object reference.
  if (document.all) {
    return document.all[id].style;
  } else if(document.layers) {
    return document.layers[id];
  } else if(document.getElementById) {
  	 return document.getElementById(id).style;
  }
}

// set hidden/visible vars for Netscape 4 compatibility
if (document.layers) {
  var hidden = "hide";
  var visible = "show";
} else {
  var hidden = "hidden";
  var visible = "visible";
}

var toggle = "toggle";

function WM_changeVisibility() {
  if (document.layers || document.all || document.getElementById) {
    var inc, endInc=arguments.length;
    // run through the args (objects) and set the visibility of each
    for (inc=0; inc<endInc; inc+=2) {
      // get a good object reference
      var daObj = WM_checkIn(arguments[inc]);
      if (arguments[inc+1] == hidden) {
        // hide the object
        daObj.visibility = hidden;
      } else if (arguments[inc+1] == visible) {
        // show the object
        daObj.visibility = visible;
      } else if (arguments[inc+1] == toggle) {
        // toggle the object's visibility
        if (daObj.visibility == visible) {
          daObj.visibility = hidden;
        } else if (daObj.visibility == hidden) {
          daObj.visibility = visible;
        }
      }
    }
  }
}

function getStyle(el, style) {
   if(!document.getElementById) return;

     var value = el.style[toCamelCase(style)];

    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);

        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];

     return value;
}

/** toCamelCase(input)
 * Converts string input to a camel cased version of itself.
 * For example:
 * toCamelCase("z-index"); // returns zIndex
 * toCamelCase("border-bottom-style"); // returns borderBottomStyle.
 */
function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ?
    	oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
}
function help(topic)
{
	if (topic == 'shipping') {
		helpWin=window.open('http://eu.movieposter.com/cgi-bin/mpw8/helpshipping.pl','remote','menubar=no,toolbar=no,location=no,directives=no,status=no,scrollbars=no,resizable=no,width=450,height=475');
	} else {
		helpWin=window.open('http://eu.movieposter.com/cgi-bin/mpw8/new_helpmatrix.pl?topic='+topic,'remote','menubar=no,toolbar=no,location=no,directives=no,status=no,scrollbars=no,resizable=no,width=450,height=450');
	}
	helpWin.focus()
}

function updateList(obj,eName,resetTitle) {
	// alert(myVal.length);
	var value;
	if (obj.value.length > 0) {
		if (obj.value != 'other' && obj.value != '0|0' && obj.value != "w|h") {
			if (obj.value.indexOf('|') != -1) {
				var lstObj = obj.value.split('|');
				var lstVal = eName.split('|');
				for (i=0; i<lstObj.length; i++) {
					document.regsearch.elements[lstVal[i]].value = lstObj[i];
					// alert(lstVal[i] + ' / ' + lstObj[i]);
				}
			} else {
				document.regsearch.elements[eName].value = obj.value;
			}
		} else {
			if (obj.value == 'other') {
				if (value = prompt('Who are you searching for\n\nSyntax: Last Name, First Name  ie: Affleck, Ben', 'Last Name, First Name')) {
					// alert('Yes ' + value);
					if (value != 'Last Name, First Name') {
						obj.options[obj.options.length] = new Option(value,value);
						obj.selectedIndex = obj.options.length - 1;
						document.regsearch.elements[eName].value = value;
					}
				} else {
					// cancel
				}
			} else if (obj.value == 'w|h') {
				if(value = prompt('What size are you searching for in inches\n\nSyntax: Width,Height ie: 11,11','Width,Height')) {
					if(value != 'Width,Height') {
						var lstVal = value.split(',');
						var w = 0;
						var h = 0;
						if(lstVal.length > 0) {
							if(parseInt(lstVal[0]) > 0) {
								w = parseInt(lstVal[0]);
							}
							if(parseInt(lstVal[1]) > 0) {
								h = parseInt(lstVal[1]);
							}
						}
						obj.options[obj.options.length] = new Option(w + '" x ' + h + '"',w + '|' + h);
						obj.selectedIndex = obj.options.length - 1;
						document.regsearch.elements['sw'].value = w;
						document.regsearch.elements['sl'].value = h;
					}
				}				
			} else {
				var d = new Date();
				var curr_year = d.getFullYear();
				if (value = prompt('What year would you like to include in your search', curr_year)) {
					// alert('Yes ' + value);
					if (parseInt(value) > 0) {
						obj.options[obj.options.length] = new Option(value,value+'|'+value);
						obj.selectedIndex = obj.options.length - 1;
						if (eName.indexOf('|') != -1) {
							var lstVal = eName.split('|');
							for (i=0; i<lstVal.length; i++) {
								document.regsearch.elements[lstVal[i]].value = value;
								// alert(lstVal[i] + ' / ' + lstObj[i]);
							}
						} else {
							document.regsearch.elements[eName].value = value;
						}					}
				} else {
					// cancel
				}
			}
		}
	} else {
		document.regsearch.elements[eName].value = '';
	}
	if (resetTitle) { document.regsearch.elements['ti'].value = ''; }
}

function initList(myVal,fldReal,fldVirtual) {
	var found = false;
	if (myVal.length > 0) {
		if (myVal.indexOf('|') != -1) {
			var myList = myVal.split('|');
			var myReal = fldReal.split('|');
			for (i=0; i < myList.length; i++ ) {
				document.regsearch.elements[myReal[i]].value = myList[i];
			}
		} else {
			document.regsearch.elements[fldReal].value = myVal;
		}
		for(var i = 0; i < document.extraSearch.elements[fldVirtual].options.length && found == false; i++) {
			if (document.extraSearch.elements[fldVirtual].options[i].value == myVal) {
				document.extraSearch.elements[fldVirtual].selectedIndex = i;
				found = true;
			}
		}
		if (!found && myVal.indexOf('|') == -1) {
			var myValTxt = myVal;
			if (window.globalGroupName != null) { myValTxt = window.globalGroupName; }
			document.extraSearch.elements[fldVirtual].options[document.extraSearch.elements[fldVirtual].options.length] = new Option(myValTxt,myVal);
			document.extraSearch.elements[fldVirtual].selectedIndex = document.extraSearch.elements[fldVirtual].options.length - 1;
			document.regsearch.elements[fldReal].value = myVal;
		}
	} else {
		document.regsearch.elements[fldReal].value = '';
	}
}

function initTitle(myVal,fldReal) {
	document.regsearch.elements[fldReal].value = myVal;
}

function checkCart() {
	if(document.getElementById('sc')) {
		var pReq;
		var curr;
		var url = document.location.href;

		if(url.indexOf("www.movieposter.com") > 0) {
			curr = "USD";
			currcode = "$";
		} else if(url.indexOf("ca.movieposter.com") > 0) {
			curr = "MPW";
			currcode = "$";
		} else if(url.indexOf("eu.movieposter.com") > 0) {
			curr = "EUR";
			currcode = "&#8364;";
		} else if(url.indexOf("uk.movieposter.com") > 0) {
			curr = "GBP";
			currcode = "&#163;";
		} else if(url.indexOf("au.movieposter.com") > 0) {
			curr = "AUD";
			currcode = "$";
		}

		pReq = new AsyncRequest();
		pReq.data='c='+curr;
		pReq.method='POST';
		pReq.url='/cgi-bin/ajax/cart.pl';
		pReq.cache=false;
		pReq.callback=function(responseText) {
			if(responseText.length>0) {
				var responseArray = responseText.split('\&');
				for( var sIndex in responseArray ) {
					if(responseArray[sIndex]) {
						var garray = responseArray[sIndex].split('=');
						if(garray[0] == 'q' && garray[1]) {
							$('sci').innerHTML = garray[1];
						}
						if(garray[0] == 't' && garray[1]) {
							$('sct').innerHTML = currcode + garray[1];
						}
					}
				}
			}
		}
		pReq.send(null);
	}
}

function initGlobal() {
	if (window.globalCrew != null) { initList(globalCrew,'cr','castcrew'); }
	if (window.globalTitle != null) { initTitle(globalTitle,'ti'); }
	if (window.globalGroup != null) { initList(globalGroup,'gr','genre'); }
	if (window.globalPrice != null) { initList(globalPrice,'prl|prh','price'); }
	if (window.globalExtra != null) { initList(globalExtra, 'or|si','posterType'); }
	if (window.globalYear != null) { initList(globalYear, 'ys|ye','dateRange'); }
	if (window.globalSize != null) { initList(globalSize, 'sw|sl','posterSize'); }

	if (document.getElementById != null) {
		var found = false;
		var cHeight = 0;
		if (document.getElementById('maincontent') != null) {
			if (parseInt(document.getElementById('maincontent').clientHeight) > cHeight) {
				found = true; cHeight = parseInt(document.getElementById('maincontent').clientHeight);
			}
		}
		if (document.getElementById('leftnav') != null) {
			if (parseInt(document.getElementById('leftnav').clientHeight) > cHeight) {
				found = true; cHeight = parseInt(document.getElementById('leftnav').clientHeight);
			}
		}
		if (document.getElementById('toplist') != null) {
			if (parseInt(document.getElementById('toplist').clientHeight) > cHeight) {
				found = true; cHeight = parseInt(document.getElementById('toplist').clientHeight);
			}
		} else {
			if (document.getElementById('maincontent') != null) {
				document.getElementById('maincontent').style.right = 0 + 'px';
			}
		}
		if (found) {
			// alert(cHeight);
			if (parseInt(document.getElementById('maincontent').clientHeight) != cHeight) {
				document.getElementById('maincontent').style.height = cHeight + 'px';
			}
			if (parseInt(document.getElementById('leftnav').clientHeight) != cHeight) {
				document.getElementById('leftnav').style.height = cHeight + 'px';
			}
			if (document.getElementById('toplist') != null) {
				if (parseInt(document.getElementById('toplist').clientHeight) != cHeight) {
					document.getElementById('toplist').style.height = cHeight + 'px';
				}
			}
		}
	}

	if (window.shipInit) {
		shipInit();
	}
	if (window.confirmInit) {
		confirmInit();
	}
	if (window.checkCart) {
		checkCart();
	}
	if(document.getElementById('divWL') || document.getElementById('divSuggested')) {

		var divwl = 0;
		var divs = 0;
		var t = 4;
		var cnamewl = "";
		var cnames = "";
		if(document.getElementById('divWL')) {
			divwl = document.getElementById('divWL').clientHeight;
			cnamewl = document.getElementById('divWL').className;
		} 
		if(document.getElementById('divSuggested')) {
			divs = document.getElementById('divSuggested').clientHeight;
			cnames = document.getElementById('divSuggested').className;
		}	
		re = new RegExp("ctrlhidden"); 
		if(cnamewl == "") {
			cname = cnames;
			divwl = divs;
		} else {
			if(re.test(cnamewl)) {
				cname = cnames;
				divwl = divs;
			} else {
				cname = cnamewl;
			}
		}
		if(cname == "divff") {
			t = t + 14;
		} else if(cname == "divie") {
			t = t + 24;
		}
		var mt = divwl + t;		
		document.getElementById("divBottomContent").style.height = mt+'px';	
		if(window.BrowserDetect) {
			if(BrowserDetect.browser == "Firefox" && BrowserDetect.version == 2) {
				resizenow('mpwfoot');
			}			
		}
	}
	resizeImage('pimg');
}

function resizenow (x) {
	var s= document.getElementById(x).style;
	s.display= "none";
	setTimeout(function () {
		s.display= "";
	},1);
}

function resizeImage(id) {
	clicked = 0;
	if(document.getElementById(id)) {
		maxWidth = 0;
		var cW = document.body.clientWidth;
		var cH = document.body.clientHeight;
		if(cW < 800) {
			maxWidth = 300;
		} 
		if(cW < 650) {
			maxWidth = 150;
		}
		if(maxWidth > 0) {
			document.getElementById(id).style.width = maxWidth + 'px';
			document.getElementById(id).onclick = function() {
				doImgClick(id)
			}
		}
	}
}

var clicked = 0;
function doImgClick(id) {
	if(clicked) {
		resizeImage(id);
	} else {
		clicked = 1;
		document.getElementById(id).style.width = '';
	}
}

function rst() {
	document.regsearch.elements['cr'].value = '';
	document.regsearch.elements['gr'].value = '';
	document.regsearch.elements['prl'].value = '';
	document.regsearch.elements['prh'].value = '';
	document.regsearch.elements['or'].value = '';
	document.regsearch.elements['si'].value = '';
	document.regsearch.elements['ys'].value = '';
	document.regsearch.elements['ye'].value = '';
	document.regsearch.elements['sw'].value = '';
	document.regsearch.elements['sl'].value = '';
}
function frameClick(obj,link) {
	setCookie('frck',obj,1);
	self.location = link;
}

function blinkIt() {
   var s = document.getElementById('messagehdr');
   s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
}

function jumpTo(pg) {
	if(pg != "") {
		window.location = pg;
	}
}

//-->