function doPopup(f)
{
  newwin = null;
  newwin = window.open('', 'Betalning','scrollbars,status,width=550,height=600');
  newwin.focus();
  if(!self.name) { self.name = 'shopwin'; }
  if (!newwin.opener) { newwin.opener = self; }
  f.opener.value = self.name;
  return true;
}

var win= null;
function openPopup(url,w,h)
{
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=yes,';
	settings +='resizable=no';
	win=window.open(url,'window',settings);
	
	if(parseInt(navigator.appVersion) >= 4) {win.window.focus();}
}

function Toggle(item)
{
   obj=document.getElementById(item);
   visible=(obj.style.display!="none");
   key=document.getElementById("x" + item);
   
   if(visible)
   {
     obj.style.display="none";
   }
   else
   {
      obj.style.display="block";
   }
}

function updatePaymentLayer(text, image)
{
	id = 'paymentLayer';
	imageId = 'paymentImageLayer';
	imageHtml = '<img border="0" src="images/paymentproviders/'+image+'" alt="" style="margin-right: 10px">';
	
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
		
		x2 = document.getElementById(imageId);
		x2.innerHTML = '';
		x2.innerHTML = imageHtml;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
		
		x2 = document.all[imageId];
		x2.innerHTML = imageHtml;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		x.document.open();
		x.document.write(text);
		x.document.close();
		
		x2 = document.layers[imageId];
		x2.document.open();
		x2.document.write(imageHtml);
		x2.document.close();
	}
}

function countdown_clock(year, month, day, hour, minute, format)
{
	//I chose a div as the container for the timer, but
	//it can be an input tag inside a form, or anything
	//who's displayed content can be changed through
	//client-side scripting.
	html_code = '<div id="countdown"></div>';
	
	document.write(html_code);
	
	countdown(year, month, day, hour, minute, format);
}
         
function countdown(year, month, day, hour, minute, format)
{
	Today = new Date();
	Todays_Year = Today.getFullYear() - 2000;
	Todays_Month = Today.getMonth() + 1;                  
	
	//Convert both today's date and the target date into miliseconds.                           
	Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
	                     Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
	Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
	
	//Find their difference, and convert that into seconds.                  
	Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
	
	if(Time_Left < 0)
	Time_Left = 0;
	
	element = document.getElementById('countdown');
	
	switch(format)
	{
		case 0:
		    //The simplest way to display the time left.
		    element.innerHTML = Time_Left + ' sek';
		    break;
		case 1:
		    //More datailed.
		    days = Math.floor(Time_Left / (60 * 60 * 24));
		    Time_Left %= (60 * 60 * 24);
		    hours = Math.floor(Time_Left / (60 * 60));
		    Time_Left %= (60 * 60);
		    minutes = Math.floor(Time_Left / 60);
		    Time_Left %= 60;
		    seconds = Time_Left;
		    
		    dps = 'ar'; hps = ''; mps = ''; sps = '';
		    //ps is short for plural suffix.
		    if(days == 1) dps ='';
		    if(hours == 1) hps ='';
		    if(minutes == 1) mps ='';
		    if(seconds == 1) sps ='';
		    
		    element.innerHTML = days + ' dag' + dps + '<br>';
		    element.innerHTML += hours + ' h' + hps + ' ';
		    element.innerHTML += minutes + ' min' + mps + ' ';
		    element.innerHTML += seconds + ' sek' + sps;
		    break;
		default: 
		    countdown.innerHTML = Time_Left + ' sek';
	}
	   
	//Recursive call, keeps the clock ticking.
	setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}

function fader()
{
	var quotes = document.getElementById("quotes");
	var fader = new Fadomatic(quotes, 1.1, 0);
	fader.textArray[0] = '&quot;Sprayen har räddat livet på mig minst en gång&quot;<div class="quote-small"><br>- Ann-marie, Taxiförare, Stockholm -<\/div>';
	fader.textArray[1] = '&quot;Två killar hotade mig att jag skulle ge dom min mobil, dom gick direkt när jag tog fram sprayen&quot;<div class="quote-small"><br>- Simon, Malmö -<\/div>';
	fader.textArray[2] = '&quot;På väg hem mitt i natten försökte någon dra iväg mig, jag använde sprayen och kom undan!&quot;<div class="quote-small"><br>- Malin, Linköping -<\/div>';
	fader.textArray[3] = '&quot;Tack! Era sprayer fungerar verkligen, jag vet för jag har tyvärr behövt använda den redan.&quot;<div class="quote-small"><br>- Josefine, Halmstad -<\/div>';
	fader.textArray[4] = '&quot;Jag blev överfallen av ett gäng, men kom undan tack vare larmet!&quot;<div class="quote-small"><br>- Klas, Göteborg -<\/div>';
	fader.textArray = shuffle(fader.textArray);
	fader.hide();
	fader.fadeIn();
}

shuffle = function(o)
{
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
}