

function GetMenu()
{
	document.write("<div id="menudiv"
			style="display: none; position: relative; top: 0px; left: 0px">
		<ul id="menubar">
			<li class="currentArticle"><a
				href='index.html'>Hem </a></li>
			<li><a href='Presentation.html'>Presentation
			</a>
			<ul id="1" class="categoryLevel-1">
				<li><a href='Om+NovaMedTech.html'>Om
				NovaMedTech</a></li>
				<li><a href='Forvantade+effekter.html'>F&#246;rv&#228;ntade
				effekter</a></li>
				<li><a
					href='Organisation+och+styrelse.html'>Organisation och
				styrgrupp</a></li>
			</ul>
			</li>
			<li><a href='Projekt+-+startsida.html'>Projekt
			</a>
			<ul id="2" class="categoryLevel-1">
				<li> <a href='Projektomraden.html'>Projektomr&#229;den
				</a></li>
				<li><a href='Pagaende+projekt.html'>P&#229;g&#229;ende
				projekt </a></li>
				<li><a href=''>Avslutade projekt </a></li>
				<li><a href='Nya+projekt.html'>Nya
				projekt </a></li>
			</ul>
			</li>
			<li><a href='Natverk.html'>N&#228;tverk
			</a>
			<ul id="3" class="categoryLevel-1">
				<li><a href='Natverk.html'>N&#228;tverk</a>
				</li>
				<li><a href='Lankar.html'>L&#228;nkar</a></li>
			</ul>
			</li>
			<li><a href='Kalendarium.html'>Aktuellt
			</a>
			<ul id="4" class="categoryLevel-1">
				<li><a href='Kalendarium.html'>Kalendarium</a>
				</li>
				<li><a href='Pressrum.html'>Pressrum</a>
				</li>
				<li><a href='Innovationsmassa.html'>Nyheter
				2009 </a>
				<ul id="5" class="categoryLevel-1">
					<li><a href='Innovationsmassa.html'>Innovationsm&#228;ssa</a></li>
				</ul>
				</li>
			</ul>
			</li>
		</ul>
		</div>");
}


function DisableEnableLinks(xHow){
  objLinks = document.links;
  for(i=0;i<objLinks.length;i++){
    //objLinks[i].disabled = xHow;
    //link with onclick
    if(objLinks[i].onclick && xHow){  
        objLinks[i].onclick = new Function("return false;" + objLinks[i].onclick.toString().getFuncBody());
    }
    //link without onclick
    else if(xHow){  
      objLinks[i].onclick = function(){return false;}
    }
    //remove return false with link without onclick
    else if(!xHow && objLinks[i].onclick.toString().indexOf("function(){return false;}") != -1){            
      objLinks[i].onclick = null;
    }
    //remove return false link with onclick
    else if(!xHow && objLinks[i].onclick.toString().indexOf("return false;") != -1){  
      strClick = objLinks[i].onclick.toString().getFuncBody().replace("return false;","")
      objLinks[i].onclick = new Function(strClick);
    }
  }
}

String.prototype.getFuncBody = function(){ 
  var str=this.toString(); 
  str=str.replace(/[^{]+{/,"");
  str=str.substring(0,str.length-1);   
  str = str.replace(/\n/gi,"");
  if(!str.match(/\(.*\)/gi))str += ")";
  return str; 
} 


function ClickToPrint(objToPrint)
     {
	
	   docPrint=window.open("","Print");
        docPrint.document.open();
        docPrint.document.write('<html><head><title>' + window.location + '</title>');
        docPrint.document.write('</head><body onLoad="self.print();self.close();">');
        docPrint.document.write('</left><br/><table border=0><tr><td width=60%><left><font face="windings">');
        docPrint.document.write(document.getElementById(objToPrint).innerHTML);  
        docPrint.document.write('</td></tr></table></left></font></body></html>');
        docPrint.document.close();  
        docPrint.focus();

}


function viewTip(){
var strForm;
var tempX = 0
var tempY = 0
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.

   /* pos = getElementPosition(obj);*/
	tempX = 100;//pos.left;
    tempY =  100;//pos.top-60;
	
	


if (document.getElementById("tipPopUp")) {
document.getElementById("tipPopUp").style.display="inline";
} else {
var divTag = document.createElement("div");
divTag.id = "tipPopUp";

//divTag.style.position = "absolute";
//divTag.style.top = "" + tempY +"px";
//divTag.style.left= "" + tempX +"px"
divTag.className ="tipPopup";


  
strForm = "<form class='tipForm' id='tipForm' method='post' action='php/sendtip.php' >";

strForm += "<input type='hidden' name='location' value='"+ document.location +"' />";
strForm += "<div class='tipHeadline'>Tipsa om " + document.title + "</div>";

strForm += "<label>Till (E-post) * <input  class=\"validate['email'] text-input\" type='text' name='mailTo'/></label>";
strForm += "<label>Från (E-post) * <input type='text' class=\"validate['email'] text-input\" name='mailFrom'/></label>";
strForm += "<label>Från (Namn) *<input type='text' class=\"validate['String'] text-input\" name='name'/></label>";
strForm += "<label>Meddelande<textarea type='text' class=\"text-input\" name='message'></textarea>";
strForm += "<input type=\"button\" name=\"send\" value=\"Skicka\" onclick=\"return  checkForm(document.getElementById('tipForm'))\"/>";

strForm += "</form>";

divTag.innerHTML = "<div class='closeError' onclick=\"document.getElementById('tipPopUp').style.display='none'\"><img src='css/close.png'/></div><div class='errorMessage'>" +  strForm + "</div>";
document.body.appendChild(divTag);
}


}


// JavaScript Document
function checkForm(objForm)
{
  if (document.getElementById("manatoryTxt")) {
		document.getElementById("manatoryTxt").style.display="none";
  }	
	
  var strMessage ='';
  var arClass, bValid;
  var objField = objForm.getElementsByTagName('*');

  for (var iFieldCounter=0; iFieldCounter<objField.length; iFieldCounter++)
  {
    
	
	 switch (objField[iFieldCounter].className)
      {
        case "validate['string'] text-input":
	 		objField[iFieldCounter].style.border = "1px solid #A5A8B8";
			
			switch (objField[iFieldCounter].value) {
				case "Navn":
				objField[iFieldCounter].value = "Namn";
				bValid = false;
				break;
				case "Telefon":
				objField[iFieldCounter].value = "Telefon";
				bValid = false;
				break;
				case "Postnummer":
				objField[iFieldCounter].value = "Postnummer";
				bValid = false;
				break;
				default:
				bValid = isString(objField[iFieldCounter].value.replace(/^\s*|\s*$/g, ''));
			
			}
	
			
        
		break;
        case "validate['number'] text-input" :
		objField[iFieldCounter].style.border = "1px solid #A5A8B8";
           	//objField[iFieldCounter].className = "text-input";
		 bValid = isNumber(objField[iFieldCounter].value);
           break;
				case "validate['email'] text-input" :
				objField[iFieldCounter].style.border = "1px solid #A5A8B8";
				bValid = isEmail(objField[iFieldCounter].value);
		
          	break;
			
			case "validate['require'] text-input" :
				
				objField[iFieldCounter].style.border = "1px solid #A5A8B8";
				
				if (objField[iFieldCounter].value == "") {
					bValid = false;
				}
				
		
				
				//isEmail(objField[iFieldCounter].value);
		
          	break;
        
	case "validate['checkbox'] checkbox-input":
		objField[iFieldCounter].style.border = "1px solid #A5A8B8";		
		if (!objField[iFieldCounter].checked)  bValid = false;
		
	break;

	default:
           bValid = true;
      }
	
	
	     if (bValid == false)
      {
        // If this field is invalid, leave the testing early,
        // and alert the visitor to this error
       // alert('Please review the value you provided for ' + objField[iFieldCounter].name);
        strMessage='<b>Fyll i nödvändiga fält!</b><br /><br />';
		objField[iFieldCounter].select();
		objField[iFieldCounter].style.border = "1px solid red";
		
		// objField[iFieldCounter].className = "text-input-error";
        //objField[iFieldCounter].focus();
       // return false;
      }
	
	
 }

	if (strMessage!='') {
		//alert(strMessage);
		 // return false;
		createDiv(strMessage,objForm)
		//makeMovable("div1", "div1");
		return false;
	} else {
		// return true;
		 objForm.submit();
	}


}



function getElementPosition(objForm){
var offsetTrail = objForm;
var offsetLeft = 0;
var offsetTop = 0;
while (offsetTrail){
offsetLeft += offsetTrail.offsetLeft;
offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent;
}
if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
offsetLeft += document.body.leftMargin;
offsetTop += document.body.topMargin;
}

return {left:offsetLeft,top:offsetTop};
}


function createDiv(strInnerHmtl,obj){

var tempX = 0
var tempY = 0
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.

    pos = getElementPosition(obj);
	tempX = pos.left;
    tempY =  pos.top-60;
	
	


if (document.getElementById("manatoryTxt")) {
document.getElementById("manatoryTxt").style.display="inline";
} else {
var divTag = document.createElement("div");
divTag.id = "manatoryTxt";

divTag.style.position = "absolute";
divTag.style.top = "" + tempY +"px";
divTag.style.left= "" + tempX +"px"
divTag.className ="dynamicDiv";
divTag.innerHTML = "<div class='formWarning'><img src='css/warning.png'/></div><div class='closeError' onclick=\"document.getElementById('manatoryTxt').style.display='none'\"><img src='css/close.png'/></div><div class='errorMessage'>"+ strInnerHmtl + "</div>";
document.body.appendChild(divTag);
}


}


function isString(strValue)
{
  return (typeof strValue == 'string' && strValue != '' && isNaN(strValue));
}

function isNumber(strValue)
{
  return (!isNaN(strValue) && strValue != '');
}



function isEmail(strValue)
{
  var objRE = /^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/;

  return (strValue != '' && objRE.test(strValue));
}

var makeMovable = function(target, handle) {
  target = $(target);

  $(handle).onmousedown = function(event) {
    var initialXOffset = target.offsetLeft - event.pageX;
    var initialYOffset = target.offsetTop - event.pageY;

    document.onmousemove = function(event) {
      target.style.left = event.pageX + initialXOffset;
      target.style.top = event.pageY + initialYOffset; 
    }

    document.onmouseup = function() {
      document.onmousemove = null;
      document.onmouseup = null;
    }

    return false;
  }
}
