function loadScript(url,callback) {
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
script.parentNode.removeChild( script );
callback();
}
};
} else { //Others
script.onload = function(){
this.parentNode.removeChild(this);
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
var system = require('system');
if (system.args.length !=2) {
console.log('Usage: '+system.args[0]+' domain');
phantom.exit(1);
} else {
var domain = system.args[1];
var page = require('webpage').create();
page.viewportSize = {
width: 1280,
height: 800
};
page.open('http://'+domain+'/', function() {
page.render(''+domain+'.png');
phantom.exit();
});
}