// JavaScript Document


//Finne ut om browser er IE6 I såfall bruke gif bilde og ikke png i iframe bakgrunn
var ie6=is_ie6();

function is_ie6(){
     return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));
}
	
function byttStyle(style) {
document.getElementById('stylesheet').href = style;
}


function getFlashMovie(movieName) { 
var isIE = navigator.appName.indexOf("Microsoft") != -1;   
return (isIE) ? window[movieName] : document[movieName];  }  

function tilbakeF() {      
getFlashMovie(hovedFilNavn).alphaTilbakeCom(); 
}  

function tilbakeKnapp(){
	
}

function settInnIframe(url){	

  var ref=document.getElementById("overFlash");
	
	var myDiv = document.createElement('div');	 

    myDiv.setAttribute('id','iframeRamme');
    myDiv.style.backgroundColor = 'transparent';
	myDiv.style.zIndex='3';	
	myDiv.style.width = '640px';
    myDiv.style.height = '740px';
	myDiv.style.position='absolute';
	myDiv.style.left='175px';	  
	myDiv.style.top='0px';	
	myDiv.style.backgroundImage="url(bakrans.png)";				
	myDiv.style.backgroundRepeat="no-repeat";
	

	
	 //Lage tilbakeKnapp
	 var tilbakeKnapp = document.createElement('img');
	 tilbakeKnapp.setAttribute('id', 'tilbakeKnapp');
     tilbakeKnapp.style.marginLeft='25px';	
	 tilbakeKnapp.style.marginTop='25px';	
	 tilbakeKnapp.style.marginBottom='0px';
	 tilbakeKnapp.onclick = function(){iFrametilbake();}; 
     tilbakeKnapp.onmouseover= function(){return tilbakeKnappOver()};  
	 tilbakeKnapp.onmouseout= function(){return tilbakeKnappUt()};
	 tilbakeKnapp.setAttribute('src', 'tilbakeknapp.gif');
	 tilbakeKnapp.style.zIndex='1';  
	 tilbakeKnapp.style.cursor = "hand";	 
	 myDiv.appendChild(tilbakeKnapp);
	 
    
   
   var iframeElement = document.createElement("iframe");
   iframeElement.setAttribute('id', 'iframe');   
   iframeElement.setAttribute('src', url);
   iframeElement.setAttribute('width', '560');
   iframeElement.setAttribute('height', '637');
   iframeElement.style.marginLeft="37px"; 
   iframeElement.style.marginTop='5px';	
   iframeElement.style.borderStyle='none';	
   iframeElement.setAttribute('frameborder', '0');
   iframeElement.style.border='1px solid #999999';
   iframeElement.setAttribute('allowtransparency', 'true');

   myDiv.appendChild(iframeElement);    
   ref.appendChild(myDiv); 
   
   
   
   
   	 //Lage del på facebook knapp
	 
	 var delUrl="http://www.facebook.com/share.php?u=http://www.kvadraturen.no/index.php?url="+url;
	 
	 var faceikon = document.createElement('img');
	 faceikon.setAttribute('id', 'faceikon');
	 //faceikon.setAttribute('href',delUrl);
     faceikon.style.marginLeft='580px';	
	 faceikon.style.marginTop=' 2px';	
	 faceikon.onclick = function(){window.location = delUrl;}; 
	 faceikon.setAttribute('src', 'faceicon.gif');
	 faceikon.style.zIndex='4';  
	 faceikon.style.cursor = "hand";

	 
	 myDiv.appendChild(faceikon);
	 

	 	  
} 



   
function initOgVisFanboks(){	   
   
	var ref=document.getElementById("overFlash");
	
	var myDiv = document.createElement('div');	 

    myDiv.setAttribute('id','fanboks');
    myDiv.style.backgroundColor = 'white';
	myDiv.style.zIndex='2';	
	myDiv.style.width = '210px';
    myDiv.style.height = '370px';
	myDiv.style.position='absolute';
	myDiv.style.right='0px';	  
	myDiv.style.top='0px';	
	

	
   //Lage iframe element med referanse til fanboks url
   var iframeElement = document.createElement("iframe");
   iframeElement.setAttribute('id', 'iframe');   
   iframeElement.setAttribute('src','http://www.kvadraturen.no/fanboks.html');
   iframeElement.setAttribute('width', '210');
   iframeElement.setAttribute('height', '370'); 
   iframeElement.setAttribute('frameborder', '0'); 
   iframeElement.setAttribute('allowtransparency', 'true');
   iframeElement.setAttribute('scrolling', 'no');
   iframeElement.style.right='0px';
   iframeElement.style.left='0px';

   myDiv.appendChild(iframeElement);    
   ref.appendChild(myDiv); 
	
   }




function fjernIframe(){
	        
				
            elem = document.getElementById('overFlash');
			elem.removeChild(document.getElementById('iframeRamme'));	
		
}

	
function iFrametilbake() {
		tilbakeF();
        fjernIframe();  
}


function visIframe(url){	
gjemFanboks();
settInnIframe(url);
}

function visFanboks(){
var fanboks=document.getElementById("fanboks");
fanboks.style.display='';
}

function gjemFanboks(){
var fanboks=document.getElementById("fanboks");
fanboks.style.display='none';	
}


function tilbakeKnappOver(){
document.images["tilbakeKnapp"].src="tilbakeknappOver.gif";
return true;
}

function tilbakeKnappUt(){
document.images["tilbakeKnapp"].src="tilbakeknapp.gif";
return true;
}
