﻿// window.name = "opener";

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01 needed for the rollover
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0 show/hide the layers with the rollovertext
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}
// args: 1=Full brouwser functionalities, 0=Only scrollbars and resize handles
function NewWindow (URL,args){
if (args==1)
{
var xw,yw
xw=(screen.width/3)*2;
yw=(screen.height/3)*2;
window.open(URL, "", "height="+yw+",width="+xw+",scrollbars=1,resizable=1,location=1,menubar=1,status=1,toolbar=1");
}

else if (args==9)
{
var xw,yw, win1
xw=788;
yw=469;
win1 = window.open(URL, "", "height="+yw+",width="+xw+",scrollbars=1,resizable=1");
win1.moveTo((screen.width/2)-((xw/2)),(screen.height/2)-((yw/2)));
}
// SAgovic 2004-06-02
// implements change 0504-09 (JavaScript Link); dynamic windows features
else if (isNaN(args))
{
var arrWFeatures = args.split(",");
var intFeature = 0;
var winWidth  = arrWFeatures[0].substring(arrWFeatures[1].indexOf('='),arrWFeatures[0].length); 
var winHeight = arrWFeatures[1].substring(arrWFeatures[1].indexOf('=')+1,arrWFeatures[1].length); 		
var intLeft = (screen.width - winWidth)/2;
var intTop  = (screen.height - winHeight)/2 - 50;		
if(intLeft<0){intLeft=0;}
if(intTop<0){intTop=0;}
var strCenter  = ",left=" + intLeft + ",screenX=" + intLeft;
strCenter += ",top=" + intTop + ",screenY=" + intTop;
args += strCenter;
var winNew = window.open(URL, 'winNew', args);
winNew.focus()
// .moveto method causes an error: access denied
//winNew.moveTo((screen.width/2)-((winWidth/2)),(screen.height/2)-((winHeight/2)));
}

else
{
var xw,yw, win1
xw=(screen.width/3)*2;
yw=(screen.height/3)*2;
win1=window.open(URL, 'win2', "height="+yw+",width="+xw+",scrollbars=1,resizable=1");
win1.moveTo((screen.width/2)-((xw/2)),(screen.height/2)-((yw/2)));
}

return false;	}

// Add a QueryString to the action of a form and send the form
function AddQueryStringAndSubmit(name,value)
{
document.frmHiddenVariables.action = document.frmHiddenVariables.action+"?"+name+"="+value
}

// Set the value of a select menu
function SetOptionSelected(value, inp)
{
inp.value=value;
}
function swapbutton(imgsrc)
{
// shows layer
if (imgsrc.id=="btnselectup")
{
document.jump.btnselect.src = "/Images/13_24773.gif";
document.jump.btnselect.id = "btnselect"
document.all.list.style.visibility = "visible";
document.all.list.focus();
return;
}
// hide layer
else
{
document.jump.btnselect.src = "/Images/13_24772.gif";
document.jump.btnselect.id = "btnselectup"
document.all.list.style.visibility = "hidden";
document.jump.btnselect.focus();
}
}

// jumps to url of selection
function GoSelected(ref)
{
document.jump.country.value=ref.id;
document.jump.country.style.cssText= "background-color:#0A246A; color:#FFFFFF;border-color:#FFFFFF;border-style:solid";
document.jump.btnselect.src = "/Images/13_24772.gif";
document.jump.btnselect.id = "btnselectup"
document.all.list.style.visibility = "hidden";
document.location = ref.href
}

// hides the countrylist
function HideList()
{
document.jump.btnselect.src = "/Images/13_24772.gif";
document.jump.btnselect.id = "btnselectup";
document.all.list.style.visibility = "hidden";
}

function printPage() {
if (window.print) {
if(navigator.userAgent.toLowerCase().indexOf('mozilla') != -1)
{
if(navigator.userAgent.toLowerCase().indexOf('msie') !=-1)
{
// much better browser, so do nothing
}

else
{
if(parseInt(navigator.appVersion)>3 && parseInt(navigator.appVersion)<5)
{
alert('you are using nav4 so print format not supported');
}
}

}

window.print();
} else {
alert("Sorry, your browser doesn't support this feature.");
}
}

function frmCompareSubmit()
{
var frmCompare,elementcount,qs,c;
qs=''
c=0
elementcount = document.frmCompare.elements.length;
// define products to be compared

for(i=0;i<elementcount;i++)
{
if (document.frmCompare.elements[i].checked)
{
c++;
qs=qs+document.frmCompare.elements[i].value
}
}
if(c<4)
{
var xw,yw, win1
xw=788;
yw=469;
win1 = window.open('/for_home/compare_products/loadcomparator.asp?prod='+qs+'&lang=UK&country=CE&dir=/for_home/product_finder/cameras/digital/',"","height="+yw+",width="+xw+",scrollbars=1,resizable=1")
win1.moveTo((screen.width/2)-((xw/2)),(screen.height/2)-((yw/2)));

}
else
{
alert ("Please select up to three products.");
}
}

function count_change(fld,maxlen)
{

Msg = fld.value;
Msglen= Msg.length;

if (Msglen > maxlen+1 ){
fld.value=Msg.substring(0,maxlen);
maxmsg = 'Maximum number of characters for this field is x1';
alert(maxmsg.replace('x1',maxlen));
fld.focus();
}
}

ys = 0;
function scroll(n) {
	dpo_list.scrollBy(0, n);
	ys = setTimeout('scroll(' + n + ')',50);
}
