﻿// JScript File

//Checks/Unchecks radio buttons on the product control page
function RadioChecked(param, price, cpyparam, totalobj) {

    var frm = document.forms[0];
    
    // Take all elements of the form
    for (i=0; i < frm.length; i++) {
        
        // itinerate the elements searching "RadioButtons"
        if (frm.elements[i].type == "radio") {
            // Unchecked if the RadioButton is != param
            if (param != frm.elements[i].id ) {
            
            // Only uncheck items that are from the Product control
                if (frm.elements[i].id.indexOf("Product") > -1) {
                    frm.elements[i].checked = false;
                }
            }
            else {
                frm.elements[i].checked = true;
                var copy = document.getElementById(cpyparam);
                var priceobj = document.getElementById(price);
                var itemprice = priceobj.innerHTML.substring(1,priceobj.innerHTML.length -1);
                
                itemprice = itemprice.replace(",","");
                document.getElementById(totalobj).value = copy.value * itemprice;
            }
        }
    }
}

// Makes sure that only numbers are being entered by the user
function PressNumber(e) {
	var charCode = e.keyCode;

	if ((charCode != 13 || charCode != 8) && (charCode < 48 || charCode > 57 )){ 
		e.keyCode=0
	}

	return true;
}

// Opens up a window 

function openWindowMove(sUrl, sName, sProperties, iWidth, iHeight, iMoveX, iMoveY){
	var iX, iY;
	
	iX = iMoveX;
	if(iMoveX == 'left')
		iX = 0
	if(iMoveX == 'middle')
		iX = (screen.width / 2) - (iWidth / 2)
	if(iMoveX == 'right')
		iX = screen.width - iWidth - 10;
		
	iY = iMoveY;	
	if(iMoveY == 'top')
		iY = 0;
	if(iMoveY == 'middle')
		iY = ((screen.height - 56) / 2) - (iHeight / 2);
	if(iMoveY == 'bottom')
		iY = screen.height - 56 - iHeight;

	sProperties += ',width=' + iWidth + ',height=' + iHeight + ',screenX=' + iX + ', screenY=' + iY + ',left=' + iX + ',top=' + iY;
	window.open(sUrl, sName, sProperties);
}

function ShowTermsAndConditions(todo,description) {
    var newwindow;
	if (typeof(newWindow2) == 'object') {
		if (!newWindow2.closed) {
			newWindow2.close();
			newWindow2 = window.open('Popups/TermsAndPrivacy.aspx?todo=' + todo, description, 'width=600,height=450,resizable=0,scrollbars=yes,status=yes');
		} else {
			newWindow2 = window.open('Popups/TermsAndPrivacy.aspx?todo=' + todo, description, 'width=600,height=450,resizable=0,scrollbars=yes,status=yes');
		}
	} else {
		newWindow2 = window.open('Popups/TermsAndPrivacy.aspx?todo=' + todo, description, 'width=600,height=450,resizable=0,scrollbars=yes,status=yes');
	}
}

function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}