//Quick Search function start
		var keyIndex = 0;
    	var keyValue = null;
    	var isHidQSDiv = true;
    	var scrollTopValue = 0;
    	var controlId = null;
    	var searchStr = '';
    	
    	function loadQSShortName() {
    		controlId = "coinShortName";
    		window.setTimeout("sendSearchRequest();",500);
   		}
		
		function loadQSDenomination() {
			controlId = "coinDenoName";
    		window.setTimeout("sendSearchRequest();",1000);
   		}
   	
   		function sendSearchRequest(){
   			var inputStr = document.getElementById(controlId).value;
   			if(keyValue!=37 && keyValue !=39 && keyValue!=40 && keyValue !=38 && keyValue !=13 && inputStr !=''){
    			if(searchStr != inputStr){
	   				searchStr = inputStr;
    				var coinShortNameValue = getElementById("coinShortName").value;
					var coinDenominationValue = getElementById("coinDenoName").value;
					if(coinShortNameValue==getElementById("countryDefaultValue").value)
						coinShortNameValue='';
					if(coinDenominationValue==getElementById("denominationDefaultValue").value)
						coinDenominationValue='';
	    			sendHttpRequest("./quickSearch.do?QSShortNameText="+encodeURIComponent(coinShortNameValue)
	    															   +"&QSControlId="+controlId
	    															   +"&QSDenominationText="+encodeURIComponent(coinDenominationValue)
	    															   +"&relationShortName="+encodeURIComponent(coinShortNameValue), 
	    															   showQSDiv,false);
   				}
   			}else if(document.getElementById(controlId).value ==''){
   				hidQSDiv();
				searchStr='';
			}
   		}
		
		//DropDownList div nodes
		function showQSDiv(httpRequest) {
			if (isHttpRequestReady(httpRequest)) {
				var result = new XMLArray();
				var inputKey = null;
				var innerXml = '';
				result.loadXML(httpRequest.responseText);
				result.setCurrentIndex(0);
				inputKey = result.currentItem.getAttribute("inputKey");
				innerXml = result.currentItem.getAttribute("innerXml");
				if(inputKey!=searchStr)
					return;
			    keyIndex = 0;
		    	keyValue = null;
		    	scrollTopValue = 0;
			    var divQS = document.getElementById('divQuickSearch');
			    //if(document.body.clientWidth > 1008)
			    //	divQS.style.left = (document.body.clientWidth-1008)/2 + 421;
			    var control = document.getElementById(controlId);			    
		    	var divQSTop = control.offsetTop;
			    var divQSLeft = control.offsetLeft;
			    while(control=control.offsetParent){
			    	divQSTop += control.offsetTop;
			    	divQSLeft += control.offsetLeft;
			    }
			    divQS.style.top = divQSTop + 20;
			    divQS.style.left = divQSLeft;
			    divQS.style.display = "";
			    divQS.style.height = "120px";
			    divQS.innerHTML = innerXml;
			    
			    var divQSChild = divQS.childNodes;
			    if(divQSChild.length<8)
			    	divQS.style.height = (divQSChild.length*16) + "px";
			    if(divQSChild.length == 0)
			    	hidQSDiv();
			}
		}
		//Mouse over function
		function setOverStyle(div_value) {
			div_value.className = 'suggest_link_over';
		}
		//Mouse out function
		function setOutStyle(div_value) {
			div_value.className = 'suggest_link';
		}
		//Click function
		function setQSearch(value) {
			document.getElementById(controlId).value = value;
			hidQSDiv();
		}
		//Key handle function
		function keySelectValue(eventTag) {
			var event = eventTag||window.event;
	        //var key=event.srcElement||event.target;
	        var key=event.charCode||event.keyCode;
	        var divQS = document.getElementById('divQuickSearch');
	        var divQSChild = divQS.childNodes;//getElementsByTagName('divQSChild');
	        keyValue = "";
	        if(key==40){//divQS.childNodes
        		//alert(divQS.childNodes[keyIndex].textContent);
	        	if(keyIndex == divQSChild.length){
		        	setOutStyle(divQSChild[keyIndex-1]);
		        	divQS.scrollTop = 0;
		        	scrollTopValue = 0;
		        	keyIndex = 0;
		        }
	        	setOverStyle(divQSChild[keyIndex]);
		        if(keyIndex > 0){
	        		setOutStyle(divQSChild[keyIndex-1]);
	        	}
	        	//document.getElementById(controlId).value = divQSChild[keyIndex].textContent || divQSChild[keyIndex].innerText;
	        	keyIndex++;
	        	keyValue = 40;
	        	
	        	if(keyIndex>8){
	        		scrollTopValue = scrollTopValue + 14;
	        		divQS.scrollTop = scrollTopValue;
	        	}
	        }else if(key==38){
	        	keyIndex--;
	        	if(keyIndex > 0){
	        		setOverStyle(divQSChild[keyIndex-1]);
		        	if(keyIndex >= 0)
		        		setOutStyle(divQSChild[keyIndex]);
		        	
		        	//document.getElementById(controlId).value = divQSChild[keyIndex-1].textContent || divQSChild[keyIndex-1].innerText;
		        	keyValue = 38;
		        	scrollTopValue = scrollTopValue - 14;
		        	divQS.scrollTop = scrollTopValue;
	        	}else{
	        		setOutStyle(divQSChild[0]);
	        		keyIndex = divQSChild.length;
	        		setOverStyle(divQSChild[keyIndex-1]);
	        		if(divQSChild.length > 8)
	        			scrollTopValue = (divQSChild.length - 8)*14;
	        		divQS.scrollTop = scrollTopValue;
	        		keyValue = 38;
	        	}	        	
	        }else if(key == 13 && keyIndex !=0){
	        	document.getElementById(controlId).value = divQSChild[keyIndex-1].textContent || divQSChild[keyIndex-1].innerText;
	        	keyValue = 13;
	        	hidQSDiv();
	        }
	        
		}
		//
		function hidQSDiv(){
			document.getElementById('divQuickSearch').style.display = "none";
		}
		function textOnblur(){
			if(isHidQSDiv)
				hidQSDiv();
		}
		function setHidQSDiv(value){
			isHidQSDiv = value;
		}
		function validateQSResultForm(){
			var txtYear = getElementById("coinSpecificYear").value;
			if(txtYear==getElementById("yearDefaultValue").value)
					txtYear='';
			if(txtYear != null && txtYear != ""){
				return isRoughYear(txtYear);
			}
			return true;
		}
		function quickSearch(){
			if(validateQSResultForm()){
				//getElementById("qSShortName").value = getElementById("coinShortName").value;
				var coinShortNameValue = getElementById("coinShortName").value;
				var coinDenominationValue = getElementById("coinDenoName").value;
				var coinYearValue = getElementById("coinSpecificYear").value;
				if(coinShortNameValue==getElementById("countryDefaultValue").value)
					coinShortNameValue='';
				if(coinDenominationValue==getElementById("denominationDefaultValue").value)
					coinDenominationValue='';
				if(coinYearValue==getElementById("yearDefaultValue").value)
					coinYearValue='';
				qSResultForm.action="quickSearchResult.do?quickShortName="+encodeURIComponent(coinShortNameValue)
													    +"&quickDenomination="+encodeURIComponent(coinDenominationValue)
													    +"&quickYear="+coinYearValue;
				qSResultForm.submit();
			}else{
				alert(getElementById("hidQSYear").value);
			}
		}
		
		//Quick Search function end
