
var DOOR_TYPES = {"sliding":	{ "NGA" : "NGA Aluminium Framed Glass Doors" ,
				  "NGF" : "NGF Frameless Glass Door Operator" ,
				  "NGA-BOS" : "NGA-BOS ADIS Panic Breakout Door Operator " ,
				  "NGT" : "NGT ADIS Telescopic Door Operator" ,
				  "NGU-A" : "NGU ULTRASLIM 73mm Profile Sliding Door Operator" ,
				  "NGU-F" : "NGU-F ULTRASLIM 73mm Profile Frameless Sliding Door Operator"
				} ,
		  "special":	{ "NGA-F" : "NGA-F Parents Room Doors" ,
				  "NGA-Swim" : "NGA Swimming Pool Doors",
				  "Disabled" : "Disabled Toilet Doors"
				}
		 };
		 

function submitSpecifyProduct()
{
   var elem = document.getElementById("pname");
   if(elem.value == "")
   {
   	alert('Please enter Project Name.');
   	elem.focus();
   	return false;
   }
   elem = document.getElementById("paddress");
   if(elem.value == "")
   {
   	alert('Please enter Project Address.');
   	elem.focus();
   	return false;
   }
    
    var ddlDoorType = document.getElementById("doorType");
    document.getElementById("mselect").value = ddlDoorType.options[ddlDoorType.selectedIndex].text;
	
    var doorType = document.getElementById("doorType").value;
    var frm = document.specProdForm;
    frm.action = "products/" + doorType  + ".asp";
}


function getDoorTypes()
{
    var _selValue = document.getElementById("dCategory").value;
    //alert(_selValue);
    var ddlDoorType = document.getElementById("doorType");
    clearList(ddlDoorType);
    
    var doorTypes = DOOR_TYPES[_selValue];
    //alert(doorTypes);
    var option = null;
    for(_val in doorTypes) 
    {
        option = document.createElement("option");
        option.setAttribute("value", _val); 
        option.appendChild(document.createTextNode(doorTypes[_val]));
        ddlDoorType.appendChild(option);
    }
	
}


function clearList(list) {
    while(list.childNodes.length > 0) {
        list.removeChild(list.childNodes[0]);
    }
}

function copyToClipboard(objId)
{
	var obj = document.getElementById(objId);
	//alert(obj.id);
	if(!obj) return;

	if( ! window.clipboardData) 
	{
		alert('Copy to clipboard not supported');
		return;
	}
	
	var text;
	if(obj.value)
		text = obj.value;
	else if(obj.innerHTML)
		text = obj.innerHTML;
	else
	{
		alert('Copy to clipboard not supported');
		return;
	}
	//alert(text);
	var text = text.replace(/(<BR>)/ig,"\r\n");
	window.clipboardData.setData("Text", text.replace(/(<([^>]+)>)/ig,""));
	alert('The data is now in your clipboard ready to be pasted with CTRL-V');
}

function deleteProductSpec(specId, prjName)
{
	if(confirm("Are you sure you want to delete the Product Spec for "+prjName+" ?"))
	{
		window.location = "deleteProduct.asp?id="+specId;
	}
}

function selectLastView(val)
{
	document.getElementById("dateRange").value = val;
}