/** Javascript */



function check_Accept()
{
 	document.body.style.cursor='wait';

  if (document.Conditionform.accept.checked == false)
 	{ 
		alert('Du skal accepterer købsbetingelserne'); 
		document.Conditionform.accept.focus();
 	 	document.body.style.cursor='default';
		return false;	
    }


	return true;
   
}

function check_Helpform()
{
 	document.body.style.cursor='wait';

    	if (isEmail('Email:', document.helpform.email.value) )
 	{ 
 		document.helpform.email.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }


	return true;
   
}

function check_OrderFormDelivery()
{
/**
	if(document.orderform.transport[0].checked)
	{
		document.orderform.textsubname.disabled=true;
		document.orderform.textsubname.style.display ='none';	
		document.orderform.textsubadress1.disabled=true;
		document.orderform.textsubadress1.style.display ='none';	
		document.orderform.textsubadress2.disabled=true;
		document.orderform.textsubadress2.style.display ='none';	
		document.orderform.textsubzipcode.disabled=true;
		document.orderform.textsubzipcode.style.display ='none';	
		document.orderform.textsubcity.disabled=true;
		document.orderform.textsubcity.style.display ='none';	
		document.orderform.textsubcountry.disabled=true;
		document.orderform.textsubcountry.style.display ='none';	
		document.orderform.textsubphone.disabled=true;
		document.orderform.textsubphone.style.display ='none';	
		document.orderform.emailsub.disabled=true;
		document.orderform.emailsub.style.display ='none';	
		document.orderform.textsubcompany.disabled=true;
		document.orderform.textsubcompany.style.display ='none';	
		
	}
	if(document.orderform.transport[1].checked)
	{
		document.orderform.textsubname.disabled=false;
		document.orderform.textsubname.style.display ='';	
		document.orderform.textsubadress1.disabled=false;
		document.orderform.textsubadress1.style.display ='';	
		document.orderform.textsubadress2.disabled=false;
		document.orderform.textsubadress2.style.display ='';	
		document.orderform.textsubzipcode.disabled=false;
		document.orderform.textsubzipcode.style.display ='';	
		document.orderform.textsubcity.disabled=false;
		document.orderform.textsubcity.style.display ='';	
		document.orderform.textsubcountry.disabled=false;
		document.orderform.textsubcountry.style.display ='';	
		document.orderform.textsubphone.disabled=false;
		document.orderform.textsubphone.style.display ='';	
		document.orderform.emailsub.disabled=false;
		document.orderform.emailsub.style.display ='';	
		document.orderform.textsubcompany.disabled=false;
		document.orderform.textsubcompany.style.display ='';	
	}
**/
}


function check_OrderForm()
{

 	document.body.style.cursor='wait';

	
//	if(document.orderform.transport[1].checked)
//	{ 
	  if (isEmpty('Navn:', document.orderform.textsubname.value) )
	 	{ 
	 		document.orderform.textsubname.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	
	
	  if (isEmpty('Adresse:', document.orderform.textsubadress1.value) )
	 	{ 
	 		document.orderform.textsubadress1.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	
	  if (isEmpty('Postnr:', document.orderform.textsubzipcode.value) )
	 	{ 
	 		document.orderform.textsubzipcode.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	        
	  if (isEmpty('By:', document.orderform.textsubcity.value) )
	 	{ 
	 		document.orderform.textsubcity.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	
	  if (isEmpty('Land:', document.orderform.textsubcountry.value) )
	 	{ 
	 		document.orderform.textsubcountry.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	
	  if (isEmpty('Telefon:', document.orderform.textsubphone.value) )
	 	{ 
	 		document.orderform.textsubphone.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
	        
	   
	  if (isEmail('Email:', document.orderform.emailsub.value) )
	 	{ 
	 		document.orderform.emailsub.focus();
	 	 	document.body.style.cursor='default';
			return false;	
	  }
// 	}
	return true;
   
}

function check_AccountForm()
{
 	document.body.style.cursor='wait';



    	if (isEmpty('Navn:', document.userform.textname.value) )
 	{ 
 		document.userform.textname.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }


    	if (isEmpty('Adresse:', document.userform.textadress1.value) )
 	{ 
 		document.userform.textadress1.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }



    	if (isEmpty('Postnr:', document.userform.textzip.value) )
 	{ 
 		document.userform.textzip.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }
        
    	if (isEmpty('By:', document.userform.textcity.value) )
 	{ 
 		document.userform.textcity.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

    	if (isEmpty('Land:', document.userform.textcountry.value) )
 	{ 
 		document.userform.textcountry.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

    	if (isEmpty('Telefon:', document.userform.textphone.value) )
 	{ 
 		document.userform.textphone.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }
        

    	if (document.userform.email.value != document.userform.email2.value )
 	{ 
		alert('Email adressen er ikke identisk'); 
 		document.userform.email.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

    	if (isEmail('Email:', document.userform.email.value) )
 	{ 
 		document.userform.email.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

    	if (document.userform.password.value != document.userform.password2.value )
 	{ 
		alert('Adgangskoden er ikke identisk'); 
 		document.userform.email.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

    	if (isEmpty('Adgandskode:', document.userform.password.value) )
 	{ 
 		document.userform.password.focus();
 	 	document.body.style.cursor='default';
		return false;	
        }

	return true;

}


function check_SearchForm()
{
	document.searchform.submit();
}


function check_ContactForm()
{
 	document.body.style.cursor='wait';
    	if (isEmpty('Navn:', document.contactform.textName.value) )
 	{ 
 		document.contactform.textName.focus();
 	 	document.body.style.cursor='default';
 	 	return false;
        }

    	if (isEmail('Email:', document.contactform.textEmail.value) )
 	{ 
 		document.contactform.textEmail.focus();
 	 	document.body.style.cursor='default';
 	 	return false;
        }

    	if (isEmpty('Text:', document.contactform.textMessage.value) )
 	{ 
 		document.contactform.textMessage.focus();
 	 	document.body.style.cursor='default';
 	 	return false;
        }
        	
 	 	return true;
}

function MouseOverImages()
{
 	document.body.style.cursor="hand";
}

function MouseLeftImages()
{
 	document.body.style.cursor="default";
}

function isEmpty(fieldname, streng) 
{ 
	if (streng.length == 0 || streng.charAt(streng.length-1) == ' ' || streng.charAt(0) == ' ') 
	{ 
		alert(fieldname + ' må ikke være tomt eller starte og slutte med mellemrum'); 
		return true;
	}
}

function isInteger(fieldname, streng) 
{ 
	var Chars = '1234567890'; 
	if (streng.length == 0 || streng.charAt(streng.length-1) == ' ' || streng.charAt(0) == ' ') 
	{ 
		alert(fieldname + ' må ikke være tomt eller starte og slutte med mellemrum'); 
		return true;  
	} 
	for (var i = 0; i < streng.length; i++) 
		if (Chars.indexOf(streng.charAt(i),0) < 0) 
		{ 
			alert(fieldname+' er ikke en integer'); return true; 
		}
}

function isEmail(fieldname, streng) 
{   
	var a = streng.indexOf('@', 1 ); 
	var Dot = 0; 
	var Domain = ''; 
	var Chars = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM-_.@'; 
	for (var i = streng.length; i > 0; i--)    
	{ 
		if (streng.charAt(i) == '.')  
		{ 
			Dot = i; 
			i = 0; 
		} 
		else 
		Domain = Domain + streng.charAt(i); 
	} 
	if ((a > Dot) || (a < 0) || (Dot < 0) || (streng.length < 6) || ((a + 1) >= Dot) || (Domain.length < 2)) 
	{ 
		alert(fieldname+' er ikke korrekt en e-mail adresse'); 
		return true; 
	} 
	for (var i = 0; i < streng.length; i++) 
		if (Chars.indexOf(streng.charAt(i),0) < 0) 
		{ 
			alert(fieldname+' er ikke korrekt en e-mail adresse'); 
			return true; 
		} 
}

function DeleteFunction()  
{
	if(confirm('Vil du slette din brugerprofil ?'))
		return true; 
	else
		return false; 	
}

function swapcolor(obj, val) {

              if (val==-1)

                     color = "#ff9900"

              if (val==0)

                     color = "#ffffff"

              if (val==1)

                     color = "#f2f2f2"

              obj.style.backgroundColor = color;

}  

function changeTab(tab)
{
	var i;
	var t;
	for(i=1;i<5;i++)
	{
		t="t"+i;
		var tabls=document.getElementById(i);
		var tabs=document.getElementById(t);
		if(i==tab)
		{
		   tabls.style.display="block";
		   tabs.className="tab_active";
		}
		else
		{
		   tabls.style.display="none";
   		   tabs.className="tab_inactive";
		}
	}
}
