/// <reference path="jquery-1.2.6.js"/>

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// Title : Philips Portal Global Functions
// Author : Rapp UK
//
// Description : Core functionality for standard sites developed by Rapp UK
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


function pageup(e) {
	UAGENT = navigator.userAgent.toUpperCase();
	if (UAGENT.indexOf("MSIE") >=0) { posi = event.y; }
	else { posi = e.pageY; }
	moveObje(posi);
}
	function moveObje(position) {
	move = position / 15;
	point = parseInt(position - move);
	scrollTo(0,point);
	if (point > 0) { setTimeout("moveObje(point)",15); }
}

function InfoWindow (url, name, height, width) {
	window.open(url, name, "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,height="+height+",width="+width);
	return false;
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

//the following(1.3) will not work with the jquery-1.2.6 lib ref in the master page

/*

jQuery(document).ready(function(){
	// The slashes are to ensure the period is in the url, the $ is to make sure it is the end of the url, the i is to make it case insensitive.
	filetypes = /\.doc$|\.xls$|\.exe$|\.zip$|\.pdf$|\.mp3$|\.psd$/i;
	jQuery("a").live("click", function(){
		// Track downloads (links with a given extension)
		if (jQuery(this).attr("href").match(filetypes)) {
			// The URL needs to be changed for each site this is applied to.
			var host = location.host.replace(/\./, "\\.");
			var pattern = new RegExp('^(http\:\/\/)*(www\.)*('+host+')*\/','i');
			var url = jQuery(this).attr("href").replace(pattern, "");
			pageTracker._trackPageview("/downloads/" + url);
		}
	});
});

*/

function getQueryVariable(variable) {
    var vars = window.location.search.substring(1).split('&');
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split('=');
        if (pair[0] == variable)
            return pair[1];
    }

    return '';
}

var blogs = {
    deleteComment: function(url, pageId) {
        $.get(url, { "ajax": "true", "command": "delete", "arg": pageId });

        $('#item-' + pageId).hide('slow');
        return false;
    }
};
