
// POPUP FÖR GENERISK TIPSA EN VÄN FÖNSTER
function tipFriend(type,dbId) {
	window.open('/docs/service/tipFriend.asp?tipType='+ type +'&id='+ dbId,'','width=500,height=250,toolbar=no,directories=no,menubar=no,scrollbars=yes,left=' + (screen.width/2-250) + ',top=' + (screen.height/2-100));
}

function englishTipFriend(type,dbId) {
	window.open('/docs/service/englishTipFriend.asp?tipType='+ type +'&id='+ dbId,'','width=500,height=250,toolbar=no,directories=no,menubar=no,scrollbars=yes,left=' + (screen.width/2-250) + ',top=' + (screen.height/2-100));	
}


// DÖLJER OCH VISAR INNEHÅLL I ETT DIV ELEMENT
function toggleView(id)
{
    var div = document.getElementById(id);
    if(div.style.display == 'block' || div.style.display == '')
    {
        div.style.display = 'none';
    }
    else
    {
        div.style.display = 'block';
    }
}

// KOLLAR ATT EN GILTIG E-POSTADRESS HAR ANGETTS
function validateEmail(strEmail){
	var str=strEmail;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if (filter.test(str))
		return true;
	else
		
		return false;

	
}

// KOLLAR ATT EN KNAPP VALTS I EN GRUPP AV RADIOBUTTONS
// ANVÄND RADIOBUTTON GRUPPENS NAMN SOM PARAMETER
function valRadioButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}


// VALIDERAR TÄVLINGSFORMULÄRET PÅ
// docs/service/for_artists/landing_emailfriends.asp
	function validateQuizForm(intLang)
	{
		if(intLang == 1)
		{
			strAnswer = "Du måste välja ett svarsalternativ";
			strName = "Du måste skriva ditt namn";
			strEmail = "Du måste skriva din e-postadress";
			strValidEmail1 = "Du måste ange en giltig e-postadress";
			strValidEmail2 = "Din väns e-postadress måste vara giltig";
			strDemands = "Du har inte uppfyllt följande krav i formuläret";
			strValid = "Du måste fylla i informationen korrekt innan du kan delta i tävlingen!";
		}
		else if(intLang == 2)
		{
			strAnswer = "You must choose an answer";
			strName = "You must enter your name";
			strEmail = "You must enter your e-mailadress";
			strValidEmail1 = "You must enter a valid e-mailadress";
			strValidEmail2 = "Your friends e-mail must be valid";
			strDemands = "You have not forfilled the following requirements";
			strValid = "You must enter the information correctly before you can participate in the contest";
		}
		else if(intLang == 3)
		{
			strAnswer = "You must choose an answer";
			strName = "You must enter your name";
			strEmail = "You must enter your e-mailadress";
			strValidEmail1 = "You must enter a valid e-mailadress";
			strValidEmail2 = "Your friends e-mail must be valid";
			strDemands = "You have not forfilled the following requirements";
			strValid = "You must enter the information correctly before you can participate in the contest";
		}
		missingInfo = '';
		
		if(valRadioButton(quizContestForm.quizAnswer) == null)
		{
			missingInfo += "\n - "+ strAnswer;
		}
		if(document.quizContestForm.quizName.value == '')
		{
			missingInfo += "\n - "+ strName;
		}
		if(document.quizContestForm.quizMyEmail.value == '')
		{
			missingInfo += "\n - "+ strEmail;
		}

		if(document.quizContestForm.quizMyEmail.value > "")
		{
			if(!validateEmail(document.quizContestForm.quizMyEmail.value))
				missingInfo += "\n - "+ strValidEmail1;
		}

		if(document.quizContestForm.quizFriendEmail.value > "")				
		{
			 if(!validateEmail(document.quizContestForm.quizFriendEmail.value))
			 	missingInfo += "\n - "+ strValidEmail2;
		}

		if(missingInfo != '')
		{
		 	missingInfo ="_____________________________\n" +
			strDemands +":\n" +
			missingInfo + "\n_____________________________" +
			"\n"+ strValid;
			alert(missingInfo);
			return false;			
		}
		else
		{
			return true;
				
		}
	}


