function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}


// POPIMAGE START
PositionX = 100;
PositionY = 100;

defaultWidth  = 20;
defaultHeight = 20;

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4) {
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle) {
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('if (isIE){');
		writeln('window.resizeTo(300,300);');
		writeln('width=300-(document.body.clientWidth-document.images[0].width);');
		writeln('height=300-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["myimg"].width;');
		writeln('window.innerHeight=document.images["myimg"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('</sc'+'ript>');
		if (!AutoClose) {
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
		} else {
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		}
		writeln('<img name="myimg" src='+imageURL+' style="display:block" onClick="self.close();"></body></html>');
		close();		
	}
}
function popVideo(videoURL,imageTitle,my_width,my_height) {
	if (isNN){videoWin=window.open('about:blank','',optNN);}
	if (isIE){videoWin=window.open('about:blank','',optIE);}
	with (videoWin.document) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		//writeln('<sc'+'ript language="javascript" src="/js/AC_ActiveX.js" type="text/javascript"></sc'+'ript>');
		//writeln('<sc'+'ript language="javascript" src="/js/AC_RunActiveContent.js" type="text/javascript"></sc'+'ript>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('if (isIE){');
		writeln('  window.resizeTo(300,250);');
		writeln('  width=300-(document.body.clientWidth-'+my_width+');');
		writeln('  height=250-(document.body.clientHeight-'+my_height+');');
		writeln('  window.resizeTo(width,height);}');
		writeln('if (isNN){');       
		writeln('  window.innerWidth='+my_width+';');
		writeln('  window.innerHeight='+my_height+';}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
	    //writeln('ns["onMetaData"] = function (obj) {       trace("Video Data------------------------");       for (var i in obj) {          trace(i+":\t"+obj[i]);       }       trace("------------------------");       duration = obj.duration;       videotitle = obj.xtradata;       vWidth = obj.width;       vHeight = obj.height;    };');
		writeln('</sc'+'ript>');
		writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
		writeln('  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="224" id="FLVPlayer">');
		writeln('	  <param name="movie" value="/images/FLVPlayer_Progressive.swf" />');
		writeln('	  <param name="wmode" value="transparent" />');
		writeln('	  <param name="salign" value="lt" />');
		writeln('	  <param name="quality" value="high" />');
		writeln('	  <param name="scale" value="noscale" />');
		writeln('	  <param name="bgcolor" value="#FAD200" />');
		writeln('	  <param name="menu" value="false" />');
		writeln('	  <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=/images/Corona_Skin_3&streamName='+videoURL+'&autoPlay=true&autoRewind=true" />');
		writeln('	<embed src="/images/FLVPlayer_Progressive.swf" menu="false" wmode="transparent" bgcolor="#FAD200" flashvars="&MM_ComponentVersion=1&skinName=/images/Corona_Skin_3&streamName='+videoURL+'&autoPlay=true&autoRewind=true" quality="high" scale="noscale" width="'+my_width+'" height="'+my_height+'" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />');
		writeln('  </object>');
		writeln('</body></html>');
		close();		
	}
}
// POPIMAGE STOP

function loginSubmit() {
	document.forma_login.login_password.value=hex_md5(document.forma_login.login_pass.value);
	document.forma_login.login_pass.value='';
}

function clearSplash() {
	document.getElementById("splashImage").innerHTML="";
	document.getElementById("splashImage").style.visibility="hidden";
}

function checkText(e, msg, act) {
	if (e.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '')=='') {
		alert(msg);
		return false;
	} else {
		eval(act+'();');
		return true;
	}
}

function do_nothing(){
}

window.onerror="do_nothing()";

// detalii
function ratePromo() {
	document.forma_rate.submit();
}

// register
function submitPageRegister() {
	if (document.forma_register.pass1.value.length<5) {
		document.forma_register.password_error.value='1';
	}
	document.forma_register.password1.value=hex_md5(document.forma_register.pass1.value);
	document.forma_register.pass1.value='';
	document.forma_register.password2.value=hex_md5(document.forma_register.pass2.value);
	document.forma_register.pass2.value='';
	document.forma_register.submit();
}
function checkTownRegister() {
	if (document.forma_register.judet.options[document.forma_register.judet.selectedIndex].text.indexOf('Sector')==-1) {
		document.forma_register.localitate.readOnly=false;
	} else {
		document.forma_register.localitate.value='BUCURESTI';
		document.forma_register.localitate.readOnly=true;
	}
}

// profil
function submitPageProfile() {
	if (document.forma_profil2.pass1.value.length<5) {
		document.forma_profil2.password_error.value='1';
	}
	document.forma_profil2.password1.value=hex_md5(document.forma_profil2.pass1.value);
	document.forma_profil2.pass1.value='';
	document.forma_profil2.password2.value=hex_md5(document.forma_profil2.pass2.value);
	document.forma_profil2.pass2.value='';
	document.forma_profil2.old_password.value=hex_md5(document.forma_profil2.old_pass.value);
	document.forma_profil2.old_pass.value='';
	document.forma_profil2.submit();
}
function submitLinkAccount() {
	document.forma_profil3.link_password.value=hex_md5(document.forma_profil3.link_pass.value);
	document.forma_profil3.link_pass.value='';
	document.forma_profil3.submit();
}
function checkTownProfile() {
	if (document.forma_profil.judet.options[document.forma_profil.judet.selectedIndex].text.indexOf('Sector')==-1) {
		document.forma_profil.localitate.readOnly=false;
	} else {
		document.forma_profil.localitate.value='BUCURESTI';
		document.forma_profil.localitate.readOnly=true;
	}
}
function permEmailCallback(perm) {
	if (perm) {
		//window.location.reload();
		window.location='/fb_saveemail.php';
	} else {
		alert('Pentru a putea primi alerte prin email trebuie sa accepti conexiunea cu Facebook!');
	}
}


// Tools
function installSearchEngine() {
	if (window.external && ("AddSearchProvider" in window.external)) {
		// Firefox 2 and IE 7, OpenSearch
		window.external.AddSearchProvider("http://www.cautpromotii.ro/tools/se.xml");
	} else if (window.sidebar && ("addSearchEngine" in window.sidebar)) {
		// Firefox <= 1.5, Sherlock
		window.sidebar.addSearchEngine("http://www.cautpromotii.ro/tools/cautpromotii-plugin.src",
		"http://www.cautpromotii.ro/favicon.ico",
		"Search Plugin", "");
	} else {
		// No search engine support (IE 6, Opera, etc).
		alert("Nu exista suport de search provider pentru browser-ul dumneavoastra !");
	}
}

function checkSearch() {
	if (document.forma_cauta.cauta_id.value.length<3) {
		alert('Introduceti minim 3 caractere pentru a efectua o cautare !');
		return false;
	} else {
		return true;
	}
}
