// Author: HaWay
IncludeJavaScript( 'jquery.min.js' );

$(document).ready(function(){

});

function ODiv( ID ){
    document.getElementById( ID ).style.display='';
}
function CDiv(ID){
    document.getElementById( ID ).style.display='none';
}

function pingreport(ip, up , time){
	if ( up ){
		alert( ip + ' is alive, response time: ' + time  );
	}else{
		alert( ip + ' NO response!!' );
	}
}

function idnchange( host ){
    var host = document.getElementById( host ).value;

	var result = $.ajax({
		url:"idn.cgi?host="+encodeURI(host),
		async: false
	}).responseText;
	$("#host").val( result );
	//alert( result );
}

// http://ameer1234567890.co.cc/projects/js-ping.php

function pingtest( ID ){
    var ip = document.getElementById( ID ).value;

    if(occurancesOf(ip, '.') != 3) {
      alert("You can only ping IPs, not hostnames\nExample: 211.72.210.250");
    } else {
		var resultping = $.ajax({ 
			url:"ping.cgi?host="+ip,
			async: false
		}).responseText;
		alert( resultping );
    }
}

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="/'
    + jsFile + '"></scr' + 'ipt>'); 
}

function occurancesOf(s, lookFor) {
    var count = 0;
    var offset =-1;
    while( (offset = s.indexOf(lookFor, offset+1)) != -1) {
        count++;
    }
    return count;
}

/*
function runCmd(command, option)
{
    var char34 = String.fromCharCode(34);
    var wsh = new ActiveXObject('WScript.Shell');
    if (wsh)
    {
        command = 'cmd /k ' + char34 + wsh.ExpandEnvironmentStrings(command) + ' ';
        command = command + char34 + wsh.ExpandEnvironmentStrings(option) + char34  + char34;
        if (confirm(command))
        {
            wsh.Run(command);
        }
    }
}
*/

