var arrMenus=new Array('services-subMenu', 'about-us-subMenu', 'portfolio-subMenu', 'contact-subMenu'); 

var maxzIndex=100;





var el=$('main-content');

if (el.addEventListener){

  el.addEventListener('mouseover', closeAll, false); 

} else if (el.attachEvent){

  el.attachEvent('onmouseover', closeAll);

}









function showMenu(menuId){

	//close all menus

	for(var i=0;i<arrMenus.length;i++)

		if (Element.visible($(arrMenus[i])) && arrMenus[i]!=menuId)

			Element.hide($(arrMenus[i]));

			//new Effect.Fade($(arrMenus[i]),{duration:0.2});

	

	//open the current menu

	if (!Element.visible(menuId)){

		Element.show(menuId);

		//new Effect.Appear(menuId,{duration:0.3});

	}

	//asez meniul peste orice alt content (inclusiv peste alt meniu)

	maxzIndex++;

	$(menuId).setStyle({zIndex:maxzIndex});

	//alert($(menuId).style.zIndex);

}





function closeAll(){

	for(var i=0;i<arrMenus.length;i++)

		Element.hide($(arrMenus[i]));

		//new Effect.Fade($(arrMenus[i]),{duration:0.2});

	maxzIndex=100;	

}





function initHistory(){

	

	window.dhtmlHistory.create({

			toJSON: function(o) {return Object.toJSON(o);}, fromJSON: function(s) {return s.evalJSON();}});

	

	var hListener = function(newLocation, historyData) {

	

		var currentW = dhtmlHistory.getCurrentHash();

		if (!currentW)

			currentW='Home';

		arrCurrentW= currentW.split(':');	

		if (arrCurrentW.length>1)

			eval ('show'+arrCurrentW[0]+'("'+arrCurrentW[1]+'");');

		else

			eval ('show'+arrCurrentW[0]+'();');

	}

	

	window.onload = function() {

			dhtmlHistory.initialize();

			dhtmlHistory.addListener(hListener);

			

	};

	

	

	

	







}





//handler pentru highlight row in meniuri

function initMenu(){



	for(var i=0;i<arrMenus.length;i++){

		Element.hide(arrMenus[i]);

		$(arrMenus[i]).setStyle({visibility:'visible'});

	}

		

	var arrObj=$$('#menu .submenu ul');

	for (i=0;i<arrObj.length;i++){

		new HighlightAlternate.list(arrObj[i]);

	}

	

}



	

function closeWindows(){

	Windows.closeAll();

}





function showModal(){

	Dialog.confirm("Va place noua prezentare a site-ului ? ", 

               {

			   width:300,

			   okLabel: "Da", 

			   cancelLabel: "Nu", 

               buttonClass: "alphacube_buttons",

               className: "alphacube",

			   id: "myDialogId",

               cancel:function(win) {alert("apasat Nu")},

               ok:function(win) {alert("apasat Da"); return true;}

              });



}





function sendAjaxForm(formId){

	new Ajax.Request('content/processContact.php', {

					 parameters: $(formId).serialize(true),

					 method: 'POST',

					 onLoading: function(){

						 if ($('formResponseBig'))

						 	new Effect.Appear($('formResponseBig'),{duration:0.7});

						else

							new Effect.Appear($('formResponse'),{duration:0.7});

					 },

					 onComplete: function(){

						 if ($('formResponseBig'))

							 $('formResponseBig').innerHTML='Mesajul a fost trimis. In cel mai scurt timp veti fi contactat.';						

						 else

						 	 $('formResponse').innerHTML='Mesajul a fost trimis. In cel mai scurt timp veti fi contactat.';						

					 }

  });

	}







function initWindows(){

	

	if (typeof(win1)!='undefined')

		win1.destroy();

	

	win1 = new Window({className: "alphacube", title: "Oferte speciale", width:260, height:90, wiredDrag: true, parent: "main-content",destroyOnClose: false,icon: "img/splash_ico.gif", recenterAuto:false}); 

	win1.setConstraint(true);	

	win1.showCenter(false, 0, 0);

	

	if (typeof(win2)!='undefined')

		win2.destroy();

	win2 = new Window({className: "alphacube", title: "Despre Aplicatiile Web", width:260, height:85, wiredDrag: true, parent: "main-content", destroyOnClose: false,icon: "img/question_ico.gif", recenterAuto:false, constraint: {left:10, right:20}}); 

	win2.setConstraint(true);

	win2.showCenter(false,150,0);

	

	if (typeof(win3)!='undefined')

		win3.destroy();

	win3 = new Window({className: "alphacube", scrollable: true, title: "Acasa", width:590, height:550, wiredDrag: true, parent: "main-content",destroyOnClose: false,icon: "img/question_ico.gif", recenterAuto:false}); 

	win3.setConstraint(true);

	//win3.adaugaScroll();

	win3.showCenter(false, 0, 295);	

	

	if (typeof(win4)!='undefined')

		win4.destroy();

	win4 = new Window({className: "alphacube", title: "Contacteaza-ne!", width:260, height:255, wiredDrag: true, parent: "main-content",destroyOnClose: false,icon: "img/phone_ico.gif", recenterAuto:false}); 

	win4.setConstraint(true);

	win4.showCenter(false, 295,0);	



	initWindowsHome();

}









function initWindowsHome(setPosition){



if (setPosition){

	win1.setLocation(0,0);

	win1.setSize(260,90);

	

	win2.setLocation(150,0);

	win2.setSize(260,85);

	

	win3.setLocation(0,295);

	win3.setSize(590,550);

	

	win4.setLocation(295,0);

	win4.setSize(260,255);

}





	showOferteSmall();

	showBlogSmall();

	showContactSmall();

	

	var currentW = dhtmlHistory.getCurrentHash();

	if (!currentW){
		//currentW='Home';
		currentW='Osiris_ecommerce_solution';
	}
	arrCurrentW= currentW.split(':');	

	if (arrCurrentW.length>1)

		eval ('show'+arrCurrentW[0]+'("'+arrCurrentW[1]+'");');

	else

		eval ('show'+arrCurrentW[0]+'();');

}





function showHome(){ //web design



	

	win3.setAjaxContent("content/home.html",{asynchronous:true, method: "GET"});



	

	dhtmlHistory.add("Home", true);

	win3.setTitle('Acasa');

	return false;

}







function showOsiris_ecommerce_solution(){ //Osiris e-commerce solution

	win3.setAjaxContent("content/e-commerce/e-commerce.html",{asynchronous:true, method: "GET"});

	dhtmlHistory.add("Osiris_ecommerce_solution", true);

	win3.setTitle('Osiris e-commerce solution');

	return false;

}





function showWebDesign(){ //web design



	if (typeof(win3)!='undefined')

		win3.destroy();

	win3 = new Window({className: "alphacube", title: "Aplicatii Web", width:590, height:550, wiredDrag: true, parent: "main-content",destroyOnClose: true,icon: "img/question_ico.gif", recenterAuto:false}); 

	win3.setConstraint(true);



	win3.setAjaxContent("content/servicii/web-design/web-design.html",{asynchronous:true, method: "GET"});

	win3.showCenter(false, 0, 295);	

	win3.setTitle('Web Design');

	dhtmlHistory.add("WebDesign", true);

	

	return false;

}





function showAplicatiiWeb(){

	

	win3.setAjaxContent("content/servicii/aplicatii-web/aplicatii-web.html",{asynchronous:true, method: "GET"});

	win3.setTitle('Aplicatii Web');	

	dhtmlHistory.add("AplicatiiWeb", true);

	

	}

	

function showSEO(){

	

	win3.setAjaxContent("content/servicii/SEO/seo.html",{asynchronous:true, method: "GET"});

	win3.setTitle('SEO - Search Engine Optimization');	

	dhtmlHistory.add("SEO", true);

	

	}





function showCariere(){ //web design



	

	win3.setAjaxContent("content/cariere.html",{asynchronous:true, method: "GET"});



	win3.setTitle('Cariere');

	dhtmlHistory.add("Cariere", true);

	

}





function showDespre(){ //web design



	

	win3.setAjaxContent("content/despre.html",{asynchronous:true, method: "GET"});

	win3.setTitle('Despre IT Experience');

	



	dhtmlHistory.add("Despre", true);

}





function showPortofoliu(pag){

	

	if (!pag)

		pag='web-design';

	

	win3.setAjaxContent("content/portofoliu/"+pag+".html",{asynchronous:true, method: "GET"});

	

	win3.setTitle('Portofoliu');

	dhtmlHistory.add("Portofoliu:"+pag, true);

	

}





function showArticol(pag){

	

	if (!pag)

		pag='tehnologia-aplicatiilor-web';

	

	win3.setAjaxContent("content/articole/"+pag+".html",{asynchronous:true, method: "GET"});

	

	win3.setTitle('Articole');

	dhtmlHistory.add("Articol:"+pag, true);

	

}



function showCorporateId(){

	

	win3.setAjaxContent("content/servicii/corporateId/corporateId.html",{asynchronous:true, method: "GET"});

	

	win3.setTitle('Corporate Id');

	dhtmlHistory.add("CorporateId", true);

	}

	

function showPartners(){

	

	win3.setAjaxContent("content/parteneri.html",{asynchronous:true, method: "GET"});

	win3.setTitle('Parteneri');	

	

	dhtmlHistory.add("Partners", true);

}





function showContact(pag){

	

	win3.setAjaxContent("content/contactBig.html",{asynchronous:true, method: "GET"});

	win3.setTitle('Contact');	

	dhtmlHistory.add("Contact:"+pag, true);

	}

	



function showOfertaSite(pag){ 



	

	if (!pag)

		pag='listaPachete';

	



	win3.setAjaxContent("content/servicii/web-design/ofertaSite-"+pag+".html",{asynchronous:true, method: "GET"});

	win3.setTitle('Pachete Web Design');

	



	dhtmlHistory.add("OfertaSite:"+pag, true);



	

}

	



function showContactSmall(){



	

	win4.setAjaxContent("content/contact.html",{asynchronous:true, method: "GET"});

	



	return false;

}





function showBlogSmall(){

	

	win2.setAjaxContent("content/blogList.html",{asynchronous:true, method: "GET"});

	

	

	return false;

}





function showOferteSmall(){

		

	win1.setAjaxContent("content/oferteSpeciale.html",{asynchronous:true, method: "GET"});

	

	return false;

}





function go(win,module,page){  //pentru navigare

		if (page)

			eval('show'+module+'("'+page+'")');

		else

			eval('show'+module+'()');

}





function highlightContact(){

	Effect.Pulsate(win4.getId(),{duration:1, pulses:1});

	win4.toFront();

}



function gotoURL(loc,arg){

	window.open(loc,arg);

}



function showModal(res,type){

	switch (type){ 

		case 'img':

			Dialog.alert({url: "content/showImage.php?res="+res, options: {method: 'get'}}, {className: "alphacube", width:540, okLabel: "Inchide"});

			break;

		case 'swf':

			Dialog.alert({url: "media/"+res, options: {method: 'get'}}, {className: "alphacube", width:540, okLabel: "Inchide"});

			break;

	 }

}

