function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
	return "";
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		for (i=0; i<menu_items.length-1; i++){
		
			stat = " var o"+i+" = newImage('images/menu/menu"+i+"-o.jpg');";
			eval(stat);
			stat = "var ov"+i+" = newImage('images/menu/menu"+i+"-ov.jpg');";
			eval(stat);
			stat = "var org"+i+" = newImage('images/menu/menu"+i+".jpg');";
			eval(stat);
		}
		for (i=1; i<=3; i++){
			stat = "var stbbtm"+i+" = newImage('images/stbbtm_"+i+".gif');";
			eval(stat);
			stat = "var tbbtm"+i+" = newImage('images/tbbtm_"+i+".gif');";
			eval(stat);
		}		
		preloadFlag = true;	
	}
	preloadFlag = true;	
}


function go(itemno, target){
	if (target=="_self" || target=="_parent")
		parent.window.location=menu_items[itemno][0];
	else
		window.open (menu_items[itemno][0]);
}

function mover(itemno){
	theitem = document.getElementById("m"+itemno);
	if (menu_items[itemno][2]=='menu')
		newbgimg = menu_items[itemno][1]+"-ov.jpg";
	else
		newbgimg = menu_items[itemno][1]+"v.jpg";
		
	theitem.style.background = "url('images/menu/"+newbgimg+"')  no-repeat";
	
	theitem.className="menu-ov";
	for (i=0; i<menu_items.length-1; i++){
		if (itemno==i){
			setsmhidden("sm"+i, false);
		}else{
			setsmhidden("sm"+i, true);
		}
	}
}

function mout(itemno){
	theitem = document.getElementById("m"+itemno);
	theitem.className=menu_items[itemno][2];
	newbg = "images/menu/"+menu_items[itemno][1]+".jpg";
	theitem.style.background = "url('"+newbg+"') no-repeat";
}
function setsmhidden(theid, ishide){
	if (ishide){
		document.getElementById(theid).style.visibility="hidden";
		document.getElementById(theid).style.display="none";
	}else{
		document.getElementById(theid).style.visibility="visible";
		document.getElementById(theid).style.display="block";
	}
}

function navmout(itemno){
	mout(itemno);
	theitem = document.getElementById("sm"+itemno);
	theitem.style.visibility="hidden";
	theitem.style.display="none";
}
function navmin(itemno){
	mover(itemno);
	theitem = document.getElementById("sm"+itemno);
	theitem.style.visibility="visible";
	theitem.style.display="block";
}


function swapinterface(){
	if (gologin!=1){
		e=document.getElementById("flashintranet");
		e.style.marginTop =  '-82px';
		changecontents();
	}else{
		document.location.href=goLoginURL+"/";
	}
}

var flashx=122;
var flashy=34;
var flashtop=0;
var flashleft=0;
function changewidth(){
    if(flashx>172){
        changeheight();
		return;
    }
    flashx += 10;
	flashleft -=10;
	e=document.getElementById("flashintranet");
    e.style.marginRight = flashleft + 'px';
    e.style.width = flashx + 'px';
    t=setTimeout("changewidth();",100);
}

function changeheight(){
    if(flashy>82){
		changecontents();
        return;
    }
    flashy += 5;	
	flashtop -=5;
    e=document.getElementById("flashintranet");
	e.style.marginTop = flashtop + 'px';
	e.style.height = flashy + 'px';
    t=setTimeout("changeheight();",100);
}

function changecontents(){
//alert(gologin);
	
	html = "<form method=post action='login.php'><div id=loginbox><img src='images/login_box.png'></div><div id=loginbox style='padding-top:28px; padding-left:10px;'><div class=label>User name:</div><div class=thetext style='width:40px;'><input name=uname id=uname></div><div class=footer style='height:1px;width:1px;overflow:hidden'><br></div><div class=label>Password:</div><div class=thetext><input name=pwd id=pwd type=password></div><div class=footer style='height:1px;width:1px;overflow:hidden'><br></div><div class=savepwd style='width:80px;'><input name=savepwd id=savepwd type=checkbox>Save details</div><div class=loginbtn  style='width:50px;'><input type=image src='images/login_btn.gif' ><input type=hidden name=gologin value='logbox'><img src='images/spacer.gif' width=5 height=1></div><div class=footer><br></div></div></form>";
	document.getElementById("flashintranet").innerHTML = html;
	
}
function open_printwindow(modulename){
	switch (modulename){
		case 'products_hq':
		case 'products_products_qoins':
		case 'products_products_capriss':
			url = modulename+'.php?printthispage=1'+'&lnk='+thissection;
		break;
		case 'news_announcements':
		case 'news_product':
		case 'news_tradefair':
		case 'news_press':
			url = modulename+'.php?printthispage=1';
		break;
		default:
			url = "printthispage.php?thepage="+modulename;
		break;
	}
	window.open(url, "printwindow", 'width=700,height=500,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	return false;
}

divscrollstep=5; 
timer=null;
function divscroll(divname,d){ 
	document.getElementById(divname).scrollTop +=(d==0?-divscrollstep:divscrollstep) 
	timer=setTimeout("divscroll('"+divname+"', "+d+")",64) 
} 

function cleardivscroll(){ 
	clearTimeout(timer) 
}

function go_divanchor(divname, anchorname){
	document.getElementById(divname).scrollTop = document.getElementById(anchorname).offsetTop;
}
function showPhoto(photoName, width, height, scroll){
	width = width+30;
	height = height+50;
	newwin=window.open("photo.php?img="+photoName, "OKIA", "location=0,resizable=1,status=0,scrollbars="+scroll+",width="+width+",height="+height);
	newwin.moveTo(50,50);
	return false;
}


function sethidden(theid, ishide){
	if (theid!=''){
		if (ishide){
			document.getElementById(theid).style.visibility="hidden";
			document.getElementById(theid).style.display="none";
		}else{
			document.getElementById(theid).style.visibility="visible";
			document.getElementById(theid).style.display="block";
		}
	}
}

var slideno = 1 
function goslide(divprevname, divnextname, imgdiv, folder, prefix, suffix, maxslidepages, goslidenum){
	slideno = slideno + goslidenum;	
	if (slideno == 1){
		sethidden (divprevname, true);
		sethidden (divprevname+"1", true);
	}else {
		sethidden (divprevname, false);
		sethidden (divprevname+"1", false);
	}
	if (slideno == maxslidepages){
		sethidden (divnextname, true);		
		sethidden (divnextname+"1", true);		
	}else{
		sethidden (divnextname, false);		
		sethidden (divnextname+"1", false);		
	}
	if (slideno < 10) imgid = "0"+slideno;
	else imgid = slideno;	
	//newfile = folder + "/"+prefix+imgid+suffix;
	newfile = "rohs_content.php?item="+prefix+imgid;
	document.getElementById(imgdiv).src = newfile;
	
	

	return false;
}

function rightclick(){
/********************/
	alert("OKIA. All Rights Reserved ");
	return false;
/********************/
}

function view_more(modulename, width, height){
	url = modulename+"_more.php";
	window.open(url, "printwindow", 'width='+width+',height='+height+',location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	return false;
}

var curr_newsid = '';
var parent_newsid = '';
function newsdebug(txt){
	//$('debug').value = txt+"\n"+$('debug').value ;
}
function showNews(currIndex, parentIndex, rootIndex, lv0Index){
	linkobj = document.getElementById('newstitle'+currIndex);
	if (linkobj.className == 'news-f1'){
		if (lv0Index==''){
			if (curr_newsid != '' && curr_newsid != parentIndex){
					showHideNewsItem(curr_newsid, false);
				if (parent_newsid != '' && parent_newsid != parentIndex){
					showHideNewsItem(parent_newsid, false);
				}
			}
			curr_newsid = currIndex;
			parent_newsid = rootIndex;
		}
		showHideNewsItem(currIndex, true);
	} else {
		showHideNewsItem(currIndex, false);
		curr_newsid = '';
		rootIndex = '';
	}
}
function showHideNewsItem(id, isshow){
	linkId = 'newstitle'+id;
	itemId = 'newscontent'+id;
	if ($(linkId)!=undefined){
		if (isshow) $(linkId).className = 'news-f2';
		else $(linkId).className = 'news-f1';
	}
	if ($(itemId)!=undefined){
		if (isshow) new Effect.SlideDown(itemId);
		else new Effect.SlideUp(itemId);
	}
}

function popupwindow(url, w, h, isphoto) { //v2.0	
	w += 80;
	h += 100;
	max_h = 500;	
	if (h>max_h) h = max_h;
	newwin=window.open(url, "newwin", 'width='+w+',height='+h+',location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	newwin.resizeTo(w,h);
	newwin.moveTo(50,50);
	return false;
}
