if (document.images) {

  var BlackArrow = new Image();
  BlackArrow.src = "/inl/images/nav/section_arrow_000.gif";

  var WhiteArrow = new Image();
  WhiteArrow.src = "/inl/images/nav/section_arrow_fff.gif";

  var subMenuArrowBlack = new Image();
  //subMenuArrowBlack.src = "/inl/images/nav/sub_sec_arrow_000.gif";
  subMenuArrowBlack.src = "/inl/images/nav/section_arrow_000.gif";

  var subMenuArrowWhite = new Image();
  //subMenuArrowWhite.src = "/inl/images/nav/sub_sec_arrow_fff.gif";
  subMenuArrowWhite.src = "/inl/images/nav/section_arrow_fff.gif";

  var NullImage = new Image();
  NullImage.src = "/inl/images/null.gif";

}


// included to allow editors to open popup videos from anywhere in the site
// this is an exact copy of videoPopup, which is in the video section
// renamed so the two functions don't clash

function vPopup(url, has_ad) {

	var swidth   = 790;
	var sheight  = 450;
	var adheight = 120;

	if ( has_ad	== 1 ) {
		sheight = sheight + adheight;
	}

	newwindow = window.open(url, 'stuffvideoplayer', 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width=' + swidth + ',height=' + sheight + ',left = 100,top = 100');
	if (window.focus) {newwindow.focus()}

}

function galleryPopup(url, has_ad) {

	var swidth   = 785;
	var sheight  = 560;
	var adheight = 120;

	var sLeft    = 100;
	var sTop     = 100;

	var sScroll  = 0;

	if ( screen.height <= 800 ) {
		sTop     = 0;
	}

	if ( screen.height <= 600 ) {
		sLeft    = 0;
		sTop     = 0;
		sScroll  = 1;
	}

	if ( has_ad	== 1 ) {
		sheight = sheight + adheight;
	}

	newwindow = window.open(url, 'stuffphotoslideshow', 'toolbar=0,scrollbars=' + sScroll + ',location=0,status=0,menubar=0,resizable=0,width=' + swidth + ',height=' + sheight + ',left = ' + sLeft + ',top = ' + sTop);
	if (window.focus) {newwindow.focus()}

}

function ImageOn (imgName, lightbg, submenu) {

    if ( submenu ) {
         whiteArrow = "subMenuArrowWhite.src";
         blackArrow = "subMenuArrowBlack.src";
    } else {
         whiteArrow = "WhiteArrow.src";
         blackArrow = "BlackArrow.scr";

    }

    if ( lightbg ) {
       document.images[imgName].src = eval( whiteArrow );
    } else {
        document.images[imgName].src = eval( blackArrow );
    }
}


function ImageOff(imgName) {
  if (document.images)
    document.images[imgName].src = eval("NullImage.src");
}



function  createWindow ( thisWindowName, thisURL, thisWidth, thisHeight,  resize, loc, scroll,status,toolbar ) {
    var URL = thisURL;

    var windowName = thisWindowName;

    var features =
        'width='        + thisWidth +
        ',height='      + thisHeight +
        ',location='    + loc +
        ',scrollbars='  + scroll +
        ',status='      + status +
        ',toolbar='     + toolbar +
        ',resizable='   + resize;

    window.open (URL, windowName, features);
}

function OpenWindow ( winname, url, width, height, resize ) {
   createWindow ( winname, url, width, height,  resize, 'no', 'no','no','no')
}


function submitPageForm(name) {

    var  theForm = document.forms[0];

    var  SubRates       = theForm.fm_SubRates;
    var  DeliveryName   = theForm.fm_UserMainName;
    var  Address1       = theForm.fm_UserMainAddress1;
    var  Address2       = theForm.fm_UserMainAddress2;
    var  Address3       = theForm.fm_UserMainAddress3;
    var  Town           = theForm.fm_UserMainTown;
    var  City           = theForm.fm_UserMainCity;
    var  pcode          = theForm.fm_UserMainPostalCode;

    if (name == "fm_Subscription")
     {
        document.forms[0].goType.value = "SUBSCRIPTION";

        if ( !SubRates.checked) {
             alert("Subscription Rates is required. Please select a subscription rates.");
             return false
        }

        if ( DeliveryName.value == "" ) {
            alert("Name for delivery address is required. Please enter name for delivery address.");
            DeliveryName.focus()
            return false
        }

        if ( (Address1.value == "") && (Address2 == "") && (Address3 == "") ) {
            alert("Address is required for delivery address. Please enter address for delivery address.");
            Address1.focus();
            return false
        }


        //if all is well

        document.forms[0].submit();
    } else {




    

    document.forms[0].goType.value = name;

    if(name == "tvDayGo" || name == "channelGo" ) {
    ;
    } else {
    //sregion = document.forms[0].search_region_select.selectedIndex;
    }
    //if(name == "search_go" &&  sregion == 0) {
    //  alert("please select a region to search");
    //} else {
    //  document.forms[0].submit();
    //}
    
    if ( name == "search_go" )
    {
        sText = document.forms[0].search_text.value;
        if ( sText.length < 3 || sText == ""){
            alert("Please enter at least 3 characters");
        } else {
        document.forms[0].submit();
        }
    } else
    if ( name == "stock_search_go" )
     {
            sText = document.forms[0].stock_search.value;
            if ( sText.length < 3 || sText == ""){
                alert("Please enter at least 3 characters");
            } else {
            document.forms[0].submit();
            }
        }
        else {
            document.forms[0].submit();
        }
    }
}

function popupWindow(url, pWidth, pHeight) {

	if ( ! pWidth ) {
			pWidth = 640;
	}

	if ( ! pHeight ) {
		pHeight = 480;
	}

	popupwindow = window.open(url,'name','width=' + pWidth + ',height=' + pHeight + ',left = 100,top = 100');

	if (window.focus) {popupwindow.focus()}


}

function featurePopup(url, pWidth, pHeight) {

	if ( ! pWidth ) {
			pWidth = 640;
	}

	if ( ! pHeight ) {
		pHeight = 480;
	}

	popupwindow = window.open(url,'name','width=' + pWidth + ',height=' + pHeight + ',left = 100,top = 100,resizable=1');

	if (window.focus) {popupwindow.focus()}

	return false;

}

function auth_stockguru () {

	var f;

	hide_stockguru_errors();

	if ( document.forms.frm_stockguru.nickname.value == "" ) {
		document.getElementById('sg_error_nickname').style.display = 'block';
		f = 1;
	}

	if ( document.forms.frm_stockguru.password.value == "" ) {
		document.getElementById('sg_error_password').style.display = 'block';
		f = 1;
	}

	if ( document.forms.frm_stockguru.password.value != document.forms.frm_stockguru.passwordConfirm.value ) {
		document.getElementById('sg_error_password_match').style.display = 'block';
		f = 1;
	}

	if ( document.forms.frm_stockguru.firstName.value == "" ) {
		document.getElementById('sg_error_firstName').style.display = 'block';
		f = 1;
	}

	if ( document.forms.frm_stockguru.lastName.value == "" ) {
		document.getElementById('sg_error_lastName').style.display = 'block';
		f = 1;
	}

	if ( document.forms.frm_stockguru.email.value == "" ) {
		document.getElementById('sg_error_email').style.display = 'block';
		f = 1;
	} else {
		if ( ! isEmail(document.forms.frm_stockguru.email.value) ) {
			document.getElementById('sg_error_email2').style.display = 'block';
			f = 1;
		}
	}

	if ( f != 1 ) {
		toggle_stockguru_loadlayer('on');
		var timer = setTimeout("document.forms.frm_stockguru.submit();", 2000);
	}

}

function hide_stockguru_errors () {
	document.getElementById('sg_error_nickname').style.display = 'none';
	document.getElementById('sg_error_password').style.display = 'none';
	document.getElementById('sg_error_password_match').style.display = 'none';
	document.getElementById('sg_error_firstName').style.display = 'none';
	document.getElementById('sg_error_lastName').style.display = 'none';
	document.getElementById('sg_error_email').style.display = 'none';
	document.getElementById('sg_error_email2').style.display = 'none';
}

function toggle_stockguru_loadlayer (setTo) {

	if ( setTo == 'on' ) {
		document.getElementById('sg_info_layer').style.display = 'none';
		document.getElementById('sg_loading_layer').style.display = 'block';
	} else {
		document.getElementById('sg_loading_layer').style.display = 'none';
		document.getElementById('sg_info_layer').style.display = 'block';
	}
}



