//=================================================================
//  EasyBOW(tm), Copyright 2005-2008, All rights reserved.
//  Container for site wide DHTML scripts
//=================================================================

function showBlock(theBlock){
	if(document.getElementById(theBlock).style.display=='block'){
		document.getElementById(theBlock).style.display='none';
		document.getElementById(theBlock + "_img").style.display='none';
	}else{
		document.getElementById(theBlock).style.display='block';
		document.getElementById(theBlock + "_img").style.display='block';
	}
}



var viewside = "fileOcean.jpg"

function flip_img(imgName) {
	if (viewside == "fileOcean.jpg") {
		viewside = "fo_back.jpg";
	} else {
		viewside = "fileOcean.jpg";
	}
	Rollover=new Image();
	Rollover.src = '/browser/images/' + viewside;
	document [imgName].src = Rollover.src
}

function popview(scrnshot){
	var Popuppref = 'screenX=380,screenY=20,left=380,top=20,width=620,height=1200,scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable';
    window.open('/browser/popview.php?scrnshot=' +scrnshot + '.gif', scrnshot, Popuppref);
}

function popphoto(shot){
	var Popuppref = 'screenX=100,screenY=70,left=100,top=70,width=830,height=560,scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable';
    window.open('/browser/popview.php?scrnshot=' +shot + '.jpg', 'shot', Popuppref);
}

function popwmv(){
	var Popuppref = 'screenX=470,screenY=220,left=470,top=220,width=360,height=330,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable';
    window.open('/browser/popwmv.html', 'wmv', Popuppref);
}

function urlswitch(gotourl) {
     	if (gotourl!="--") {
		document.location.href = gotourl;
	}
}

function frame_buster() {
	if (parent.frames.length > 0) {
	    parent.location.href = self.document.location
	}
}

function addEngine() {
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		window.sidebar.addSearchEngine(
		  "http://www.easybow.nl/extra/searchplugins/fileocean.src",
		  "http://www.easybow.nl/extra/searchplugins/fileocean.gif",
		  "fileOcean Search", 
		  "Documents");
		alert("fileOcean_Document_Search now installed in you Firefox_Search_Bar.\nReady to search all fileOcean documents directly from your browser.");
	}
	else {
		alert("Sorry, you need Mozilla (version M15 or later) or Firefox to add a searchroll to your browser.");
	}
}

function SubmitCheck(thisfrm) {
	if (verify(thisfrm) == true) {
		return true;
	}
	else return false;
}


function isblank(s){
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}
function verify(f){
    var msg;
    var empty_fields = "";
    var errors = "";

    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea") || (e.type == "select-one")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) {
                var v = parseFloat(e.value);
                if (isNaN(v) ||
                    ((e.min != null) && (v < e.min)) ||
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null)
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null)
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
        else if ((e.type == "checkbox") && !e.optional) {
        	if (e.checked == false) {
				empty_fields += "\n          " + e.name;
				continue;
			}
        }
    }

    if (!empty_fields && !errors) return true;

    msg  = "__________________________________________________\n\n"
    msg += " Om uw bestelling in behandeling te nemen hebben \n";
    msg += " we nog de onderstaande gevens van u nodig.\n";
    msg += "__________________________________________________\n\n"

    if (empty_fields) {
        msg += "- De onderstaande velden zijn nog leeg:"
                + empty_fields + "\n";
        if (errors) msg += "\n\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

function GetCookie(name) {
//========================================================================
//  Purpose:    Simple GetCookie function
//========================================================================

    // === read the cookie property ===
    var allcookies = document.cookie;
    var pos = allcookies.indexOf(name + "=");

    if (pos != -1) {
        var start = pos + name.length +1;
        var end = allcookies.indexOf(";", start);
        if (end == -1) end = allcookies.length;
        var cookievalue = allcookies.substring(start, end);
        return unescape(cookievalue);
    }
    else
        return "";
}

function SetCookie(name,cookieval,expire,path,domain,secure) {
//========================================================================
//  Purpose:    Write cookieval (name=value) into cookie
//========================================================================


    // === Now that we have the value of the cookie, put together the complete cookie string
    var cookie = name + '=' + escape(cookieval);
    if (expire != null)
        cookie += '; expires=' + expire.toGMTString();
    else {
        // === if not supplied, assume one year ===
        var nextyear = new Date();
        nextyear.setFullYear(nextyear.getFullYear() +1);
        cookie += '; expires=' + nextyear.toGMTString();
    }
    if (path != null)
        cookie += '; path=' + path;
    else
        // === if not supplied, assume for whole site ====
        cookie += '; path=/';
    if (domain != null) cookie += '; domain=' + domain;
    if (secure != null) cookie += '; secure';

    // === Now store the cookie by setting the magic Document.cookie property ===
    document.cookie = cookie;
}

function onthoudMij(mypath) {
//========================================================================
//  Purpose:    Waardes voor gebruiker onthouden
//========================================================================

	var strCookieName, strCookieVal;
	var iFormsCount = 0;
	var iElementsCount = 0;
	for(iFormsCount=0;iFormsCount < document.forms.length;iFormsCount++) {
		for(iElementsCount=0; iElementsCount < document.forms[iFormsCount].elements.length; iElementsCount++) {
			if (document.forms[iFormsCount].elements[iElementsCount].type == "text") {
				if (document.forms['klantcontact'].onthouden.checked != true) {
					strCookieVal = "";
				} else {
					strCookieVal = document.forms[iFormsCount].elements[iElementsCount].value;
				}
				strCookieName = document.forms[iFormsCount].elements[iElementsCount].name;
				SetCookie(strCookieName, strCookieVal, null, mypath);
			}
		}
	}
	if (document.forms['klantcontact'].onthouden.checked == true) {
		SetCookie("onthouden", "true", null, mypath);
	} else {
		SetCookie("onthouden", "", null, mypath);
	}
	return true;
}


function prefillFields() {
//========================================================================
//  Purpose:    Prefill input fields
//========================================================================
	var strCookieName, strCookieVal;
	var iFormsCount = 0;
	var iElementsCount = 0;
	for(iFormsCount=0;iFormsCount < document.forms.length;iFormsCount++) {
		for(iElementsCount=0; iElementsCount < document.forms[iFormsCount].elements.length; iElementsCount++) {
			strCookieName = document.forms[iFormsCount].elements[iElementsCount].name;
			strCookieVal = GetCookie(strCookieName);
			//if (strCookieVal != null && !(isNaN(strCookieVal)) && strCookieVal != '') {
			if (strCookieVal != null && strCookieVal != '') {
				//document.forms[iFormsCount].elements[iElementsCount].selectedIndex = strCookieVal;
				if (document.forms[iFormsCount].elements[iElementsCount].type == "text") {
					document.forms[iFormsCount].elements[iElementsCount].value = strCookieVal;
			 	}
				if (document.forms[iFormsCount].elements[iElementsCount].type == "checkbox") {
					document.forms[iFormsCount].elements[iElementsCount].checked = strCookieVal;
			 	}
			 	
		  	}
	   }
	}	   
}




