// JScript File

// Call the args_init () function to set up the args [] array:
var args;
args_init();

var stylesheet;
var orgid;
var pagid;
var url = window.location.host.toLowerCase();

function createMenuItem(itemtype, itemcontent, itemid, menuid, orgcatid, intro)
	{
		var menu="";
		if (itemtype==5)
		{
			menu = menu + "</div><div id=hoofdmenu_" + itemid + " class=hoofdmenuItem onclick=\"toggleSubmenu('submenu_" + itemid + "');\"  >";
			menu = menu + "<table cellspacing=0 border=0 style=\"cursor:pointer; padding-left:12px; border-bottom:solid 1px #fff;\"><tr><td style=\" padding-left:10px;\"><img src=\"images/icmwebsites/menubutton" + orgcatid + ".jpg\" border=0 hspace=3></img></td><td align=\"left\" width=\" 100%\"><strong>" + itemcontent +"</strong></td></tr></table></div>";
			menu = menu + "<div id=submenu_" + itemid + " class=submenuBlok style=\"display:none; visibility:visible; position:relative;\">";
		} else
		{
			menu = menu + "<table cellpadding=1px cellspacing=0 border=0 width=100%>";
			if ((intro != null) && (intro != "")) {
				menu = menu + "<tr><td class=\"uitklap\" onclick=\"DCMGetObject(5, '@ContId=" + itemid + "'); DCMGetObject(23, '@ContID=" + itemid + "'); \" ><li>" + itemcontent + "</li></td></tr></table>";
			} else {
				menu = menu + "<tr><td class=\"uitklap\" onclick=\"DCMGetObject(5, '@ContId=" + itemid + "'); DCMGetObject(32, '@ContID=" + itemid + "'); \" ><li>" + itemcontent + "</li></td></tr></table>";
			}

		}
		document.write(menu);
		return (true);
	}
	
function createshopmenu(itemtype, itemcontent, itemid, menuid, orgcatid, intro)
	{
		var menu="";
		if (itemtype==5)
		{
			menu = menu + "</div><div id=hoofdmenu_" + itemid + " class=hoofdmenuItem onclick=\"toggleSubmenu('submenu_" + itemid + "');\"  >";
			menu = menu + "<table cellpadding=0 cellspacing=0 border=0 style=\"cursor:pointer; border-bottom:solid 1px #fff;\"><tr><td><img src=\"images/icmwebsites/menubutton" + orgcatid + ".jpg\" border=0 hspace=3></img></td><td align=\"left\" width=\" 100%\"><strong>" + itemcontent +"</strong></td></tr></table></div>";
			menu = menu + "<div id=submenu_" + itemid + " class=submenuBlok style=\"display:none; visibility:visible; position:relative;\">";
		} else
		{
			menu = menu + "<table cellpadding=5 cellspacing=0 border=0 width=100%style=\"margin-left:25px; border-bottom:solid 1px #fff;\">";
			if ((intro != null) && (intro != "")) {
				menu = menu + "<tr><td class=\"uitklap\" onclick=\"getObjectById('frmShop').src='/include/icmwebsites/shopscripts/shop.asp?fd=verk&itm=shop&cat=" + intro + "';\" >" + itemcontent + "</td></tr></table>";
			} else {
				menu = menu + "<tr><td class=\"uitklap\" onClick=\"getObjectById('frmShop').src='/include/icmwebsites/shopscripts/shop.asp?fd=verk&itm=shop&cat=GEH_DIMM';\">" + itemcontent + "</td></tr></table>";
			}

		}
		document.write(menu);
		return (true);
	}

function toggleSubmenu(submenuitem)
	{
		var o = document.getElementById("menuitems").childNodes;

		for (var i = 0; i < o.length; i++)
		{
				  var divname = o[i].id; 
     			  if(divname.indexOf("submenu") == 0)   	
  				  { 
       				document.getElementById(divname).style.display = "none";
                  }
	    }	
	
		if (document.getElementById(submenuitem).style.display == "none")
		{
			document.getElementById(submenuitem).style.display = "block";
		} else
		{
			document.getElementById(submenuitem).style.display = "none";
		}
		
	}

function hideObject(objs)
	{
		if (objs != null)
		{
			var obj = objs.split(",");
			for (var i=0; i<obj.length; i++)
			{
				if (document.getElementById(obj[i]) != null)
				{
					document.getElementById(obj[i]).style.visibility = 'hidden';
				}
			}
		}
	}
	
function initPage(home)
{
    switch (url)
    {
        case "www.vosautomatisering.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
            
        case "www.vosautomatisering.com":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
            
        case "www.vos-electronics.com":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
        
        case "www.vos-electronics.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
        
        case "www.voselectronics.com":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
        
        case "voselectronics.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
        
        case "www.voshosting.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 2;	        
            break;
        
        case "www.icmperformance.nl":
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;	        
            break;
        
        case "www.icmsolution.nl":
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;	        
            break;
        
        case "www.icmsupport.nl":
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;	        
            break;
        
        case "www.icmperformance.eu":
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;	        
            break;
        
        case "www.flexvoip.nl":
            window.location="http://www.icmperformance.nl/pages/flexvoip.htm";
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;    
            break; 
        
    	case "www.flexcontactcenter.nl":
            window.location="http://www.icmperformance.nl/pages/telecom.htm";
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;    
            break;
        
        case "www.icmgroep.nl":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "icmgroep.nl":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "www.icmgroep.eu":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "icmgroep.eu":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "www.icmgroep.com":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "icmgroep.com":
            stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 9;
		    break;
		
		case "ipcc.icmperformance.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 3;
		    break;
		
		case "ipcc.icmgroep.nl":
		    stylesheet = "vosautomatisering.css";
		    orgid = 7;
		    pagid = 3;
		    break;
		
		default:
		    stylesheet = "icmperformance.css";
		    orgid = 8;
		    pagid = 2;
		    break;
    }
    
	// Workaround to make it work on browsers other then IE7
	document.write('<link rel="stylesheet" type="text/css" href="/include/icmwebsites/' + stylesheet + '" />');
	// END Workaround

	if(document.createStyleSheet) {
	 	document.createStyleSheet("/include/icmwebsites/" + stylesheet);
	} else {
		var styles = "@import url('include/icmwebsites/" + stylesheet + "');";
		var newSS=document.createElement('link');
		newSS.rel='stylesheet';
		newSS.href='data:text/css,'+escape(styles);
		document.getElementsByTagName("head")[0].appendChild(newSS);
	}
	
	if ((home != null) && home) {
		if ((pagid == 4) || (pagid == 5)) {
			DCMGetPage(pagid, '@mid=' + args['mid'] + ',@lid=' + pagid);
		} else {
			DCMGetPage(pagid, '@OrgCatId=' + orgid);
		}
	}
}
	
// This function is included to overcome a bug in Netscape's implementation
// of the escape () function:

function myunescape (str)
{
	str = '' + str;
	while (true)
	{
		var i = str . indexOf ('+');
		if (i < 0)
			break;
		str = str . substring (0, i) + ' ' + str . substring (i + 1, str . length);
	}
	return unescape (str);
}


// This function creates the args [] array and populates it with data
// found in the URL's search string:

function args_init ()
{
	args = new Array ();
	var argstring = window . location . search;
	if (argstring . charAt (0) != '?')
		return;
	argstring = argstring . substring (1, argstring . length);
	var argarray = argstring . split ('&');
	var i;
	var singlearg;
	for (i = 0; i < argarray . length; ++ i)
	{
		singlearg = argarray [i] . split ('=');
		if (singlearg . length != 2)
			continue;
		var key = myunescape (singlearg [0]);
		var value = myunescape (singlearg [1]);
		args [key] = value;
	}
}
//=====mailform====//
function CheckFields(form, sendmail, mailid)
{
    if (form == "NieuwsBrief") {
        var vfldEmail = document.getElementById("fldEmail");
    }
    if ((vfldEmail != null) && (vfldEmail.value != "")) {
        if (sendmail) {
            var url;
            url = "xmlhttp/DCMSaveRequestEx.aspx?dcmmail=" + mailid;
            if (DCMVersion != null) {
                url = url + "&v=" + DCMVersion;
            }
            url = url + "&fldEmail=" + vfldEmail.value;
            var xmlhttp = mdlReadData(url);
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.responseText == "0") {
                        window.alert("Er is een fout opgetreden bij het opnemen van uw E-mail adres!");
                    } else {
                        window.alert("Bedankt voor uw inschrijving, U bent nu geabonneerd op onze nieuwsbrief");
                    }
                }
            }
            xmlhttp.send(null);
        }
    }
    else if (vfldEmail.value == "") {
        window.alert("Vul een e-mail adres in!");
    }
    else {
        window.alert("Er is een onverwachte fout opgetreden!");
    }
    return (true);
}
