// Configurator JavaScript
<!--
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=325,left = 640,top = 375');");
}

function setfocus(){
    document.pcbuild.PrintBtn.focus()
}

function systemprice()
{
	var CPU = 0
	var systotal = 0
	var cpu_field = 0

	// Run through all the form fields
	for (var i=0; i < document.pcbuild.elements.length; ++i) {

		// Get the current field
		form_field = document.pcbuild.elements[i]

		// Get the field's value
		form_name = form_field.value

		// Is it a "product" field?
		if (form_name.substring(0,4) == "PROD") {

			// If so, extract the price from the name
			item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))

			systotal = item_price + systotal;
		}

		if (form_name.substring(0,3) == "CPU" && form_field.checked) {

			// If so, extract the price from the name
			CPU = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))

			systotal = CPU + systotal;
		}
	}

	document.pcbuild.TOTAL.value = "$" + systotal;

	if(systotal < 600){
	var deposit = 300;
	}

	if(systotal > 600){
	var deposit = systotal * 0.5;
	}

	document.getElementById('deposit1').innerHTML = Math.round(deposit);
	document.getElementById('deposit2').innerHTML = Math.round(systotal);

	if(CPU > 1000 && document.pcbuild.GRAPHICS.value == "PROD_COMPONENT[GRAPHICS]_Intel HD Graphics_0.00"){
		document.getElementById('GRAPHICS').selectedIndex = 1;
		systemprice();
	}
	// END SYSTEMPRICE FUNCTION
}

function rst()
{
	document.getElementById('deposit1').innerHTML = 0;
	document.getElementById('deposit2').innerHTML = 0;
	document.pcbuild.reset();
	document.TOTAL.reset();
}

// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety =  8;

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
    if(!document.getElementById('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = document.getElementById('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}
-->
