<!--
function runMany(){
	/* Detta script finns att hämta på http://www.jojoxx.net och får användas fritt så länge som dessa rader står kvar. */
	var year = 2007;
	var month = 9;
	var day = 21;
	
	// Do not edit lines below.
	var then = new Date(year,month-1,day);
		var now = new Date();
		if (now < then){
			var days  = Math.floor((then-now)/(1000*60*60*24));
			//var hours = Math.floor((then-now-days*1000*60*60*24)/(1000*60*60));
			//var mins  = Math.floor((then-now-days*1000*60*60*24-hours*1000*60*60)/(1000*60));
			//var secs  = Math.floor((then-now-days*1000*60*60*24-hours*1000*60*60-mins*1000*60)/(1000));
			//var tsecs = Math.floor((then-now-days*1000*60*60*24-hours*1000*60*60-mins*1000*60-secs*1000)/(100));
			document.getElementById("counter").innerHTML = "<span style='font-size:25px; font-weight:bold;'>"+days+ "</span> dagar kvar till invigningen av Piteås nya shoppingcenter";
		}
		setTimeout("runMany();",100);
	}
	
function checkAction(inAction, inForm){
	document.getElementById("action").value = inAction;
	/*document.getElementById(inForm).submit();*/
	return true;
}

function verifyDelImg(confirmMessage){
	if (confirm(confirmMessage)){
		return true;
	}
	else{
		return false;
	}	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function validation(inAction){
	locUser = trim(document.getElementById("txtUser").value);
	locPass = trim(document.getElementById("txtPass").value);
	
	if ((locUser == '') || (locPass == '')){
		alert("Både användarnamn och lösenord måste fyllas i!");	
	}
	else{
		checkAction(inAction);	
	}
}

function trim(inString)
{
   return inString.replace(/^\s*|\s*$/g,"");
}

function right(str, n){
	if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function isValidEmail(email, required) {
	if (required == undefined){   // if not specified, assume it's required
		required = true;
	}
	
	if (email == null){
		if (required){
			return false;
		}
		
		return true;
	}
	
	if (email.length == 0){  
		if (required){
			return false;
		}
		return true;
	}
	
	if (! allValidChars(email)){  // check to make sure all characters are valid
		return false;
	}
	
	if (email.indexOf("@") < 1){ //  must contain @, and it must not be the first character
		return false;
	} 
	else if (email.lastIndexOf(".") <= email.indexOf("@")){  // last dot must be after the @
		return false;
	} 
	else if (email.indexOf("@") == email.length){  // @ must not be the last character
		return false;
	} 
	else if (email.indexOf("..") >= 0){ // two periods in a row is not valid
		return false;
	} 
	else if (email.indexOf(".") == email.length){  // . must not be the last character
		return false;
	}
	
	return true;
}

function allValidChars(email){
	var parsed = true;
  	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  	
	for (var i=0; i < email.length; i++) {
    	var letter = email.charAt(i).toLowerCase();
    	if (validchars.indexOf(letter) != -1)
      	continue;
    	parsed = false;
    	break;
  	}
	
  	return parsed;
}

function setFocus(){
	document.getElementById("txtUser").focus();
}

function displayError(inValue){
	if (inValue != ''){
		alert(inValue);
		return false;
	}
}


function verifyRemover(confirmMessage){
	if (confirm(confirmMessage)){
		return true;
	}
	else{
		return false;
	}
}

function checkActionDropdown(inAction, control){
	if(document.getElementById(control).options[document.getElementById(control).selectedIndex].value != ''){
		document.getElementById("action").value = inAction;
		document.getElementById("form1").submit();
	}
}

function validationNewUser(inAction, inForm, inFlag){
	var strError;
	strError = "";
	
	locUser = trim(document.getElementById("txtUser").value);
	locPass = trim(document.getElementById("txtPass").value);
	if(inFlag == '-1'){locName = trim(document.getElementById("txtStoreName").value);}
	
	if(locUser == ''){strError += "Användare saknas!\n";}
	
	if(locPass == ''){strError += "Lösenord saknas!\n";}
	
	if(inFlag == '-1'){
		if(locName == ''){
			strError += "Butikens namn saknas!\n";
		}
	}
	
	if(strError.length > 0){
		alert(strError);
		return false;	
	}
	else{
		checkAction(inAction, inForm);
	}
}

function isValidEmail(email, required) {
	if (required == undefined){   // if not specified, assume it's required
		required = true;
	}
	
	if (email == null){
		if (required){
			return false;
		}
		
		return true;
	}
	
	if (email.length == 0){  
		if (required){
			return false;
		}
		return true;
	}
	
	if (! allValidChars(email)){  // check to make sure all characters are valid
		return false;
	}
	
	if (email.indexOf("@") < 1){ //  must contain @, and it must not be the first character
		return false;
	} 
	else if (email.lastIndexOf(".") <= email.indexOf("@")){  // last dot must be after the @
		return false;
	} 
	else if (email.indexOf("@") == email.length){  // @ must not be the last character
		return false;
	} 
	else if (email.indexOf("..") >= 0){ // two periods in a row is not valid
		return false;
	} 
	else if (email.indexOf(".") == email.length){  // . must not be the last character
		return false;
	}
	
	return true;
}

function allValidChars(email){
	var parsed = true;
  	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  	
	for (var i=0; i < email.length; i++) {
    	var letter = email.charAt(i).toLowerCase();
    	if (validchars.indexOf(letter) != -1)
      	continue;
    	parsed = false;
    	break;
  	}
	
  	return parsed;
}

function validationStore(){
	var strError;
	strError = "";
	
	locStore = trim(document.getElementById("txtStore").value);
	locStoreText = trim(document.getElementById("txtStoreText").value);
	locPhone = trim(document.getElementById("txtPhone").value);
	locEmail = trim(document.getElementById("txtEmail").value);
	locImage = right(document.getElementById("txtUpload").value, 4);
	
	if(locStore == ''){strError += "Butikens namn saknas!\n"}
	if(locStoreText == ''){strError += "Text till butiken saknas!\n";}
	if(locPhone == ''){strError += "Telefon saknas!\n";}
	if(locEmail == ''){
		strError += "E-post saknas!\n";
	}
	else{
		if (isValidEmail(locEmail) == false){
			strError += "Felaktigt format på e-postadressen!\n";
		}
	}
	
	if(document.getElementById("plan1").disabled == false && document.getElementById("plan2").disabled == false && document.getElementById("plan3").disabled == false && document.getElementById("cafe").disabled == false && document.getElementById("service").disabled == false){
		if(document.getElementById("plan1").checked == false && document.getElementById("plan2").checked == false && document.getElementById("plan3").checked == false && document.getElementById("cafe").checked == false && document.getElementById("service").checked == false){
			strError += "Plan saknas!\n";
		}
	}
	
	if(locImage != ''){
		locImage = locImage.toLowerCase();
		
		if((locImage != '.jpg') && (locImage != '.bmp')){	
			strError += "Felaktigt filformat. Bara jpg och bmp tillåtna!\n";
		}
	}
	
	if(strError.length > 0){
		alert(strError);
		return false;	
	}
	else{
		return true;
	}
	
}

function validationPage(inAction, inForm){
	var strError;
	strError = "";
	
	locTitle = trim(document.getElementById("txtTitle").value);
	locKeyword = trim(document.getElementById("txtKeywords").value);
	locDescription = trim(document.getElementById("txtDesc").value);
	tinyMCE.triggerSave(true, true);
	var locContent = tinyMCE.getContent('txtContent');
	
	if(locTitle == ''){strError += "Titel saknas!\n"}
	if(locKeyword == ''){strError += "Nyckelord saknas!\n"}
	if(locDescription == ''){strError += "Beskrivning saknas!\n"}
	if(locContent == ''){strError += "Innehåll saknas!\n"}
	
	if(strError.length > 0){
		alert(strError);
		return false;	
	}
	else{
		checkAction(inAction, inForm);
	}
	
}

function removeIMG(inId){
	if(confirm("Är du säker på att du vill ta bort bilden?")){
		document.location.href = 'butiker.asp?action=removeimg&storeId='+inId;
	}
}

function validationNewsletter(inAction, inForm){
	var strError;
	strError = "";

	if(inAction == "send"){
		i = 0;
		len = document.forms[0].send_to.length;
		receiver_checked = 0;
		while(i < document.forms[0].length){
			element = document.forms[0].elements[i];
			
			if(element.type){
				if(element.name == "send_to"){
					if(element.checked){
						receiver_checked = 1;
					}
				}
			}
		   
			i = i + 1;
		}
	
	
		if(receiver_checked == 0){
			alert("Du måste välja minst en mottagare");
			return false;
		}
	}
	
	if(inAction == "send"){
		if(!confirm("Vill du skicka nyhetsbrevet?")){
			return false;
		}
	}

	locSubject = trim(document.getElementById("txtSubject").value);
	locContent_upper = trim(document.getElementById("txtContent_upper").value);
	locContent_lower = trim(document.getElementById("txtContent_lower").value);
	
	//document.getElementById("action").value = "save";
	document.getElementById("action").value = inAction;
	
	document.forms[0].submit();
	
	return true;
	
}

function validationNewsletterRecipient(inAction, inForm, inId){
	
	with(inForm){
	
		locName = trim(document.getElementById("name_"+inId+"").value);
		locEmail = trim(document.getElementById("email_"+inId+"").value);
		locCityPostal = trim(document.getElementById("city_postal_"+inId+"").value);
	
		if(trim(locName) == ""){
			alert("Ett namn måste anges");
			return false;
		}
		
		if(trim(locCityPostal) == ""){
			alert("Ort eller postnr måste anges");
			return false;
		}
		
		if(trim(locEmail) == ""){
			alert("En epost måste anges");
			return false;
		}else{
			if(!isValidEmail(locEmail)){
				alert("Eposten är inte valid");
				return false;
			}
		}
		
		document.getElementById("action_").value = inAction;
		document.getElementById("save_id_").value = inId;
		
		document.getElementById("form23").submit();
		
		return true;
	}
	
}

function removeRecipient(inID, inEmail){
	
	if(!confirm("Vill du verkligen ta bort prenumeranten "+inEmail+"?")){
		return false;
	}
	
	document.getElementById("save_id").value = ""+inID+"";
	document.getElementById("action").value = "delRecipient";

	document.getElementById("form232").submit();
}

function validationNewsletterRecipient_new(inAction, inForm){
	var strError;
	strError = "";
	
	locName = trim(document.getElementById("name").value);
	locEmail = trim(document.getElementById("email").value);
	locCityPostal = trim(document.getElementById("city_postal").value);
	
	if(trim(locName) == ""){
		alert("Ett namn måste anges");
		return false;
	}
	
	if(trim(locCityPostal) == ""){
		alert("Ort eller postnr måste anges");
		return false;
	}
	
	if(trim(locEmail) == ""){
		alert("En epost måste anges");
		return false;
	}else{
		if(!isValidEmail(locEmail)){
			alert("Eposten är inte valid");
			return false;
		}
	}
	
	document.getElementById("action").value = inAction;
	
	document.forms[0].submit();
	
	return true;
	
}

function toggle_checkboxes(form, checkbox_name){
	with(form){
		i = 0;			
		len = checkbox_name.length;
		toggle_status = check_all.checked;
		
		while(i < length){		
			element = elements[i];
			
			if(element.name.substring(0, len) == checkbox_name){
				element.checked = toggle_status;
			}
			
			i = i + 1;
		}
	}
}
//-->