function onLoadInit() {
try {
    basketAlert();
} catch(err) {
}

try {
    feedbackAlert();
} catch(err) {
}

//Read and apply text-size cookie.
iceCookie('userpref', '|');
}

function openNewWindow(strURL, strName, intWidth, intHeight, intType) {
    var titleBarHeight, windowBorderWidth, screenWidth, screenHeight, windowWidth, windowHeight, left, top, blnScrollbars, blnResizable, blnOpenWithParms;

    titleBarHeight = 24;
    windowBorderWidth = 4;
    screenWidth = 800;
    screenHeight = 600;

    if (window.screen) {
	    if (window.screen.availWidth) {
		    screenWidth = window.screen.availWidth;
		    screenHeight = window.screen.availHeight;
	    }
    }

    windowWidth = windowBorderWidth + intWidth + windowBorderWidth;
    windowHeight = titleBarHeight + intHeight + windowBorderWidth;

    left = (screenWidth - windowWidth) / 2;
    top = (screenHeight - windowHeight) / 2;

    if (intType == 1) {
	    // No scrollbars, not resizable
	    blnScrollbars = 0;
	    blnResizable = 0;
	    blnOpenWithParms = 1;
    } else if (intType == 2) {
	    // Scrollbars, not resizable
	    blnScrollbars = 1;
	    blnResizable = 0;
	    blnOpenWithParms = 1;
    } else if (intType == 3) {
	    // No scrollbars, resizable
	    blnScrollbars = 0;
	    blnResizable = 1;
	    blnOpenWithParms = 1;
    } else if (intType == 4) {
	    // Normal window
	    blnOpenWithParms = 0;
	    strName = window.open(strURL, strName, 'left = ' + left + ', top = ' + top + ', screenX = ' + left + ', screenY = ' + top + ', width = ' + windowWidth + ', height = ' + windowHeight);
    } else {
	    // Normal window. Note: Size is being ignored!
	    blnOpenWithParms = 0;
	    strName = window.open(strURL, strName);
    }

    if (blnOpenWithParms == 1) {
	    strName = window.open(strURL, strName, 'left=' + left + ', top=' + top + ', screenX=' + left + ', screenY=' + top + ', width=' + windowWidth + ', height=' + windowHeight + ', scrollbars=' + blnScrollbars + ', resizable=' + blnResizable + ', toolbar=0, location=0, directories = 0, status = 0, menubar = 0, copyhistory = 0');
    }
    strName.focus();
}


/*-------------------------------------------------------------------------*/

var ImageProductCode="";
var OriginalWidth=270;

function LargeImage()
{
	if(arguments.length<2)
	{
		ImageProductCode=arguments[0].replace("&","%26");
		//if(navigator.appName.toLowerCase().indexOf("microsoft")>-1)
		//{
			var html="<img id=\"ProductImage\" src=\"ProductImage.aspx?pc="+ImageProductCode+"&w="+OriginalWidth+"\">";
			document.getElementById("DivLargeImagePlaceHolder").innerHTML=html;
			document.getElementById("DivLargeImage").style.visibility="visible";
			document.onclick=HideImage;
		//}
		//else
		//{
		//	window.open("LargeImage.aspx?productcode="+arguments[0].replace("&","%26"), "largeimage", 'resizable=yes,menubar=no,status=no,location=no,scrollbars=no,top=0,left=0,width=600,height=600');
		//}
	}
	else
	{
		var strName=arguments[0];
		var intWidth=arguments[1];
		var intHeight=arguments[2];
		var strURL=arguments[3];
		objRefWindow = window.open(strURL, strName, 'resizable=yes,menubar=no,status=no,location=no,scrollbars=yes,width=' + intWidth + ',height=' + intHeight);
	}

}

function HideImage()
{
	document.getElementById("DivLargeImage").style.visibility="hidden";
}


function ImageZoomIn()
{
	var img=document.getElementById(arguments[0]);

	if(img.width>1000)
	{
		alert("Image zoom level reached its maximum limit");
		return;
	}

	w=img.width+270;

	var html="<img id=\"ProductImage\" src=\"ProductImage.aspx?pc="+ImageProductCode+"&w="+w+"\">";
	document.getElementById("DivLargeImage").style.visibility="visible";
	document.getElementById("DivLargeImagePlaceHolder").innerHTML=html;

}

function ImageZoomOut()
{

	var img=document.getElementById(arguments[0]);

	if(img.width<271)
		return;

	w=img.width-270;

	var html="<img id=\"ProductImage\" src=\"ProductImage.aspx?pc="+ImageProductCode+"&w="+w+"\">";
	document.getElementById("DivLargeImage").style.visibility="visible";
	document.getElementById("DivLargeImagePlaceHolder").innerHTML=html;
}


function DisplayAgeAndVintagePage()
{
	var cmb=document.getElementById(arguments[0]);
	var Page=arguments[1];
	if(cmb.selectedIndex>0)
	{
		window.location.href=Page+"-"+cmb[cmb.selectedIndex].value+".aspx";
	}
}




function GenerateDefaultPageBanners()
{

	//"<a href=\""+siteURL+"D-428.aspx\" title=\"DIAGEO Special Releases Offer - 20% Off !!!\"><img src=\"site_data/thewhiskyexchange_com/images/gfxdSuper.gif\" width=\"189\" height=\"99\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",

	//"<a href=\"mailto:sss@thewhiskyexchange.com\" title=\"Wanted\"><img src=\"site_data/thewhiskyexchange_com/images/gfxWanted.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",

	//"<a href=\""+siteURL+"D-430.aspx\" title=\"Staff Favourites\"><img src=\"site_data/thewhiskyexchange_com/images/gfxTWEfavorites.jpg\" width=\"189\" height=\"120\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",

	//"<a href=\""+siteURL+"D-429.aspx\" title=\"Bin Ends\"><img src=\"site_data/thewhiskyexchange_com/images/gfxBinEnds.gif\" width=\"189\" height=\"82\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",

	//"<a href=\""+siteURL+"D-446.aspx\" title=\"Glenfarclas 'The Family Casks'\"><img src=\"site_data/thewhiskyexchange_com/images/gfxGlenfarclasFamily.gif\" width=\"189\" height=\"125\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>"

	//"<a href=\""+siteURL+"D-454.aspx\" title=\"Our Top 10 Whiskies of 2008\"><img src=\"site_data/thewhiskyexchange_com/images/gfxTop10.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",

	//"<a href=\""+siteURL+"D-468.aspx\" title=\"Our Top 10 Deals For Christmas 2008\"><img src=\"site_data/thewhiskyexchange_com/images/gfxDealsTop10.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 1px #666666;border-bottom: solid 1px #666666; border-left: solid 1px #666666;\" /></a>",





	var siteURL="http://www.thewhiskyexchange.com/";
	siteURL="";

	var displayarr = new Array

		(
			"<a href=\""+siteURL+"F-40-Port_Askaig.aspx\" title=\"Port Askaig - Single Islay Malt Scotch Whisky Range\"><img src=\"site_data/thewhiskyexchange_com/images/gfxPa-imgr.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"LostDistilleries.aspx\" title=\"The Lost Distilleries of Scotland\"><img src=\"site_data/thewhiskyexchange_com/images/gfxLost.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"D-429.aspx\" title=\"Bin Ends\"><img src=\"site_data/thewhiskyexchange_com/images/gfxBinEnds.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"G-460.aspx\" title=\"Elements of Islay\"><img src=\"site_data/thewhiskyexchange_com/images/gfxElements.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"Luxury.aspx\" title=\"Our Luxury Collection has the world\'s rarest and most expensive single malt whiskies, from Black Bowmore to a Macallan 1928\"><img src=\"site_data/thewhiskyexchange_com/images/gfxLuxury.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"D-404.aspx\" title=\"Exclusive Single Malts\"><img src=\"site_data/thewhiskyexchange_com/images/gfxExclusiveToUs.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"D-480.aspx\" title=\"World Whisky Awards 2010\"><img src=\"site_data/thewhiskyexchange_com/images/gfxWWA2010.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"selection/the_dalmore_candela_50_yo_whisky.aspx\" title=\"THE DALMORE 50 Year old - Candela\"><img src=\"site_data/thewhiskyexchange_com/images/gfxCandela.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",
			
			"<a href=\""+siteURL+"P-5016.aspx\" title=\"Monkey Shoulder Poker Offer\"><img src=\"site_data/thewhiskyexchange_com/images/gfxPoker.jpg\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>",

			"<a href=\""+siteURL+"G-492.aspx\" title=\"10th Anniversary Bottlings\"><img src=\"site_data/thewhiskyexchange_com/images/gfx10ann.gif\" width=\"189\" style=\"border-right:0px;border-top: solid 0px #666666;border-bottom: solid 0px #666666; border-left: solid 0px #666666;\" /></a>"


		)

	displayarr=RandomizeArray(displayarr);

	var j=8;
	if(displayarr.length<8)
		j=displayarr.length

	for(i=0;i<j;i++)
	{
		document.write(displayarr[i]+"<div style=\"height:10px\"></div>");
	}
}

function RandomizeArray( myArray )
{
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i )
  {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
  }
  return myArray;
}

function LimitInputChars()
{
	var ObjTextBox=arguments[0];
	var ObjLimitBox=arguments[1];
	var MaxChars= parseInt(arguments[2]);

	if(ObjTextBox.value.length>MaxChars)
		ObjTextBox.value=ObjTextBox.value.substr(0,MaxChars);

	var RemainChars=MaxChars-ObjTextBox.value.length;

	ObjLimitBox.value=RemainChars+" chars remaining";
}