function MM_openBrWindow(theURL,winName,features)
{ //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function AW_BustFrames() {
	if (self.parent.frames.length!=0)
	{
		self.parent.location.replace(document.location.href);
	}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_reloadPage(init)
{  //reloads the window if Nav4 resized
	if (init==true) with (navigator)
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4))
		{
    		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}
  	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// allows me to have a name assigned to any window at all times
function setWinName()
{
	var mainWindow;
	window.name = "dcsSite";
}

// scrolling text
/**
to call this function just place the following code into the file you want to call:

var scroll_msg = "Add your text here";
scrollText();
**/
var scroll_i = 0;
function scrollText()
{
	while (scroll_i ++ < 30)
	{
		scroll_msg = " " + scroll_msg;
	}

	window.status = scroll_msg.substring(scroll_i,scroll_msg.length) + scroll_msg.substring(0,scroll_i-1)

	if (scroll_i < scroll_msg.length)
	{
		scroll_i++;
	}
	else
	{
		scroll_i=0;
    }

	setTimeout("scrollText()",150);
}

function changeImage(img)
{
	if(screen.width > '800')
	{
		document.write('<img src="/images/frontpage/1024/' + img + '" hspace="2" vspace="2" border=0 align="left"  alt="Click for More Information on this Product">');
	}
	else
	{
		document.write('<img src="/images/frontpage/800/' + img + '" hspace="2" vspace="2" border=0 align="left" alt="Click for More Information on this Product">');
	}
}

function hideImage(htmlbefore, htmlafter, path, img_to_show, hspace, vspace, border, align, desctext)
{
	if(screen.width > '800')
	{	
		// show html before
		if(htmlbefore){document.write(htmlbefore);}
		
		document.write('<img src="' + path + img_to_show + '" hspace="' + hspace + '" vspace="' + vspace + '" border="' + desctext + '" align="' + desctext + '"  alt="' + desctext + '">');
		
		// show html after
		if(htmlafter){document.write(htmlafter);}
	}
	else
	{
		return false;
	}
}

var headerAds;
var metaText;
function elementsByRes()
{
	if(screen.width >=1024) //greater than 1024
	{
		headerAds = document.getElementById("headerAds");
		headerAds.setAttribute("width","88%");

        metaText = document.getElementById("metaText");
		metaText.setAttribute("width","51%");
	}
	else if(screen.width <1024) // less than 1024
	{
		headerAds = document.getElementById("headerAds");
		headerAds.setAttribute("width","95%");

        metaText = document.getElementById("metaText");
		metaText.setAttribute("width","47%");

	}
}
function dcs_jsBack(back_text)
{
	return '<a href = "javascript:history.back(1)" onMouseOver="MM_displayStatusMsg(\'' + back_text + '\');return document.MM_returnValue" class="dcsBack">' + back_text + '</a>'
}

//js to close popup after click link - at

function targetopener(mylink, closeme, closeonly)
{
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.location.href=mylink.href;
if (closeme)window.close();
return false;
}

function multiRes()
{
    var cssStyle = "";
    var operating_sys = "";
    var ah_winNT = navigator.userAgent.indexOf('Windows NT 5.1');
    var ah_msie = userAgent.indexOf('MSIE');
    //test if ie on xp
    
        if(ah_winNT != -1 && ah_msie != -1)
        {
            operating_sys = "_ie_xp";
        }
    
    // setup stylesheet based on resolution
    if(screen.width >851 && screen.width <=1024) //if resolution is 1024 wide
    {
        cssStyle = "/templateDir/template2/1024" + operating_sys + ".css";
        cssLayout = "/design/css/header_1024w.css";
        cssBodyLayout = "/design/css/body_1024w.css";
    }
    else if(screen.width <=850) // if resolution is 800 wide
    {
        cssStyle = "/templateDir/template2/800" + operating_sys + ".css";
        cssLayout = "/design/css/header_800w.css";
        cssBodyLayout = "/design/css/body_800w.css";
    }
    else if(screen.width >1024) //if resolution is greater than 1024
    {
        cssStyle = "/templateDir/template2/1152" + operating_sys + ".css";
        cssLayout = "/design/css/header_1152w.css";
        cssBodyLayout = "/design/css/body_1152w.css";
    }
    
    return '<link href="' + cssStyle + '" rel="stylesheet" type="text/css"><link href="' + cssLayout + '" rel="stylesheet" type="text/css"><link href="' + cssBodyLayout + '" rel="stylesheet" type="text/css">';
}

/** BEGIN DCS Iframe cart specific functions **/
function process_add_item(item_id) 
{
    elem = document.getElementById('show_cart_div');    
    if(elem)
    {
        elem.style.display = "";
            
        if(elem.style.display == "")
        {
            elem.style.display = "inline";
            show_iframe(item_id);
        }
    }
}

function show_iframe(item_id)
{
    document.getElementById('show_cart_div').innerHTML = '<a name="dcs_cart"></a><div id="dcs_cart_close_window" name="dcs_cart_close_window"><iframe src="/modules/ordersys/dcs_cart_iframe_header.php?window_type=cart&item_id=' + item_id + '" name="dcs_cart_iframe_header" id="dcs_cart_iframe_header" scrolling="none" marginwidth="0" marginheight="0" frameborder="0"></iframe><iframe src="/modules/ordersys/process.php?osb_id=' + item_id + '" name="show_cart_iframe" id="show_cart_iframe" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0">You don\'t have iframe ability</iframe>';
}

function process_show_general_cart()
{
    elem = document.getElementById('show_cart_div');    
    elem.style.display = "";
        
    if(elem.style.display == "")
    {
        elem.style.display = "inline";
        show_general_cart_iframe();
    }
}

function show_general_cart_iframe()
{
    document.getElementById('show_cart_div').innerHTML = '<a name="dcs_cart"></a><div id="dcs_cart_close_window" name="dcs_cart_close_window"><iframe src="/modules/ordersys/dcs_cart_iframe_header.php?window_type=cart" name="dcs_cart_iframe_header" id="dcs_cart_iframe_header" scrolling="none" marginwidth="0" marginheight="0" frameborder="0"></iframe><iframe src="http://shopping.netsuite.com/app/site/site.nl?ext=T&amp;site=ACCT66838&amp;mode=cart&amp;ext=T" name="show_cart_iframe" id="show_cart_iframe" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0">You don\'t have iframe ability</iframe>';
}

function process_login_frame()
{
    elem = document.getElementById('show_cart_div');    
    elem.style.display = "";
        
    if(elem.style.display == "")
    {
        elem.style.display = "inline";
        show_login_iframe();
    }
}

function show_login_iframe()
{
    document.getElementById('show_cart_div').innerHTML = '<a name="dcs_cart"></a><div id="dcs_cart_close_window" name="dcs_cart_close_window"><iframe src="/modules/ordersys/dcs_cart_iframe_header.php?window_type=login" name="dcs_cart_iframe_header" id="dcs_cart_iframe_header" scrolling="none" marginwidth="0" marginheight="0" frameborder="0"></iframe><iframe src="http://shopping.netsuite.com/store/query/customercenterredirect.nl?site=ACCT66838&amp;ext=T" name="show_cart_iframe" id="show_cart_iframe" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0">You don\'t have iframe ability</iframe>';
}

function process_contactus_frame()
{
    elem = document.getElementById('show_cart_div');    
    elem.style.display = "";
        
    if(elem.style.display == "")
    {
        elem.style.display = "inline";
        show_contactus_iframe();
    }
}

function show_contactus_iframe()
{
    document.getElementById('show_cart_div').innerHTML = '<a name="dcs_cart"></a><div id="dcs_cart_close_window" name="dcs_cart_close_window"><iframe src="/modules/ordersys/dcs_cart_iframe_header.php?window_type=contact" name="dcs_cart_iframe_header" id="dcs_cart_iframe_header" scrolling="none" marginwidth="0" marginheight="0" frameborder="0"></iframe><iframe src="https://system.netsuite.com/store/crm/externalcasepage.nl?compid=ACCT66838&amp;formid=1&amp;h=94ecb2f5fc478853e38f" name="show_cart_iframe" id="show_cart_iframe" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0">You don\'t have iframe ability</iframe>';
}

function process_faq_frame()
{
    elem = document.getElementById('show_cart_div');    
    elem.style.display = "";
        
    if(elem.style.display == "")
    {
        elem.style.display = "inline";
        show_faq_iframe();
    }
}

function show_faq_iframe()
{
    document.getElementById('show_cart_div').innerHTML = '<div id="dcs_cart_close_window" name="dcs_cart_close_window"><iframe src="/modules/ordersys/dcs_cart_iframe_header.php?window_type=faq" name="dcs_cart_iframe_header" id="dcs_cart_iframe_header" scrolling="none" marginwidth="0" marginheight="0" frameborder="0"></iframe><iframe src="http://shopping.netsuite.com/s.nl/c.ACCT66838/sc.5/category.-1/ctype.KB/KB.2003/.f?=f" name="show_cart_iframe" id="show_cart_iframe" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0">You don\'t have iframe ability</iframe>';
}


function process_hide_cart()
{
/*
    elem = document.getElementById('show_cart_div');
    if(elem.style.display=="inline")
    {
        elem.style.display = "none";
    }
    */
    
    
}

// close cart from child window
function proces_hide_close_cart_child()
{
    elem = parent.window.document.getElementById('show_cart_div');
    
    if(elem)
    {
        if(elem.style.display=="inline")
        {
            elem.style.display = "none";
        }
    }
    elem.style.width = "";
    elem.style.left= "";
    elem.style.height= "";
    elem.style.top= "";
    
    show_dcsBody = parent.window.document.getElementById('dcsBody');
    show_dcsBody.style.display = "inline";
    
    show_headerFrame = parent.window.document.getElementById('headerFrame');
    show_headerFrame.style.display = "inline";
    
    show_horzNav2 = parent.window.document.getElementById('horzNav2');
    show_horzNav2.style.display = "inline";
    
    hide_dcsPrintButton = parent.window.document.getElementById('dcsPrintButton');
    hide_dcsPrintButton.style.display = "none";
    
    processajax ('/modules/ordersys/reset_session.php', 'show_cart_div', 'get', 'WAIT');
}

/**
 * expand_iframe_cart() controls paqe elements when display printer friendly view
 * 
 * 
 */
function expand_iframe_cart()
{
    // Hide div elements
    hide_dcsBody = parent.window.document.getElementById('dcsBody');
    hide_dcsBody.style.display = "none";
    
    hide_headerFrame = parent.window.document.getElementById('headerFrame');
    hide_headerFrame.style.display = "none";
    
    hide_horzNav2 = parent.window.document.getElementById('horzNav2');
    hide_horzNav2.style.display = "none";
    
    hide_scrn_res = parent.window.document.getElementById('scrn_res');
    if(hide_scrn_res)
    {
        hide_scrn_res.style.display = "none";
    }

    // show print element
    show_dcsPrintButton = parent.window.document.getElementById('dcsPrintButton');
    show_dcsPrintButton.style.position = "absolute";
    show_dcsPrintButton.style.display = "inline";
    show_dcsPrintButton.style.left = "350px";
    show_dcsPrintButton.style.top = "10px";
    
    // expand shopping cart div
    expand_cart_div = parent.window.document.getElementById("show_cart_div");
    expand_cart_div.style.width = "800px";
    expand_cart_div.style.height = "1000px";
    expand_cart_div.style.left= "0px";
    expand_cart_div.style.top= "50px";
    expand_cart_div.style.zIndex= "1000";
    
    // expand iframe part of cart
    expand_cart_iframe = parent.window.document.getElementById('show_cart_iframe');
    expand_cart_iframe.style.width = "800px";
    expand_cart_iframe.style.zIndex= "1000";
    expand_cart_iframe.style.height = "1000px";
    
    // expand iframe header    
    expand_cart_iframe_header = parent.window.document.getElementById('dcs_cart_iframe_header');
    expand_cart_iframe_header.style.width = "800px";
    expand_cart_iframe_header.style.zIndex= "1000";
}
/** END DCS Iframe cart specific functions **/

/** BEGIN JS which apply to Running Ajax **/

    
    //xml_http.js
    
    //Function to create an XMLHttp Object.
    function getxmlhttp (){
        //Create a boolean variable to check for a valid microsoft active X instance.
        var xmlhttp = false;
        
        //Check if we are using internet explorer.
        try {
            //If the javascript version is greater than 5.
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            //If not, then use the older active x object.
            try {
                //If we are using internet explorer.
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                //Else we must be using a non-internet explorer browser.
                xmlhttp = false;
            }
        }
        
        //If we are using a non-internet explorer browser, create a javascript instance of the object.
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        
        return xmlhttp;
    }
    
    //Function to process an XMLHttpRequest.
    function processajax (serverPage, obj, getOrPost, str){
        //Get an XMLHttpRequest object for use.
        xmlhttp = getxmlhttp ();
        if (getOrPost == "get"){
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                   // obj.innerHTML = xmlhttp.responseText;
                }
            }
            xmlhttp.send(null);
        } else {
            xmlhttp.open("POST", serverPage, true);
            xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    obj.innerHTML = xmlhttp.responseText;
                }
            }
            xmlhttp.send(str);
        }
    }
    
/** END JS which apply to Running Ajax **/
