function blurAnchors() {
	if (document.getElementsByTagName) {
		var a = document.getElementsByTagName("a");
		for (var i = 0; i < a.length; i++) {
			a[i].onfocus = function() { this.blur(); };
		}
	}
}
window.onload = blurAnchors;


function toggleDisplay(o,i) {
	var o = document.getElementById(o);
	if (o.style.display=='block') {
		o.style.display='none';
	} else {
		o.style.display='block';
	}
}

//Create custom method
function dmethod(apa){
	alert(apa);
}



tabs = new function() {
	this.currentTab = null;
	
	this.open = function(n) {
		this.newTab = 'tab_'+n;
		if (this.currentTab) { toggleDisplay(this.currentTab); }
		toggleDisplay(this.newTab);
		this.currentTab = this.newTab;
	}
}

var activeFormObj = null;
function closeActiveFormPayment(s)
{
	var obj = document.getElementById(s);
	if (obj != activeFormObj && activeFormObj != null)
		activeFormObj.style.display = 'none';
}

function clickFormPayment(s)
{
	closeActiveFormPayment(s);
	if (s == 'card')
	{
	}
	else if (s == 'bank')
	{
		var current = document.getElementById("bank");
		current.style.display = 'block';
		activeFormObj = current;
	}
	else
	{
	}
}

//toogle-function, to expand and collapse areas   
function toggle(elementID){
	var target1 = document.getElementById(elementID)
	if (target1.style.display == 'none') {
		target1.style.display = 'block'
	} else {
		target1.style.display = 'none'
	}
}
function toggleDisplay(e){
	toggle(e);
}




function makeRequest(url,target,callback) {
	var httpRequest;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) { // IE
		try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) {
			try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) {}
		}
	}

	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	httpRequest.onreadystatechange = function() {
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				if (target)
				{
					target.innerHTML = (httpRequest.responseText);
				}
			} else {
				alert('There was a problem with the request.' + httpRequest.responseText);
			}
			if (callback)
			{
				callback();
			}
		}
	};
	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}


chat = new function() {
	this.hej = 2;

	this.openChat = function(cid,u,s) {
		// Döda timern
		if (keepAliveTimer) { window.clearTimeout(keepAliveTimer); }
		document.getElementById('qStatus').innerHTML = 'Chatten ska nu ha öppnats i ett nytt fönster. Om den inte har öppnats, kontrollera att din webbläsare inte blockerar popupfönster och ladda sedan om sidan.';
		// Öppna ett fönster!
		this.openW(cid,u,s);
	}
	this.openW = function(cid,u,s) {
		window.open('/default.asp?pageID=185&cID='+cid+'&uID='+u+'&sID='+s,'Chat'+u+s,'status=0,menu=0,height=635,width=660');
	}
	this.openSurvey = function(pageID, intChatSessionID) {
		// Öppna ett fönster!
		window.open('/default.asp?pageID=' + pageID +'&intChatSessionID='+intChatSessionID,'_blank', 'status=0,menu=0,height=600,width=640');
	}
}


var surveyWindow = null;

function openSurvey(step,hash)
{
	surveyWindow = window.open('?pageID=350&s='+hash+'&step='+step,'survey','width=640,height=600,toolbar=0,status=0');
}
	

function writeE(a) {
	document.write ('<a href="mailto:'+a+'">'+a.replace('%40','@')+'</a>');
}


var showWarning = true
function ignoreWarnings() {
	showWarning = false;
}


function getFlashVersion()
{
	var v = new deconcept.SWFObjectUtil.getPlayerVersion();
	return v.major;
}


function checkMaxLength(o,l)
{
	if (o.value.length>l)
	{
		o.value = o.value.substring(0,l);
		alert('Texten får max vara '+l+' tecken lång');
		return false;
	}
	return true;
}

function showhideMembership(v)
{
	if (v.length>2)
	{
//		document.getElementById('membershippan').style.display = 'block';
		//visa fältet om ifall du vill bli medlem etc
	}
	else
	{
		document.getElementById('membershipplease').checked=false;
	}
}

function confirmDelete()
{
	if (document.getElementById("delete_user").checked)
	{
		if (confirm("Är du säker på att du vill radera din profil?"))
		{
			document.theForm.submit();	
		}
	}
	else
	{
		document.theForm.submit();	
	}
}

function chkcontrol(j) {
	var total=0;
	for(var i=0; i < document.questionnaire_form.q_1.length; i++){
		if(document.questionnaire_form.q_1[i].checked){
			total =total +1;
		}
		if(total > 3){
			document.questionnaire_form.q_1[j].checked = false ;
			return false;
		}
	}
}
