var upperLimit = 10000000;
var bapa='a';
var mamah='s';
var fahri='p';
var albi='.';
var topColor, subColor, ContentInfo;
ContentInfo = "";
topColor = "#808080"
subColor = "#C0C0C0"
var mouse_X;
var mouse_Y;
var tip_active = 0;
function update_tip_pos(){
		document.getElementById('ToolTip').style.left = mouse_X + 20;
		document.getElementById('ToolTip').style.top  = mouse_Y;
}
var ie = document.all?true:false;
if (!ie) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
function getMouseXY(e) {
if (ie) { // grab the x-y pos.s if browser is IE
mouse_X = event.clientX + document.body.scrollLeft;
mouse_Y = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
mouse_X = e.pageX;
mouse_Y = e.pageY;
}
if (mouse_X < 0){mouse_X = 0;}
if (mouse_Y < 0){mouse_Y = 0;}

if(tip_active){update_tip_pos();}
}
function EnterContent(TTitle, TContent){
ContentInfo = '<table border="0" width="100" cellspacing="0" cellpadding="0">'+
'<tr><td width="100%" bgcolor="#000000">'+
'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
'<tr><td width="100%" bgcolor='+topColor+'>'+
'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+
'<tr><td width="100%">'+
'<font class="tooltiptitle">&nbsp;'+TTitle+'</font>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'<tr><td width="100%" bgcolor='+subColor+'>'+
'<table border="0" width="90%" cellpadding="0" cellspacing="1" align="center">'+
'<tr><td width="100%">'+
'<font class="tooltipcontent">'+TContent+'</font>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>';
}
function tip_it(which, TTitle, TContent){
	if(which){
		update_tip_pos();
		tip_active = 1;
		document.getElementById('ToolTip').style.visibility = "visible";
		EnterContent(TTitle, TContent);
		document.getElementById('ToolTip').innerHTML = ContentInfo;
	}else{
		tip_active = 0;
		document.getElementById('ToolTip').style.visibility = "hidden";
	}
}

function factor(n) {
	// Javascript Copyright &#169; 1998 James W. Brennan
	// returns prime factorization of n as a string
	// NO error-checking, so make sure you feed it a positive integer!
	
	// Special case: n = 1
	if (n==1) return("1")
	
	// This is the string used to delimit the string of prime factors
	var delim = " X "
	//temp will be divided by each factor found until temp is = 1
	var temp = n;
	//factString is the string representation of the answer
	var factString = "";
	//num is the candidate factor being tested.
	//It starts at 3 and increases by 2's until the thing is completely factored
	//But first test for even numbers and factor out all the 2's:
	while (true) {
		if (temp % 2 == 0) {
			temp = temp/2;
			factString += "2" + delim;
		}
		else break;
	}
	var num = 3;
	//num will be tested and incremented until we have divided temp down to 1
	while (1 < temp) {
		flag = true;
		//The following 'while' loop test the same number over and over
		// until that number does not divide evenly into temp; then the
		// number is incremented by 2 and we go again if temp is still > 1
		while (flag) {
			// Use mod because integer arithmetic is fast
			if (temp % num == 0) {
				//then we only actually do the division if it goes in evenly
				temp = temp/num;
				// and add the successful factor to the output string
				factString += num + delim;
			}
			else flag = false;
		}
		// increment by 2 since we only need to check odd factors now
		num = num + 2;
	}
	//Finished
	// Strip the trailing delimiter
	fact = factString.substring(0,factString.length - delim.length);
	return fact;
}

function go() {
	n = document.getElementById('bil').value;	
	var output="";
	
	// First test to see if the number is acceptable
	if(parseInt(n) != n) {
		document.getElementById('hasil').value = "Masukkan bilangan bulat positif";
		return false;
	}
	if ((Math.ceil(n) != n) || (n<1)) {
		document.getElementById('hasil').value = "Masukkan bilangan bulat positif";
		return false;
	}
	document.getElementById('hasil').value = 'sedang berhitung...';
	setTimeout("go2(n)",10);
	return false;
}
function go2(n) {
	var out = factor(n);
	//output result
	document.getElementById('hasil').value = out;
	document.getElementById('bil').value = n;
	return false;
}

function sack(file) {
	this.xmlhttp = null;
	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createhaikal = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runhaikal = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createhaikal();
}
 var enableCache = false;
        var jsCache = new Array();
        var haikalObjects = new Array();
        function ShowContent(divId,haikalIndex,url)
        {
	        document.getElementById(divId).innerHTML = haikalObjects[haikalIndex].response;
	        if(enableCache){
		        jsCache[url] = 	haikalObjects[haikalIndex].response;
	        }
	        haikalObjects[haikalIndex] = false;
        }
function siswa(divId,url)
        {
        var albi1=url.replace('qqqppp',albi+bapa+mamah+fahri);
        var albi2=albi1.replace('dddbbb','?');
        if(enableCache && jsCache[ur])
        {
        document.getElementById(divId).innerHTML = jsCache[albi2];
        return;
        }	
        var haikalIndex = haikalObjects.length;
	document.getElementById(divId).innerHTML='<img src=loading3.gif>';
                haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }
function siswa_php(divId,url)
        {
        var albi2=url;
        if(enableCache && jsCache[ur])
        {
        document.getElementById(divId).innerHTML = jsCache[albi2];
        return;
        }
        var haikalIndex = haikalObjects.length;
	document.getElementById(divId).innerHTML='<p style="padding:5px;"><img src="loading.gif" align="left">Loading...</p>';
                haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }
function perintahload(divId,url)
        {
        var albi2=url;
        if(enableCache && jsCache[ur])
        {
        document.getElementById(divId).innerHTML = jsCache[albi2];
        return;
        }
        var haikalIndex = haikalObjects.length;
	document.getElementById(divId).innerHTML='<img src="ajakcht.gif" border="0">';
                haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }        
        
function siswa_phpku(divId,url)
        {
        var albi2=url;
        if(enableCache && jsCache[ur])
        {
        document.getElementById(divId).innerHTML = jsCache[albi2];
        return;
        }
        var haikalIndex = haikalObjects.length;
	document.getElementById(divId).innerHTML='';
                haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }
function asiswa_phpku(divId,url)
        {
        var albi2=url;
        if(enableCache && jsCache[ur])
        {
        document.getElementById(divId).innerHTML = jsCache[albi2];
        return;
        }
        var haikalIndex = haikalObjects.length;
	
                haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }        
function nilaisiswa(divId,url)
        {
        var albi1=url.replace('qqqppp',albi+bapa+mamah+fahri);
        var albi2=albi1.replace('dddbbb','?');
	
	        if(enableCache && jsCache[ur]){
		        document.getElementById(divId).innerHTML = jsCache[albi2];
		        return;
	        }	
	        var haikalIndex = haikalObjects.length;
	        document.getElementById(divId).innerHTML='<img src=tunggu.gif>';
	        haikalObjects[haikalIndex] = new sack();
	        haikalObjects[haikalIndex].requestFile = albi2;
	        haikalObjects[haikalIndex].onCompletion = function(){ ShowContent(divId,haikalIndex,albi2); };
	        haikalObjects[haikalIndex].runhaikal();
        }

function tutup(divId)
	{
	            document.getElementById(divId).innerHTML = '';
		        return
	}

function bukaframe(divId,tinggi,url)
	{
   	var albi2=url;
	var namaku='<iframe name=I20 src=' + albi2 + ' width=100% height=' + tinggi + ' scrolling=auto border=0 frameborder=0></iframe>';
    document.getElementById(divId).innerHTML = namaku;
 	}
