
// browser detection:
var ua = navigator.userAgent;
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns4 = (document.layers)?1:0;
var ns6 = (document.getElementById && ns)?1:0;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1)?1:0;
var macie4 = (mac && !ns && parseInt(ua.substr(ua.indexOf("MSIE")+4,2)) <= 4)?1:0;
var macie = (mac && !ns)?1:0;

if (ns4)
	document.write('<LINK rel="stylesheet" href="rotecom_ns.css" type="text/css">')
else
	document.write('<LINK rel="stylesheet" href="rotecom.css" type="text/css">')


var arrMenu=new Array("images/menu_1_off.jpg","images/menu_1_on.jpg","index.php","home",
"images/menu_2_off.jpg","images/menu_2_on.jpg","despre-noi.php","despre",
"images/menu_3_off.jpg","images/menu_3_on.jpg","produse.php","produse",
"images/menu_4_off.jpg","images/menu_4_on.jpg","despre-geam.php","geam",
"images/menu_5_off.jpg","images/menu_5_on.jpg","cerere-oferta.php","cerere",
"images/menu_6_off.jpg","images/menu_6_on.jpg","contact.php","contact"
)

var strInitialTable = new String("");
var strContentTable = new String("");
//string for bottom_menu generate
var strBottomTable = new String("");
var strInitialBottomTable = new String("");

var objMenu1On = new Array();
var objMenu1Off = new Array();

function Preload(){
	// START: preload image
	for (var i=0; i<arrMenu.length; i+=4){
		var j=(parseInt(i/4))
		objMenu1On[j] = new Image();
		objMenu1On[j].src = arrMenu[i+1];

		objMenu1Off[j] = new Image();
		objMenu1Off[j].src = arrMenu[i];
	}
	// END: preload image
}

function generateMenuLeft(){
	strContentTable=""
		for(var i = 0; i < arrMenu.length; i+=4){
			var j=parseInt(i/4)
			if(menuIDHome==arrMenu[i+3])
				strContentTable += "<tr><TD><A href='" + arrMenu[i+2] + "'><IMG src='" + arrMenu[i+1] + "' border=0 name='mnu" + j + "' vspace='4' alt='"+ arrMenu[i+3] +"' title='"+ arrMenu[i+3] +"'></A></TD></tr>";
			else 
				strContentTable += "<tr><TD><A href='" + arrMenu[i+2] + "' onmouseover=On('"+j+"') onmouseout=Off('"+j+"')><IMG src='" + arrMenu[i] + "' border=0 name='mnu" + j + "' vspace='4' alt='"+ arrMenu[i+3] +"' title='"+ arrMenu[i+3] +"'></A></TD></tr>";
			}
	strContentTable = "<TABLE cellspacing=0 cellpadding=0 border=0 width= background='images/spacer.gif'>" + strContentTable + "</tr></TABLE>";
	document.write(strContentTable);			
}

function generateMenuTop(){
	strContentTable=""
		for(var i = 0; i < arrMenu.length; i+=4){
			var j=parseInt(i/4)
			if(menuIDHome==arrMenu[i+3])
				strContentTable += "<TD><A href='" + arrMenu[i+2] + "'><IMG src='" + arrMenu[i+1] + "' border=0 name='mnu" + j + "'></A></TD><td><img src='images/spacer.gif' width=37 height=1 border=0></td>";
			else 
				strContentTable += "<TD><A href='" + arrMenu[i+2] + "' onmouseover=On('"+j+"') onmouseout=Off('"+j+"')><IMG src='" + arrMenu[i] + "' border=0 name='mnu" + j + "'></A></TD><td><img src='images/spacer.gif' width=37 height=1 border=0></td>";
	}
	strContentTable = "<TABLE cellspacing=0 cellpadding=0 border=0><tr><td><img src='images/spacer.gif' width=37 height=1 border=0></td>" + strContentTable + "</tr></TABLE>";
	document.write(strContentTable);			
}

//getting the content height:
var contH="100%"
var contW="100%"
function GetContentH(){
	if (ns) {
				contW=parseInt(window.innerWidth-918);
			}
	else
			{				
				contW=parseInt((document.body.clientWidth-918));
			}
}

FixNSWindow();
function FixNSWindow() {
	if (ns6 || ns && (parseInt(navigator.appVersion) == 4)) {
		if (typeof document.NS == 'undefined') document.NS = new Object;
		if (typeof document.NS.NS_scaleFont == 'undefined') {
			document.NS.FixCssInNS = new Object;
			document.NS.FixCssInNS.initWindowWidth = window.innerWidth;
			document.NS.FixCssInNS.initWindowHeight = window.innerHeight;
		}
		window.onresize = FixCssInNS;
	}
}
function FixCssInNS() {
	if (document.NS.FixCssInNS.initWindowWidth != window.innerWidth || document.NS.FixCssInNS.initWindowHeight != window.innerHeight) document.location = document.location;
}
ReloadWindow();
function ReloadWindow(){if (!ns) setTimeout("window.onresize=new Function('window.location.reload()')",200);}
// <<< END: fixing the page content on resize

//-->

function On(mnuNo) {
	if (document.images) {
		var imgName = "mnu" + mnuNo;
		if(ns6) document.images[imgName].src = objMenu1On[mnuNo].src;
		if(ns) eval("document.images['" + imgName + "'].src = objMenu1On[" + mnuNo + "].src");
		else document.images[imgName].src = objMenu1On[mnuNo].src;
	}
}

// function off - call on onmouseout
function Off(mnuNo) {
	if (document.images) {
		var imgName = "mnu" + mnuNo;
		if(ns6) document.images[imgName].src = objMenu1Off[mnuNo].src;
		else if(ns) eval("document.images['" + imgName + "'].src = objMenu1Off[" + mnuNo + "].src");
			else document.images[imgName].src = objMenu1Off[mnuNo].src;
	}
}

var imgNameOff = new Array("images/btn_more_off.jpg","images/btn_submit_off.jpg","images/btn_reset_off.jpg","images/btn_more_white_off.jpg");
var imgNameOn = new Array("images/btn_more_on.jpg","images/btn_submit_on.jpg","images/btn_reset_on.jpg","images/btn_more_white_on.jpg");

var imgObjOff = new Array(imgNameOff.length);
var imgObjOn = new Array(imgNameOn.length);

//Preload2()

//preloading images:
function Preload2(){
	for (i = 0; i<imgNameOff.length; i++)
	{
		imgObjOff[i] = new Image();
		imgObjOff[i].src = imgNameOff[i];
		imgObjOn[i] = new Image();
		imgObjOn[i].src = imgNameOn[i];
	}
}
//mouseover fumction:
function swapIn(nume, i)
{
	var o = eval("document." + nume);
	o.src = imgObjOn[i].src;
}
//mouseout fumction:
function swapOut(nume,i)
{
	var o = eval("document." + nume);
	o.src = imgObjOff[i].src;
}
//-->

function emailAdressIsValid(str){
	var emailAdressFormat = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,3}$/;
	if(str=="")
		{
			return 2
		}
		else if (!(emailAdressFormat.test(str)))
			{
				return 1;
			}
			else
			{				
				return false;
			}
}
function Trim(strToTrim) {
	while(strToTrim.charAt(0)==' '){strToTrim = strToTrim.substring(1,strToTrim.length);}
	while(strToTrim.charAt(strToTrim.length-1)==' '){strToTrim = strToTrim.substring(0,strToTrim.length-1);}
	return strToTrim;
}


var newWinImg;
function OpenImage(imgFile){
	if (new String(newWinImg)!="undefined" && newWinImg!=null) if (!newWinImg.closed) newWinImg.close();
	var newWinImg=window.open("","ReservedItemsPicture","width=100,height=100,top=0,left=0,location=no,directories=no,hotkeys=no,copyhistory=no,resizable=no,menubar=no,status=no,toolbar=no,scrollbars=no,z-lock=yes");
	newWinImg.document.write('<HTML><HEAD><TITLE>Productie Geam Termoizolant</TITLE></HEAD><BODY marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 alink="#0033CC bgcolor="#E5F2FF" onload="window.resizeTo(parseInt(document.images[\'img\'].width)+10,parseInt(document.images[\'img\'].height)+29)"><IMG src="' + imgFile + '" name=img></BODY></HTML>')
	newWinImg.document.close()
	newWinImg.focus();
}