﻿function ChangeCountry()
{
    var DropdownListCountry = document.getElementById('ctl00_PageContent_ddlCountry');
    var DropdownListState = document.getElementById('ctl00_PageContent_ddlState');
    
    var SelectedIndex=DropdownListCountry.selectedIndex;
    var SelectedValue=DropdownListCountry.value;
    var SelectedText=DropdownListCountry.options[DropdownListCountry.selectedIndex].text;    
   
    if(SelectedValue == "New Zealand")
    {
       DropdownListState.selectedIndex=0;
       DropdownListState.setAttribute('disabled','disabled');
    }
    else
    {
        DropdownListState.selectedIndex=2;
        DropdownListState.removeAttribute('disabled');
    }
}




function PopUp(intID){
    if(intID!=''){
	    var winFeatures = "status=1,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=0,width=700,height=755";
	    mywindow = window.open ("/popup.aspx?id=" + intID,"winphoto",winFeatures);
    }

}

function ShowForgottenPw(){
    if(document.getElementById('ForgottenPasswordBox').style.display=='block'){
        document.getElementById('ForgottenPasswordBox').style.display='none'
    }else{
        document.getElementById('ForgottenPasswordBox').style.display='block'
    }
    

}

function ValidateProduct(objForm){
    if(isNaN(objForm.quantity.value)){
       document.getElementById('ProductError').style.display="block";
       document.getElementById('ProductError').innerHTML = "Please enter a valid quantity";
       return false;
    
    }

    return true;
    
    

}



var str="";
function initScroll(){

        var i=1;
		
		for (i=1;i<5;i++)
		{
			str = str + '<td>';
			str = str + '<div class="scrollPromoBox">';
			str = str + '<div class="scrollPicBox">';
			if (typeof galleryImages[i] == "undefined") {
				str = str + '<img src="/css/images/spacer.gif" />';
			}else{
				str = str + '<a href="'+galleryImages[i][1]+'" title="Click for details" ><img src="'+galleryImages[i][0]+'" /><br/><p><span>' + galleryImages[i][2] + '</span><br/>' + galleryImages[i][3] + '</p></a>';
			}
			str = str + '</div>';
			str = str + '</div>';
			str = str + '</td>';
		}

		if(galleryImages.length > 4)
		{
			var i = 5
			for (i=5;i<=galleryImages.length;i++)
			{
				str = str + '<td>';
				str = str + '<div class="scrollPromoBox">';
				str = str + '<div class="scrollPicBox">';
				if (typeof galleryImages[i] == "undefined") {
					str = str + '<img src="/images/empty.gif" />';
				}else{
					str = str + '<a href="'+galleryImages[i][1]+'" title="Click for details" ><img src="'+galleryImages[i][0]+'" /><br/><p><span>' + galleryImages[i][2] + '</span><br/>' + galleryImages[i][3] + '</p></a>';
				}
				str = str + '</div>';
				str = str + '</div>';
				str = str + '</td>';
			}
		}
}

// the slides - relative or complete urls for any number of swappable images

var slideIndex = 0; // which slide are we viewing?
var fadeTimer = 2; // time, in seconds, it takes to swap images
var swapTimer = 5; // time, in seconds, between image swaps

// gotta set it all up before we run it...
function initSwap(cnt) {
	// CAREFUL! we ASSUME there's a page element with id 'fadeBox' to 
	// contain the effected images
	//alert("HI")
	var fadeBox = document.getElementById('fadeBox');
	// set up the actual images
	for(var i=0;i<slides.length;i++) {
		// hooray for the DOM
		var slide = document.createElement('img'); // a new image
		slide.src = slides[i][0]; // should show this image
		//slide.useMap ='#homemap' + i
		slide.style.display = 'none';
		slide.style.position = 'absolute'; // important so images stay on top of each other
		slide.style.left = slides[i][1] + "px";
		slide.style.opacity = '0'; // init to transparent (CSS2)
		slide.style.filter = 'alpha(opacity:0)'; // init to transparent (MSIE)
		fadeBox.appendChild(slide); // put the image in the box
		//alert(slide.useMap)
		slides[i] = slide; // reassign to same array for convenience
		// if it's the first image, let's show it now to avoid waiting
		if(i==0 && cnt==1) { 
			fade(i,1); // fade it in!
		}else 
		{
			if(i==0)
			{
				fade(i,1); // fade it in!
				setTimeout(doSwap,swapTimer*1000); // start the swap timer!
			}
		}
		// repeat for each slide
	}
}

function doSwap() {
	var s1 = slideIndex; // where *are* we?
	var s2 = s1+1==slides.length?0:s1+1; // either the next or the first
	// we just wrapped to the beginning if we hit the end of the array, so...
	slideIndex = s2; // update slide index
	fade(s1,0); // fade the old slide out!
	fade(s2,1); // fade the new slide in!
	setTimeout(doSwap,swapTimer*1000); // do it again in swapTimer seconds!
}

function fade(whoid,dir) {
	var slide = slides[whoid]; // get the slide element at index whoid
	var completed; // so we know when the fade is done
	var opac = parseFloat(slide.style.opacity,10); // get a reference value
	// increment if fading in, decrement if fading out
	if(dir > 0) { 
		slide.style.display = 'block';
		opac += .1; // more opaque
		if(opac >= 1) {
			// fade is at max! fade done!
			completed = true;
		}
	} else {
		opac -= .1; // less opaque
		if(opac <= 0) {
			// fade is at min! fade done!
			slide.style.display = 'none';
			completed = true;
		}
	}
	slide.style.opacity = opac; // set opacity (CSS2)
	slide.style.filter = 'alpha(opacity:'+(opac*100)+')'; // set opacity (MSIE)
	if(!completed) {
		// as long as the fade is not complete, keep doing this in 1/10 increments within fadeTimer seconds
		setTimeout("fade("+whoid+","+dir+")",parseInt(fadeTimer/10,10));
	}
}

function SwapProductImage(pageImgURL,pageImgWidth,pageImgHeight,newTitle,largeImgURL){
    var objPageImg;
    var objLargeImgLink

    if (document.getElementById) {
        objPageImg = document.getElementById("ProdPageImg");
        objLargeImgLink = document.getElementById("ProdLargeImgLink");
        objText = document.getElementById("textImageEnlarge");
        
        objPageImg.src = pageImgURL;
        objPageImg.width = pageImgWidth;
        objPageImg.height = pageImgHeight;
        objText.innerHTML = newTitle;
        objLargeImgLink.href = largeImgURL;
        objLargeImgLink.title = newTitle;
    }
}

// the slides - relative or complete urls for any number of swappable images

var slideIndex = 0; // which slide are we viewing?
var fadeTimer = 2; // time, in seconds, it takes to swap images
var swapTimer = 5; // time, in seconds, between image swaps

// gotta set it all up before we run it...
function initSwap(cnt) {
	// CAREFUL! we ASSUME there's a page element with id 'fadeBox' to 
	// contain the effected images
	//alert("HI")
	var fadeBox = document.getElementById('fadeBox');
	// set up the actual images
	for(var i=0;i<slides.length;i++) {
		// hooray for the DOM
		var slide = document.createElement('img'); // a new image
		slide.src = slides[i][0]; // should show this image
		//slide.useMap ='#homemap' + i
		slide.style.display = 'none';
		slide.style.position = 'absolute'; // important so images stay on top of each other
		slide.style.left = slides[i][1] + "px";
		slide.style.top = slides[i][2] + "px";
		slide.style.opacity = '0'; // init to transparent (CSS2)
		slide.style.filter = 'alpha(opacity:0)'; // init to transparent (MSIE)
		fadeBox.appendChild(slide); // put the image in the box
		//alert(slide.useMap)
		slides[i] = slide; // reassign to same array for convenience
		// if it's the first image, let's show it now to avoid waiting
		if(i==0 && cnt==1) { 
			fade(i,1); // fade it in!
		}
		else
		{
			if(i==0)
			{
				fade(i,1); // fade it in!
				setTimeout(doSwap,swapTimer*1000); // start the swap timer!
			}
		}
		// repeat for each slide
	}
}

function doSwap() {
	var s1 = slideIndex; // where *are* we?
	var s2 = s1+1==slides.length?0:s1+1; // either the next or the first
	// we just wrapped to the beginning if we hit the end of the array, so...
	slideIndex = s2; // update slide index
	fade(s1,0); // fade the old slide out!
	fade(s2,1); // fade the new slide in!
	setTimeout(doSwap,swapTimer*1000); // do it again in swapTimer seconds!
}

function fade(whoid,dir) {
	var slide = slides[whoid]; // get the slide element at index whoid
	var completed; // so we know when the fade is done
	var opac = parseFloat(slide.style.opacity,10); // get a reference value
	// increment if fading in, decrement if fading out
	if(dir > 0) { 
		slide.style.display = 'block';
		opac += .1; // more opaque
		if(opac >= 1) {
			// fade is at max! fade done!
			completed = true;
		}
	} else {
		opac -= .1; // less opaque
		if(opac <= 0) {
			// fade is at min! fade done!
			slide.style.display = 'none';
			completed = true;
		}
	}
	slide.style.opacity = opac; // set opacity (CSS2)
	slide.style.filter = 'alpha(opacity:'+(opac*100)+')'; // set opacity (MSIE)
	if(!completed) {
		// as long as the fade is not complete, keep doing this in 1/10 increments within fadeTimer seconds
		setTimeout("fade("+whoid+","+dir+")",parseInt(fadeTimer/10,10));
	}
}