﻿  function openWin(pURL)
  {
        parent.open(pURL,'Announcement','height=300,width=450,left=5,top=5,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no');
  }
  function showSuggestion(valPage){
		var name = "";
		name = window.open (valPage, "Suggestions", "height=255, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no, width=430, top=5, left=5");
		name.focus();
	}
	
	function showHelp(valPage){
		var name = "";
		name = window.open (valPage, "WebHelp", "height=500, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no, width=700, top=5, left=5");
		name.focus();
	}
	
	function showRecordings(valPage){
		var name = "";
		name = window.open (valPage, "Recordings", "height=500, location=no, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no, width=700, top=5, left=5");
		name.focus();
	}
	
	function showContact(valPage){
		var name = "";
		name = window.open (valPage, "Contact", "height=375, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no, width=550, top=5, left=5");
		name.focus();
	}
  function searchFormSubmit(){

		var searchText = document.getElementById('txtSearchTop').value; 		
		var lbox = document.getElementById('ddlSearchType');
		var searchType = lbox.selectedIndex;

		if (searchText == "")
		{	
			alert("Search Text must be filled in to perform search.")
		}
		else if (searchType == "")
		{
			alert("Search Type must be filled in to perform a search.")			
		}
		else
		{
			top.document.location.href = "Include/Search.aspx?searchType=" + searchType + "&searchText=" + searchText;			
		}
		return false;
    }

function Toggle (senderId, ctrlId, collapseText, expandText)
{
    var sender = document.getElementById(senderId);
    var ctrl = document.getElementById(ctrlId);
    if (ctrl.style.display == 'none')
    {
        ctrl.style.display = 'block';
        sender.innerHTML = collapseText;
    }
    else 
    {
        ctrl.style.display = 'none';
        sender.innerHTML = expandText;
    }
}

function openWindow(url, width, height)
{
    window.open(url,'CSDS','scrollbars=yes,menu=no,status=yes,width=' + width + ',height=' + height + ',top=5,left=5');
}

function OpenUserProfile(id)
{
    window.open('../User/UserProfile.aspx?Id=' + id + '&PageIsPopUp=true&bHideNav=True', 'UserProfile', 'scrollbars=yes,menu=no,status=yes,width=900,height=500,top=5,left=5')
}

function RequestExtension(CId, ExtensionRequestTypeId)
{
	location.href = "../CWA/ExtensionRequest.aspx?TId=" + ExtensionRequestTypeId + "&CId=" + CId;
}

function getCookie(cookie_name)
{
    if (document.cookie.length == 0)
        return '';
        
    var startIndex = document.cookie.indexOf(cookie_name + '=');
    if (startIndex != -1)
    {
        startIndex = startIndex + cookie_name.length + 1;
        endIndex = document.cookie.indexOf(';', startIndex);
        
        if (endIndex == -1)
            endIndex = document.cookie.length;
        
        var value = unescape(document.cookie.substring(startIndex, endIndex));
        return value;
    }
}

function setCookie(cookieName, cookieValue, expireDays)
{
    var expirationDate = new Date();
    expirationDate.setDate( expirationDate.getDate() + expireDays);
    
    var cookie = cookieName + '=' + escape(cookieValue);
    
    document.cookie =  cookie;
    
}

function BrowserDetect()
{
    this.browser = '';
    this.version = '';
    this.OS = '';
}

BrowserDetect.prototype.init = function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	}

BrowserDetect.prototype.searchString = function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	}

BrowserDetect.prototype.searchVersion =  function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},

BrowserDetect.prototype.dataBrowser = [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	];

BrowserDetect.prototype.dataOS = [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	];

