// SIGN UP FIELD BORDER

	function brdron(obj){
		obj.style.background = '#f2f2f2';
		}
	function brdroff(obj){
		obj.style.background = '#e5e5e5';
		}

// HOME CHANGE HOVER

	//SELECTS STRING TO BUILD FILENAME FOR MOUSEOVER

	var whatpage = '';
	var lastSelected = 'MainProductImg4';
	var lastView = '';
	var bodyloaded = 'false';

	function ldclr(intID){
		if(!(window.document.getElementById('homepage') || window.document.getElementById('homepagecity') || window.document.getElementById('homepagewintersun'))){
		    lastView = 'product-' + intID + '-0-0';whatpage = 'prod';
			}			
		    bodyloaded = 'true';
		    if(window.document.getElementById('productpage')){
		        window.document.getElementById('productpage').style.display = 'block';
		    }
		}

	//ONMOUSEOVER
	
    //LANDING PAGE IMAGE SWAP

	function imgSwp(obj,fname){
	    if (fname == "-on"){
            document.getElementById('city-collection').src = 'cms/assets/city-collection-off.jpg';
            document.getElementById('winter-sun').src = 'cms/assets/winter-sun-off.jpg';
            document.getElementById('summer-brights').src = 'cms/assets/summer-brights-off.jpg';
            document.getElementById('little-fins').src = 'cms/assets/little-fins-off.jpg';        
            obj.src = 'cms/assets/' + obj.id + fname + '.jpg';
        }
        else{
            document.getElementById('city-collection').src = 'cms/assets/city-collection-on.jpg';
            document.getElementById('winter-sun').src = 'cms/assets/winter-sun-on.jpg';
            document.getElementById('summer-brights').src = 'cms/assets/summer-brights-on.jpg';
            document.getElementById('little-fins').src = 'cms/assets/little-fins-on.jpg';            
        }    
        
	}


	function changepic(clr){		    
		if(whatpage == 'prod'){
			productSIDE(clr);
			}else{
			//HOME ONLY						
			window.document.getElementById('mainimg').src = 'assets/img/homepage/' + clr +'.jpg';
			}
		}
		//HOVER CHANGE FOR PRODUCT VIEW ICONS
    var currImage;
    function changeLandingImage(clr) {
        currImage = document.getElementById('mainimg').src;
        document.getElementById('mainimg').src = 'assets/img/homepage/' + clr + '.jpg';
    }
    function restoreLandingImage(clr) {
        document.getElementById('mainimg').src = currImg
    }
	

		function productSIDE2(clr){
			//HOVER MAIN PIC
			window.document.getElementById('mainimg').src = 'assets/img/products/Fins-Shoe-' + clr + lastView + '.jpg';
			//HOVER SIDE ICON
			window.document.getElementById('viewicon' + lastView).src = 'assets/img/products/S_TMB-' + clr + lastView + '.gif';
			}

		function productSIDE(clr){
		    
		    var leftnum = 0;
		    //alert(clr)
		    if (clr.length != 0){
		        
		        window.document.getElementById('mainimg').src = 'assets/img/products/' + clr + '.jpg';
			    //ICONS
			    if (clr.length == 13){
			        leftnum = 9;
			    }else{
			        leftnum = 10;
			    }
			    //window.document.getElementById('icontext').value = clr;
			    window.document.getElementById('viewicon0').src = 'assets/img/products/' + Left(clr, leftnum) + '-0-0-tn.jpg';
			    window.document.getElementById('viewicon1').src = 'assets/img/products/' + Left(clr, leftnum) + '-0-1-tn.jpg';
			    window.document.getElementById('viewicon2').src = 'assets/img/products/' + Left(clr, leftnum) + '-0-2-tn.jpg';
			    window.document.getElementById('viewicon3').src = 'assets/img/products/' + Left(clr, leftnum) + '-0-3-tn.jpg';
			    }
			}

	//ONCLICK

	function slct(sclr){
	    //alert('slct: ' + lastView)
		//window.document.getElementById(lastSelected).style.borderColor = '#fff';
		//window.document.getElementById(sclr).style.borderColor = '#000';
		if(whatpage == 'prod'){
			productSIDE(sclr);//was clr
			}
		lastSelected = sclr;
		}
	

	//ON MOUSEOUT

	function slctlst(){
	    //alert('slctlst: ' + lastView)
		if(whatpage != 'prod'){
			window.document.getElementById('mainimg').src = 'assets/img/homepage/' + lastSelected + '.jpg';
			}else{
			    if(bodyloaded == 'true'){
			        productSIDE(lastView);
			    }
			}
		}

	//CLICK FOR VIEW ICONS
	function Left(str, n){
	    if (n <= 0)
	        return "";
	    else if (n > String(str).length)
	        return str;
	    else
	        return String(str).substring(0,n);
    }
    
	function Right(str, n){
        if (n <= 0)
           return "";
        else if (n > String(str).length)
           return str;
        else {
           var iLen = String(str).length;
           return String(str).substring(iLen, iLen - n);
        }
    }


	function viewType(obj,viewr){
	    //alert('viewType: ' + lastView)
	    if (document.getElementById(lastView)) { 
		    window.document.getElementById(lastView).style.borderColor = '#fff';
		}
		obj.style.borderColor = '#000';
        
		window.document.getElementById('mainimg').src = 'assets/img/products/' + viewr + '.jpg';

		lastView = viewr;
		//lastIcon = 
		}
	

	var pageLoadTime = new Date(); // this variable is used to compare to the time that people hover over sample images, to prevent the sample changing if the mouse is over a sample graphic when the page loads
	function viewTypeColour(viewr){
        //alert('viewTypeColour: ' + viewr + ' - lastView: ' + lastView)
        if(new Date(new Date() - 2000) > new Date(pageLoadTime)) {
			window.document.getElementById('mainimg').src = 'assets/img/products/product-' + viewr + Right(lastView, 4) + '.jpg';
			window.document.getElementById('viewicon0').src = 'assets/img/products/product-' + viewr + Left(Right(lastView, 4), 3) + '0-tn.jpg';
			window.document.getElementById('viewicon1').src = 'assets/img/products/product-' + viewr + Left(Right(lastView, 4), 3) + '1-tn.jpg';
			window.document.getElementById('viewicon2').src = 'assets/img/products/product-' + viewr + Left(Right(lastView, 4), 3) + '2-tn.jpg';
			window.document.getElementById('viewicon3').src = 'assets/img/products/product-' + viewr + Left(Right(lastView, 4), 3) + '3-tn.jpg';
		}
		//lastView = viewr;
		//lastView = 'product-' + viewr + Right(lastView, 4)
		//lastIcon = 
	}
		
	
    function setproduct(){
        //alert(lastSelected)
        window.document.getElementById('mainproduct').value = lastSelected;
        window.document.getElementById('frmHomeAddToBasket').submit();
    }

    function viewproduct(){
        //alert(lastSelected)
        window.document.getElementById('homeproduct').value = lastSelected;
        window.document.getElementById('frmHomeProduct').submit();
    }

    function viewproductcity(){
        //alert(lastSelected)
        window.document.getElementById('frmHomeProduct').submit();
    }
    
    
//==============================MOVING ICONS======

	var scrollspd = 30;		//rate of function loop in milisecs
	var curpos = 0;		//style.left
	var pixtomove = 5;		//increments to move element from rst()
	var sc = '';		//var to permit loop
	var jumpdis = 200;		//jump distance in px
	var maxR = 0;		//stop scrolling first item  to the right
	var maxL = -1400;		//stop scrolling last one off screen - MUST be #iconsdiv width - 700-ish

	function scrollR(){	//HOVER RIGHT

		if(sc == 'Y' && curpos < maxR){
			curpos = curpos + pixtomove;
			window.document.getElementById('iconsdiv').style.left = curpos + 'px';
			setTimeout(scrollR,scrollspd);
			//readout();
			}
		}
	function scrollL(){	//HOVER LEFT
		if(sc == 'Y' && curpos > maxL){
			curpos = curpos - pixtomove;
			window.document.getElementById('iconsdiv').style.left = curpos + 'px';
			setTimeout(scrollL,scrollspd);remL()
			//readout();
			}
		}

	function jumpR(){	//JUMP LEFT

		if(curpos < maxR - jumpdis){

			window.document.getElementById('iconsdiv').style.left = curpos + jumpdis + 'px';

			curpos = curpos + jumpdis;

			}else{

			window.document.getElementById('iconsdiv').style.left = maxR + 'px';

			}
		//readout();
		}
	function jumpL(){	//JUMP LEFT

		if(curpos > maxL + jumpdis){

			window.document.getElementById('iconsdiv').style.left = curpos - jumpdis + 'px';

			curpos = curpos - jumpdis;

			}else{

			window.document.getElementById('iconsdiv').style.left = maxL + 'px';

			}
		//readout();
		}

	function remL(){pixelsleft = maxL - curpos;}

	// READOUT FOR DEBUGGING==============================

	function readout(){window.document.getElementById('sreadout').innerHTML = 'curpos: ' + curpos + ', maxleft:' + maxL + ', pixelsleft:' + pixelsleft;}

//==============================END MOVING ICONS===

    function getCollection(_targetPage, _existingPage) {
        // If it's the same page as before, there's no 
        // need to reload it
        if (_targetPage != _existingPage) {
            switch(_targetPage) {
                case 'george-loafer':
                    window.document.location = _targetPage + '.asp';
                    break;
                case 'reggie-leather':
                    window.document.location = _targetPage + '.asp';
                    break;
                case 'marshall':
                    window.document.location = _targetPage + '.asp';
                    break;
                case 'billamberg':
                    window.document.location = _targetPage + '.asp';
                    break;
                case 'amalfi':
                    window.document.location = _targetPage + '.asp';
                    break;                                                           
            }
        }
    }
    