var db='Fotboll/gais.nsf';
var returnField = '';
function setTarget(){
	for(var i = 0; i <= document.links.length - 1; i++) {
		var url = document.links[i].href.toLowerCase().split("/");
		if( url[0] !=" http:") { continue; }
		if( url[2] != "www.gais.se") { document.links[i].target = '_blank';}
	}
}
function doRemoveDocument(str){
	if( str == '' ){
		alert('It is not possible to delete this document')
	}else{
		if( confirm('Are you sure that you want to delete this document?') ){
			location.href='/'+db+'/($All)/'+str+'?DeleteDocument';
		}
	}
}
function doEditDocument(str){
	if( str == '' ){
		alert('It is not possible to edit this document')
	}else{
		location.href='/'+db+'/(edit)/'+str+'?EditDocument';
	}
}
function doCreateCopy(str){
	if( str == '' ){
		alert('It is not possible to copy this document')
	}else{
		location.href='/'+db+'/CreateCopy?OpenAgent&ParentUNID='+str;
	}
}
function doSendNewsletter(str){
	if( str == '' ){
		alert('It is not possible to send this document as a newsletter')
	}else{
		window.open('http://82.183.160.90/'+db+'/ConfirmNewsletter?OpenForm&Login&ParentUNID='+str, 'Newsletter', 'scrollbar=0,width=380,height=300,left=200,top=200');
	}
}
function startSearch(str){
if(str!=''){location.href='/'+db+'/InfoPagesSearch?SearchView&SearchMax=9999&Count=20&Start=1&Query='+escape(str)}}
function ml(n,d){
document.location.href='mailto:'+n+'@'+d}
function shellSort(arr,length,element) {
	var j, i, v, h, k, s=3;
	for (h=1; h < length; h=s*h+1);
		while (h=(h-1)/s)
			for (k=0; k<h; k++)
				for (i=k+h, j=i, v=arr[i]; i<length; arr[j+h]=v, i+=h, j=i, v=arr[i])
					while((j-=h) >= 0 && arr[j][element] < v[element])
						arr[j+h]=arr[j];
}
function sort(n){
	var t = new Array();
	var t1 = false;
	var sorted = false;
	var i = 1;
	var x = 0;
	var o = document.getElementById('cell_1_0')
	if( !t1 ){
		while( document.getElementById('cell_' + i + '_0' ) != null && i < 1000 ){
			t[i-1] = new Array();
			t[i-1][0] = document.getElementById('cell_' + i + '_0').innerText;
			for(x=1;x<=4;x++){
				o = document.getElementById('cell_' + i + '_' + x);
				t[i-1][x] = parseFloat( o.innerText.replace(',','.') );
			}
			i++;
		}
		t1 = true;
	}
	shellSort(t,t.length,n)
	for( i = 1; i <= t.length; i++){
		document.getElementById('cell_' + i + '_0' ).innerText = t[i-1][0];
		for(x=1;x<=4;x++){
			document.getElementById('cell_' + i + '_'+ x ).innerText = t[i-1][x].toFixed(0).replace('.',',');
		}
	}
}
function SelectAll(v){
	var o = document.view.elements
	for( i = 0; i < o.length; i++){
		if( o[i].type != null){
			if(o[i].type == 'checkbox') o[i].checked = v
		}
	}
}
function RemoveDocs(){
	var o = document.view.elements;
	var v = false;
	for( i = 0; i < o.length; i++){
		if( o[i].type != null){
			if(o[i].type == 'checkbox') v = v | o[i].checked
		}
	}
	if( v ){
		if( confirm('Är du helt säker på detta?') ) document.view.submit()
	}else{
		alert( 'Du har inte valt något dokument att ta bort' )
	}
}
function SaveCookie() {
var f = document.forms[0];
var Name = escape(f.Name.value);
var MailAddress = escape(f.MailAddress.value);
var Signature1 = escape(f.Signature1.value);
var Signature2 = escape(f.Signature2.value);
var the_date = new Date('December 31, 2023');
var the_cookie_date = the_date.toGMTString();
document.cookie = 'BKS_Gastbok='+Name + '&'+MailAddress+'&'+Signature1+'&'+Signature2+'; expires='+the_cookie_date; 
}
var pointer=0;var stop;var offset;var scrollWidth;
function pad(id,nr){
document.getElementById(id).style.left=nr;nr-=1;
if(nr < - offset) setText(id)
else{
if((nr<4)&&(stop==false)){stop=true;setTimeout("pad('"+id+"',"+nr+")",2000);}
else setTimeout("pad('"+id+"',"+nr+")",10);
}
}
function setText(id){
stop=false;
scrollWidth=document.getElementById('link').offsetWidth;
document.getElementById('scrolltext').innerHTML=newsarray[pointer];
offset=document.getElementById('scrolltext').offsetWidth;
pointer++;
if(pointer>=newsarray.length) pointer=0;
pad(id,scrollWidth);
}
function SC(id,fromN,toN){
id = document.getElementById( id );
var old = id.className;
id.className = ( old == toN ? fromN : toN );
}
function initXMLHttpRequest(){
var g_XMLHttpRequest_ActiveX;
var objHTTP = null;
if(window.ActiveXObject){
if(g_XMLHttpRequest_ActiveX){objHTTP = new ActiveXObject(g_XMLHttpRequest_ActiveX);}else{
var xmlhttp = new Array('Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
for(var i = 0; i < xmlhttp.length; i++) {
try{
objHTTP = new ActiveXObject(xmlhttp[i]);
if(objHTTP != null){g_XMLHttpRequest_ActiveX = xmlhttp[i];break;}}catch(e){}}}
}else{ //Mozilla
try{objHTTP = new XMLHttpRequest();}catch(e){}}
return objHTTP;
}
function Dialog(url,action,init){}
function ShowHide( id, tot, name ){
	for(var i=1; i <= tot; i++ ){
		var c = document.getElementById("cell" + name + i ).style;
		if( i == id ){
			c.backgroundColor = '#FFFFFF'
			c.borderBottomStyle = 'none'
		}else{
			c.backgroundColor = '#E0E0E0'
			c.borderBottomStyle = 'solid'
		}
	}
	
	for(var i=1; i <= tot; i++ ){
		var s = document.getElementById("section" + name + i ).style;
		if( i == id || id == 0 ){
			s.display = ''
		}else{
			s.display = 'none'
		}
	}
}
function ReplaceAllTextareas() {
	var allTextAreas = document.getElementsByTagName('textarea');
	for (var i=0; i < allTextAreas.length; i++) {
		var className = allTextAreas[i].className;
		if( className != ''){
			var oFCKeditor = new FCKeditor( allTextAreas[i].name ) ;
			oFCKeditor.BasePath = '/gemensam.nsf/FCKeditor/' ;
			oFCKeditor.Config["CustomConfigurationsPath"] = '/'+db+'/fckmyconfig.js' ;
			oFCKeditor.ToolbarSet = className;
			oFCKeditor.ReplaceTextarea() ;
		}
	}
}
function setImageField(f1,f2){
	if ( f1 ){ if ( f1.value != '') f2.value=f1.value;}
}
function showRSS(queryString, count, container){
	var rssStore = new dojox.data.GoogleFeedStore();
	rssStore.fetch({
		query:{url: queryString},
		count: count,
		onComplete: function(items, request) {
			var buffer = [""];
			var e=1;
			dojo.forEach(items, function(item){
				var title = rssStore.getValue(item, "title");
				var date = new Date( rssStore.getValue(item, "published") );
				var d1 = date.toUTCString().split(" ")
				var link = rssStore.getValue(item, "link");
				e=1-e;
				buffer.push('<div class="t14BG' + (e+1) + '"><div class="date">' + d1[1]+' '+d1[2]  + '</div><div class="title"><a href="' + link + '" target="rss">' + title + '</a></div></div>');
			});
			container.innerHTML = buffer.join("");
		}
	});
}
