
function searchAjaxPro(domId)
{
	var a = OBOS.Articles.Search();
	//var b = documkent.getElementById(domId);
	//b.style['visible'] = '';
}
function SearchFunc()
{
// var t=OBOS.Templates.Sites.Portal.SearchResult();
 OBOS.Templates.Sites.Portal.DoSearch();

document.getElementById('SearchResultDiv').innerHTML = ''; 

}

function HidesearchContainer()
{

document.getElementById('SearchResultDiv').style.visibility =  'hidden';
}
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

function doPosition() {


var Top=(MainContentDiv.offsetHeight/2) - (SearchResultDiv.offsetHeight/2);
var Left=(MainContentDiv.offsetWidth/2) - (SearchResultDiv.offsetWidth/2);

if(Top > 0 && Top<40)
{
SearchResultDiv.style.top = Top;
}
else
{
  SearchResultDiv.style.top = 32;
}

if(Left > 0 && Left<108)
{

SearchResultDiv.style.left = Left;
}
else
{
SearchResultDiv.style.left = 107;
}


}


	function show_data(strName,WebConfigSearchUrl,CurrentUrl){ 
			if (strName.length > 0){ 
				//Append the name to search for to the requestURL 
			document.getElementById('SearchResultDiv').style.visibility =  'visible';
	          /*  document.getElementById('SearchResultDiv').innerHTML ='<iframe id="IframeSearchResult"scrolling="no" width="620" height="554" src="http://localhost/ObosIframeSearch/?query=' +strName +'></iframe>';*/
	     
	          var SearchResultdiv=document.getElementById('SearchResultDiv');
	          var SearchUrl='<iframe scrolling="no" frameborder="0"  width="620" height="554" id="IframeSearchResult" ';
	          var SearchUrl=SearchUrl+ 'src=\"' + WebConfigSearchUrl;
	           var SearchUrl=SearchUrl+ strName+CurrentUrl
	            var SearchUrl=SearchUrl+ '\" ';
	               var SearchUrl=SearchUrl+ '</iframe>';
	          SearchResultdiv.innerHTML=SearchUrl;
	  


	          
/*$("#SearchResultDiv").html("<iframe id='IframeSearchResult' scrolling='no' width='620' height='554' src='http://localhost/ObosIframeSearch/?query=" +strName +"></iframe>");*/
	            
			} 
			else { 
			
				document.getElementById('SearchResultDiv').style.visibility =  'hidden';

			} 
		}

function windowWidth() {
    var winW = 840, winH = 460;

    if (parseInt(navigator.appVersion) > 3) {
        if (navigator.appName == "Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") != -1) {
            winW = document.body.offsetWidth;
            winH = document.body.offsetHeight;
        }
    }
    return winW;
}


function sendAssessmentForm(form){
	var err = '';
	if(form.assessment_name.value == '') err += '- navn\r';
	if(form.assessment_address1.value == '') err += '- adresse\r';
	if(form.assessment_ziparea.value == '') err += '- poststed/postnummer\r';
	if(form.assessment_email.value == '') err += '- e-post\r';
	if(form.assessment_phone.value == '') err += '- telefon/mobil\r';
	
	if(err != '') {
		alert('Vennligst fyll inn:\r' + err);	
	} else {
		form.submit();
	}
}

function menuOver(elem,action) {
	if(elem) {		
		if(action == 'over') {
			elem.className  =  elem.className  + '-rollover';
		} else {
			var css = elem.className;
			if(css != '') elem.className  = css.replace('-rollover','');
		}		
	}
}

/*function showMenu(num) {
	// Deactivate menus
	for(var i = 0; i < 15; i++) {
		var div = document.getElementById('menu' + i);
		if(div) {			
			if(num == i) { //div.className = div.className + ' active';
				if(div.className.indexOf('active') > 0) {
					div.className = div.className.replace(' active','');
				} else {
					div.className = div.className + ' active';
				}		
			} else {
					div.className = div.className.replace(' active','');
			}		
			
		}
	}		
}*/




function fixchars(val) {
	return val.replace(/['_,%`"~#]/g, "");	
}


function sendTip() {
	var elem = document.getElementById('Form1').elements;
	var fromemail, toemail,subject,message,url, documentid;
	
	for(var i = 0; i < elem.length; i++)
	{		
			switch(elem[i].name) {
				case "fromemail": fromemail=fixchars(elem[i].value); break;
				case "toemail": toemail=fixchars(elem[i].value); break;
				case "subject": subject=fixchars(elem[i].value); break;
				case "message":  message=fixchars(elem[i].value); break;
				case "documentid":  documentid=fixchars(elem[i].value); break;
				case "url":  url=fixchars(elem[i].value); break;
			} 						
	}
	response = OBOS.Templates.Documents.Tip.ucTip.AjaxSendTip(documentid,fromemail, toemail,subject, message, url, sendTipResult);
}
function sendTipResult(response) {
	var rtn = document.getElementById('tip-result');	
	if (response.error!=null) 
	{	
		rtn.innerHTML = response.error;
		return;
	}
	rtn.innerHTML = response.value;
}



function sendETip(documentid) {
	var elem = document.getElementById('Form1').elements;
	var toemail1,toemail2,toemail3,documentid;
	
	for(var i = 0; i < elem.length; i++)
	{		
			switch(elem[i].name) {
				case "CI_EMAIL1": toemail1=fixchars(elem[i].value); break;
				case "CI_EMAIL2": toemail2=fixchars(elem[i].value); break;
				case "CI_EMAIL3": toemail3=fixchars(elem[i].value); break;								
			} 						
	}
	response = OBOS.Templates.Documents.eMarketing_Tip.ucFull.AjaxSendETip(documentid,toemail1,toemail2,toemail3, sendETipResult);
}
function sendETipResult(response) {
	var rtn = document.getElementById('message-result');	
	if (response.error!=null) 
	{	
		rtn.innerHTML = response.error;
		return;
	}
	rtn.innerHTML = response.value;
}


