function 
PopUp(URL, w, h) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=" +w+ ",height=" +h+ "');");
}


// a = url
// b = param list 
// c = GET || POST
// d = div id
function
getAlertAjax(a, b, c, d) {

	$.ajax({
	    url: a,
	    type: c,
	    dataType: 'text',   
	    data: b,
	    async: false,
	    timeout: 1000,
	    error: function(request, msg){
	        alert('Error retrieveing data - please try again later!');
	    },
	    success: function(r){
	        // do something with xml    
		$("#"+d).html( r );
	    }
	});
}


function
gotoPublication(a) {
	if (a.indexOf("http://") > -1) {
		window.location.href = a;
	}
}

function
vote(a, b, c, t) {
	$.ajax({
	    url: '/VotingService.asmx/Vote',
	    type: 'GET',
	    dataType: 'xml',   
	    data: "cid="+c+"&ctid="+b+"&v="+a,
	    timeout: 10000,
	    error: function(request, errtype){
	        alert('Error voting - please try again later!');
	    },
	    success: function(xml){
	        // do something with xml    
		if ( $("return", xml).text() == 0 ) {
			$("#tooltip").hide();
			$("#"+t+c).html( $("up", xml).text() + " Thumbs Up | " + $("down", xml).text() + " Thumbs Down");
			$("#vbtn"+c).html( "" );
		} else if ( $("return", xml).text() == 1 ) {
			//alert("Already Voted!");
			$("#tooltip").hide();
			$("#"+t+c).html( $("up", xml).text() + " Thumbs Up | " + $("down", xml).text() + " Thumbs Down");
			$("#vbtn"+c).html( "" );
		} else if ( $("return", xml).text() == 3 ) {
			alert("Missing a value");
		} else {
			alert("Must be logged in to vote");
		}
	    }
	});
}

function
Save(a, b) {
	$.ajax({
	    url: '/Account/Clipboard/Clipboard.asmx/AddToClipboard',
	    type: 'POST',
	    dataType: 'xml',   
	    data: "a="+a+"&b="+b,
	    timeout: 10000,
	    error: function(request, errtype){
	        alert(request.responseText);
	        alert('Error saving - please try again later!');
	    },
	    success: function(xml){
	        // do something with xml    
		    if ( $("int", xml).text() == 0 ) {
			    alert("Saved to Clipboard\nYour clipboard can be found under Account > My Clipboard");
		    } else if ( $("int", xml).text() == 1 ) {
			    //alert("You must be logged in to save an article.");
			    tb_show('Login', '/Remote/Login.aspx?continue=%2FRemote%2Fdone%2Easpx%3Fa%3D'+a+ '%26b%3D'+b+'&TB_iframe=true&height=300&width=500',false);
		    } else if ( $("int", xml).text() == 2 ) {
			    alert("Article already saved to Clipboard\nYour clipboard can be found under Account > My Clipboard");
		    } else {
			    alert("Unknown error (" + $("int", xml).text() + ") occurred.  Please try again later.");
		    }
	    }
	});
}

function
Save2(a, b) {
	$.ajax({
	    url: '/Account/Clipboard/Clipboard.asmx/AddToClipboard',
	    type: 'POST',
	    dataType: 'xml',   
	    data: "a="+a+"&b="+b,
	    timeout: 10000,
	    error: function(request, errtype){
	        alert(request.responseText);
	        alert('Error saving - please try again later!');
	    },
	    success: function(xml){
	        // do something with xml    
		    if ( $("int", xml).text() == 0 ) {
			    alert("Article saved");
			    top.tb_remove();
		    } else if ( $("int", xml).text() == 1 ) {
			    //alert("You must be logged in to save an article.");
			    //tb_show('Login', '/Remote/Login.aspx?continue=%2FRemote%2Fdone%2Easpx%3Fa%3D'+a+ '%26b%3D'+b+'&TB_iframe=true&height=300&width=500',false);
		    } else if ( $("int", xml).text() == 2 ) {
			    alert("Article already saved.");
			    top.tb_remove();
		    } else {
			    alert("Unknown error (" + $("int", xml).text() + ") occurred.  Please try again later.");
			    top.tb_remove();
		    }
	    }
	});
}

function 
WriteDate(){
	var today = new Date();
	var months = new Array(
		"January", "February", "March", "April", 
		"May", "June", "July", "August", "September", 
		"October", "November", "December"
	);
	var m = today.getMonth();
	var d = today.getDate();	
	var y = today.getFullYear();	
	document.write(months[m] + " " + d + ", " + y);
}