function openPage(page, docTitle, exload){
	var ifr = document.getElementById("contentIframe"); 
	ifr.style.height = "1px"; 
	
	if(docTitle != "undefined")
		setDocumentTitle(docTitle); 
	
	ifr.src = BASE + page;
	document.getElementById("aLoader").style.display = "block";
	//if(height) ifr.style.height = height + 'px';
	
	if(ifr.style.display == "none"){
		ifr.style.display = "block";
		document.getElementById("p_wrapper").removeChild(ifr.nextSibling);
	}

	if(thisMovie("menuFlash").getExtended()){
		ExtendFlashHeight();
	}
	else if (thisMovie("menuFlash").getShrinked()){
		ShrinkFlashHeight();
	}
	else if(exload){
		checkAndSetFlashHeightBeforeIn();
	}
}

function getDocHeight(doc) {
	var docHt = 0, sh, oh;
		if (doc.height) docHt = doc.height;
	else if (doc.body) {
		if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
		if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
		if (sh && oh) docHt = Math.max(sh, oh);
	}
	return docHt;
}

function setIframeHeight(iframeName) {
	
	var iframeName = 'contentIframe';
	var iframeWin = window.frames[iframeName];
	var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
	if ( iframeEl && iframeWin ) {
		iframeEl.style.height = "1px"; // helps resize (for some) if new doc shorter than previous
		var docHt = getDocHeight(iframeWin.document);
		// need to add to height to be sure it will all show
		document.getElementById("aLoader").style.display = "none";
		if (docHt) iframeEl.style.height = docHt + 20 + "px";
	}
	//alert(document.getElementById(movieName));
	//thisMovie("menuFlash").focus();*/
}

function thisMovie(movieName){
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? document.getElementsByTagName("object")[0] : document.getElementsByTagName("embed")[0];
}

function changeFlashContent(model, submenu, subsubmenu, needToShrink, needToExtend){
	thisMovie("menuFlash").changeFlashContent(model, submenu, subsubmenu, needToShrink, needToExtend);
	if(needToShrink){
		ShrinkFlashHeight();
	}
	else if(needToExtend){
		ExtendFlashHeight();
	}
	else checkAndSetFlashHeightBeforeIn();
}

function checkAndSetFlashHeightBeforeIn(){
	if(document.getElementById('flashMenu').className != "normal"){
		document.getElementById('flashMenu').className = "normal";
	}
}

function ShrinkFlashHeight(){
	document.getElementById('flashMenu').className = "shrinked";
}

function ExtendFlashHeight(){
	document.getElementById('flashMenu').className = "";
}

function setDocumentTitle(title){
	if(document.title.indexOf(':')>0){
		var	title_split = document.title.split(":");
		var new_title = title + ':' + title_split[1];
	}
	else
		var new_title = title + ':' + document.title;
		
	document.title = new_title;
}

function toggleForm(fid, toggler){
 	var fel = document.getElementById(fid);
	if(fel.style.display == "none"){
		fel.style.display = "block";
		toggler.innerHTML = "Inchide formularul de contact";
		parent.setIframeHeight();
	}
	else{
		fel.style.display = "none";
		if(document.getElementById("errorCont").className != "") document.getElementById("errorCont").style.display = "none";
		toggler.innerHTML = "Trimite mesaj la Subaru Oradea"
		parent.setIframeHeight();
	}
 }
 
 function listContact(){
 	window.print();
 }
 
 //promotie
 
function loadPromotie(){
	if(document.getElementById("newsHeads") == undefined) return;
	
	var cont = document.createElement("div");
	cont.className = "promotie";
	cont.id = "promoCont";
		
	var close = document.createElement("a");
	close.href = "#"
	close.innerHTML = "inchide X";
	
	cont.onclick = function(){
		this.style.display = "none";
		return false;
	}
	
	close.onclick = function(){
		this.parentNode.style.display = "none";
		return false;
	}	
	
	var img = document.createElement("embed"); //embed for flash img for pic
	
	img.onclick = function(){
		this.parentNode.style.display = "none";
		
		return false;
	}	
	
	//for flash
	
	img.setAttribute("position","relative");	
	img.setAttribute("width",900);
	img.setAttribute("height",280);
	img.setAttribute("src","flash/Promotie/subaru_gpl.swf");	
	img.setAttribute('pluginspage', 'http://www.macromedia.com/go/getflashplayer/');
	img.setAttribute('type', 'application/x-shockwave-flash');
	img.setAttribute("wmode", "transparent");
	
	
	//for img z
	//img.src = "images/promotii/einvitatie.jpg";
	
	var div = document.createElement("div");
	cont.appendChild(div);
	
	cont.appendChild(close);	
	cont.appendChild(img);

	cont.style.height = document.body.clientHeight + 'px';
	
	document.body.appendChild(cont);
}
