/*
 * var protovis_forced = function(uri) {
	
	var w = $("#tab2").outerWidth(),
        //h = $(".tab_content").height(),
        h = 650,
        colors = pv.Colors.category19();

    var vis = new pv.Panel()
            .width(w)
            .height(h)
            .fillStyle("white")
            .event("mousedown", pv.Behavior.pan())
            .event("mousewheel", pv.Behavior.zoom(.3));
    
    //vis.transform = new pv.Transform().scale(150);
    //vis.transform(pv.Transform.scale(.9));
    
    var force = vis.add(pv.Layout.Force)
	.nodes(data.nodes)
	.links(data.links)
	.chargeConstant(-120)
	.springLength(60)
	.bound(true);
   
         //.iterations(800)
            //.springLength(40)

    force.link.add(pv.Line);

	//.size(function(d) (d.linkDegree + 40) * Math.pow(this.scale, .7))
        //.fillStyle(function(d) d.fix ? "brown" : colors(d.group))
        
    force.node.add(pv.Dot)
	//.size(function(d) (d.linkDegree + 40) * Math.pow(this.scale, .7))
	.radius(function (d) (d.radius) * Math.pow(this.scale, .7) )
        .fillStyle(function(d) d.group )
        .strokeStyle(function() this.fillStyle().darker() )
        .lineWidth(5)
        .title(function(d) d.nodeName )
        .event("mousedown", pv.Behavior.drag())
        .event("drag", force)
        .event("dblclick", function(d) location.assign(d.url) );
        //.anchor("top").add(pv.Label)
		//	.font("12px sans-serif")
		//	.text(function(d) d.label);
		//	.events("all")
		//	.event("mouseover", function() this.visible(false));
		
    
    
    //vis.transform = new pv.Transform().scale();

	vis.canvas("protovisforced");
	vis.render();

}
*/

var graphgear = function() {
   var cleanheader = decodeURIComponent(graphgear_data.header).replace(/\+/g, ' ');
   if ( $('#protovisforced').parent().html().indexOf(cleanheader) == -1 ) {
        $('#protovisforced').parent().prepend('<h1>' + cleanheader + '</h1>');
   }
   var so = new SWFObject("/static/GraphGear.swf", "graphgear", "680", "550", "8");
   so.addVariable("graphXMLFile", graphgear_data.xml);
   //so.addParam("allowScriptAccess", "always");
   so.addParam("scale", "noborder");
   so.addParam("salign", "tl");
   //so.addParam("base", "examples");
   so.write("protovisforced");
}


jQuery(function() {
    // show a simple loading indicator
    var msg = '<div id="loader">Submitting ... <img src="/static/images/loading.gif" alt="Submitting..." /></div>'
    var load1 = $('#load1').append(msg).css({position: "relative", margin: "auto"}).hide();
    var load2 = $('#load2').append(msg).css({position: "relative", margin: "auto"}).hide();
    jQuery().ajaxStart(function() {
        load1.show();
        load2.show();
    }).ajaxStop(function() {
        load1.hide();
        load2.hide();
    }).ajaxError(function(a, b, e) {
        throw e;
});

var v = jQuery("#commentform").validate({
    submitHandler: function(form) {
        jQuery(form).ajaxSubmit({
            target: "#submitresult1, #submitresult2", 
            success: function() { 
                //document.getElementById('buttonSet').innerHTML = '';
                //setTimeout("location.href = '/';", 5000);
            },
            clearForm: false
        });
    }
});

jQuery("#reset").click(function() {
    v.resetForm();
    });
});


