// JavaScript Document


			function pause(numberMillis) {
        		var now = new Date();
        		var exitTime = now.getTime() + numberMillis;
        		while (true) {
            		now = new Date();
            		if (now.getTime() > exitTime) {
                		return;
					}
        		}
    		}


			function LoadGraph()
			{


				
			var sel = document.getElementById('types');
			var type = sel.options[sel.selectedIndex].value;
			
			var selDate = document.getElementById('time');
			var frame = selDate.options[selDate.selectedIndex].value;
			
			var endDate = new Date();
			if(frame.substring(1) == 'y') {
				var yearNum = parseInt(frame.substring(0,1));
				if(yearNum == 0) {
					yearNum = 10;
				}
				endDate.setFullYear(endDate.getFullYear() - yearNum);
			}
			
			if(frame.substring(1) == 'm') {
				var monthNum = parseInt(frame.substring(0,1));
				endDate.setMonth(endDate.getMonth() - monthNum);
			}
			
			 var year = endDate.getFullYear() + '';
			 var month = (endDate.getMonth() + 1);
			 if(month < 10) {
				month = '0' + month;
			 }
			 else {
			 	month = month + '';
			 }
			 var day = endDate.getDate();
			 if(day < 10) {
				day = '0' + day; 
			 }
			 else {
				 day = day + '';
			 }
			//$html .= "	alert(year + month + day);
			var frameDate = year + month + day;
			
			var selFreq = document.getElementById('frequency');
			var frequent = selFreq.options[selFreq.selectedIndex].value;
			
			window.location='/common/crons/stockInfoRetriever.php?type=' + type + '&endDate=' + frameDate + '&frequency=' + frequent;
			
			pause(2000); //needed in order for file to be replaced befor the page reloads.
			//var t = setTimeout(delay,2000);
			
			//window.location.reload(false);
			//ShowGraph();	//ajax call
			}
			
			