Sniffer = function()
{
	var browser;			// Complete user agent information

	var isOpera;			// Is the browser "Opera"
	var isMSIE;				// Is the browser "Internet Explorer"
	var isFirefox;			// Is the browser "Firefox"
        var isSafari;                   // Is the browser "Safari"
	var navigatorVersion;	// Browser version
}

Sniffer.prototype = {
	init : function()
	{
		this.browser = navigator.userAgent;
		this.isMSIE = (this.browser.toLowerCase().indexOf('msie')>=0)?true:false;
		this.isFirefox = (this.browser.toLowerCase().indexOf('firefox')>=0)?true:false;
                this.isSafari = (this.browser.toLowerCase().indexOf('safari')>=0)?true:false;
		this.isOpera = (this.browser.toLowerCase().indexOf('opera')>=0)?true:false;
		this.navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
	}
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.validEmail = function()  {
    var ere = new RegExp("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");
    return this.match(ere);
}
String.prototype.validTags = function()  {
    var ere = new RegExp("^[a-zA-Z0-9,\\s]*$");
    return this.match(ere);
}
String.prototype.reduce = function(l)
{
    var words=this.split(" ");
    var numwords=words.length;
    var output=[];
    var ol=0,cWord=0,w=0;
    for(w=0; w<numwords; ++w)
    {
        cWord=words[w];
        cwl=cWord.length;
        if((ol+cwl)<=l)
        {
            output.push(cWord);
            ol+=cwl+1;
        }
        else break;
    }
    return output.join(" ");
}
function checkall(field, act)  {
    for (var i = 0; i < field.length; i++)  {
    	field[i].checked = act ;
    }
}
function getCookie(name) {
    var start = document.cookie.indexOf(name + "=" );
    var len = start + name.length + 1;
    if (!start && name != document.cookie.substring( 0, name.length ) ) {
        return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
function showPlayButton(id)  {
    document.getElementById(id).style.display='block';
}
function hidePlayButton(id)  {
    document.getElementById(id).style.display='none';
}
function popupWin(url, w, h, scroll)  {
    var topX = (window.screen.width-w) / 2;
    var topY = (window.screen.height-h) / 2;
    return window.open(url, 'popupWin', 'top='+topY+',left='+topX+',width='+w+',height='+h+',menubar=no,location=no,scrollbars='+
                scroll+',status=no,resizable=no,dependent=yes,modal=yes');
}
