// One object tracks the current modal dialog opened from this window.
// Generate a modal dialog.
//var win=null

//replaceAll function
String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

function openDialog(url, name, w, h) {

          if (checkFocus()==1) {return 1}
          w=w+(0.05*w)
          h=h+(0.05*h)
          var left = (screen.availWidth - w) / 2
          var top = (screen.availHeight - h) / 2
          //var attr = "left=" + left + ",top=" + top + ",resizable=no,scroll=no,status=no,titlebar=0,width=" + w + ",height=" + h
          var attr = "resizable=no,scroll=no,status=no,titlebar=0,width=" + w + ",height=" + h
          // Generate the dialog and make sure it has focus.
          //alert(name)
          active=0
          name = window.open(url,name,attr)
          //name.focus()
}

// Grab all Navigator events that might get through to form elements while
// dialog is open. For Internet Explorer, disable form elements.

function checkFocus() {

  if (window.win)
          { if (window.win.closed) {self.status="ii inchisa";return 0}
               else {self.status=" nu ii inchisa";return 1}
          }
  else { self.status="nu exista"; return 0}
    }

function setFocus() {

  if (window.win)
          { if (window.win.closed) {self.status="ii inchisa";self.focus()}
               else {self.status="nu ii inchisa"; win.focus()}
          }
          else { self.status="nu exista";self.focus()}
    }

function openWindow(action,frameName,widthValue,heightValue){
  openDialog(action, frameName, widthValue, heightValue)
}

function openNewWindow()
{
	var img=document.images['thumb1'];
      var newImg = new Image();
      source = img.src;
     	newImg.src = source;
	imgH = newImg.height;
	imgW = newImg.width;
      var name = source.substr(source.lastIndexOf("/")+1, source.length);
      name = name.replaceAll(".","");
      name = name.replaceAll("%","");
      name = name.replaceAll("+","");
      name = name.replaceAll("-","");
	openDialog(source, name, imgW, imgH);
}

function openNewWindow2()
{
	var img=document.images['highslide-gallery'];
      var newImg = new Image();
      source = img.src;
      newSource = source.replace(/Medii/, "Mari");
     	newImg.src = newSource;
      //alert(newSource);
      while(newImg.height==0){
      }
	imgH = newImg.height;
	imgW = newImg.width;
      alert('Image:'+imgW+','+imgH);
      var name = source.substr(source.lastIndexOf("/")+1, source.length);
	openDialog(newSource, name, imgW, imgH);
}

function changeImage(imagePath){
     // alert("changeImage")
      var img= document.images['thumb1'];
      img.src = imagePath;
}

function changeSty(){
      //alert('change style')
      var url = location.href;
	param = url.substr(url.lastIndexOf('/')+1, url.length) ;
      param = param.replace('_en.php','');
	param = param.replace('.php', '');
      if ((param=="contact") || (param=="proiectare")) 
      	{}
      else {
            if ((param=="despre") || (param=="index"))
			id="mymenu1"
      	else if ((param=="mobilier") || (param=="peretiDespartitori") || (param=="scauneBirou"))
			id="mymenu2"
      		else if ((param=="dormitoare") || (param=="dressinguri") || (param=="bucatarii") || (param=="corpuriIluminat") || (param=="calorifereDecorative") || (param=="baiAccesorii") || (param=="scauneCanapele") || (param=="cameradezi") )
			id="mymenu3"
      	else if((param=="gresieFaianta") || (param=="ardezie"))
           		id="mymenu4";
		document.getElementById(id).className="show";
      	menu_status[id] = 'show';
     } 
}


// the following function is used to change the language, for internalization
function languageChange(toLang){
	var URL = document.URL;
      var newUrl;
	if(toLang == "enToRo"){
		newURL = URL.substring(0,URL.lastIndexOf(".")-3)+".php";
	}
	if(toLang == "roToEn"){
               if (URL == "http://www.archicraft.ro/") {
                   newURL = "http://www.archicraft.ro/index_en.php";
               }else{ 
		    	 newURL = URL.substring(0,URL.lastIndexOf("."))+"_en.php";
                   //newURL = URL+"?$lang=en";   
                }
	}
	document.getElementById('steag').href=newURL;
}

