checkPassword = function(source, arguments) {
    arguments.IsValid = (arguments.Value.length > 5)
}

initRoundedCorners = function() {
    if (!NiftyCheck())
        return;
    /* here the calls to add Nifty Corners */
    if (document.getElementById("wineList")) {
        Rounded("#wineList li", "#f4dcb3", "#f6f1de");
    }

    if (document.getElementById("baginbox")) {
        Rounded("div#baginbox", "#f6f1de", "#d9d5bc");
    }

    if (document.getElementById("wijnenSub")) {
        Rounded("div#wijnenSub", "#f6f1de", "#d9d5bc");
    }

    if (document.getElementById("aanbieding")) {
        RoundedTop("div#aanbieding", "#f6f1de", "#e7e3cd");
        RoundedBottom("div#aanbieding", "#f6f1de", "#666633");
    }

    if (document.getElementById("overigeaanbiedingen")) {
        Rounded("div#overigeaanbiedingen", "#f6f1de", "#e7e3cd");
    }

    if (document.getElementById("actie")) {
        RoundedTop("div#actie", "#f4dcb3", "#4a0015");
        RoundedBottom("div#actie", "#f4dcb3", "#fcf5e8");
    }
}

initContentHeight = function() {
    if (document.getElementById("home")) {
        var obj1 = document.getElementById("content");
        var obj2 = document.getElementById("subContent");
        var oheight1 = YAHOO.util.Dom.getRegion(obj1).bottom - YAHOO.util.Dom.getRegion(obj1).top;
        var oheight2 = YAHOO.util.Dom.getRegion(obj2).bottom - YAHOO.util.Dom.getRegion(obj2).top;

        //console.debug(oheight1);
        //console.debug(oheight2);

        if (oheight2 > oheight1) {
            YAHOO.util.Dom.setStyle(obj1, "height", oheight2 + "px");
        } else {
            YAHOO.util.Dom.setStyle(obj2, "height", oheight1 + "px");
        }
    } else {
        if (document.getElementById("content") || document.getElementById("contentArticle")) {
            if (document.getElementById("content")) {
                var obj = document.getElementById("content");
            } else {
                var obj = document.getElementById("contentArticle");
            }
            var oheight = YAHOO.util.Dom.getRegion(obj);
            if (oheight.bottom - oheight.top < 400) {
                YAHOO.util.Dom.setStyle(obj, "height", "400px");
            }
        }
    }
}

initReplaceImages = function() {
	if(document.getElementById("flashImages")) {
		var root = document.getElementById("flashImages");
		var imagesToReplace = root.getElementsByTagName("IMG");
		for(var i=imagesToReplace.length-1; i >= 0; i--) {
			replaceImage(imagesToReplace[i]);
		}
	}
}

initReadOnlyCssClass = function() {
    var fields = document.getElementsByTagName("input")
    
	for(var i=fields.length-1; i >= 0; i--) {
	    field = fields[i];
		if(field.type == 'text' && field.readOnly)
		    field.className += ' readonly';
	}
}

replaceImage = function(img) {
	var imgSrc = img.src;
	var imgWidth = 100;
	var imgHeight = 100;
	var imgBorderColor = "0xFFFFFF";
	var imgBorderWidth = 6;
	var imgShadow = true;
	var imgRotate = 5;

	var imgRoot = img.parentNode;
	var flashContainer= document.createElement("SPAN");
	
	var flashElement = document.createElement("EMBED");
	flashElement.setAttribute("type","application/x-shockwave-flash");
	flashElement.setAttribute("src","/includes/swf/default.swf");
	flashElement.setAttribute("name","replacedImage");
	flashElement.setAttribute("width",imgWidth);
	flashElement.setAttribute("height",imgHeight);
	flashElement.setAttribute("wmode","transparent");
	flashElement.setAttribute("flashvars","src=" + imgSrc + "&border=" + imgBorderColor + "&borderwidth=" + imgBorderWidth + "&shadow=" + imgShadow + "&rotate=" + imgRotate);

	YAHOO.util.Dom.addClass(flashContainer,"flashImage");
	flashContainer.appendChild(flashElement);
	imgRoot.replaceChild(flashContainer,img);
}

initPage = function() {
	//console.debug("1");
	initRoundedCorners();
	//console.debug("2");
	initReplaceImages();
	//console.debug("3");
	initReadOnlyCssClass();
	//console.debug("4");
	initContentHeight();
	//console.debug("5");
}

//YAHOO.util.Event.addListener(window,"load",initContentHeight);
//YAHOO.util.Event.addListener(window,"load",initRoundedCorners);
//YAHOO.util.Event.addListener(window,"load",initReplaceImages);
//YAHOO.util.Event.addListener(window,"load",initReadOnlyCssClass);
YAHOO.util.Event.addListener(window,"load",initPage);