function PreparaDati(frm){
  stringa = ""; 
  var form = document.getElementById(frm);
  var numeroElementi = form.elements.length;  
  for(var i = 0; i < numeroElementi; i++){
    if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    }  
  }
return stringa;
}

function Nascondi(dachiudere){
if (document.getElementById(dachiudere).style.display=="none"){
if ((cico!='')){
document.getElementById(cico).style.display="none";
}
document.getElementById(dachiudere).style.display="";
cico=dachiudere;
}else{
if ((cico!=dachiudere) && (cico!='')){
document.getElementById(dachiudere).style.display="none";
}
}
}
function createObject() {
	var request_type = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         request_type = new XMLHttpRequest();
         if (request_type.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            request_type.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            request_type = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               request_type = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!request_type) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
return request_type;
}


//var http =new XMLHttpRequest();
var nocache = 0;
function PostAjax(dachiudere,pagina,params){
var http = createObject();
//var params=PreparaDati(frm);
//if (document.getElementById(dachiudere).style.display=="none"){
document.getElementById(dachiudere).style.display='';
document.getElementById(dachiudere).innerHTML =Attendere();
nocache = Math.random();
var url = pagina;
http.open("POST", url, true);

http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		document.getElementById(dachiudere).innerHTML =http.responseText;
	}else{
		document.getElementById(dachiudere).innerHTML =Attendere();
	}
}
http.send(params);

//document.getElementById(dachiudere).style.display="";
//cico=dachiudere;
//}else{

//document.getElementById(dachiudere).style.display="none";

//}
}
function Nasc(ns) {
document.getElementById(ns).style.display="none"
}
function Attendere() {
return '<div id="Wait"><img src="img/wait30trans.gif" width="30" height="30" /></div>';
}

if ( document.all )
{
	function blink_show()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'visible';
		}
		
		window.setTimeout( 'blink_hide()', 700 );
	}
	
	function blink_hide()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'hidden';
		}
		
		window.setTimeout( 'blink_show()', 250 );
	}
	

}


//  End -->
function ChangeImg(fl,im){
	document.getElementById(im).src='fl'	
}
function Sicuro(id,pagina){
	if (confirm('Sei sicuro di voler eliminare ?')){
		document.location.href=pagina + '&del=' + id;
	}
}
function popup(a,x,y,z)
{
	var str = "height=" + y + ",innerHeight=" + y;
    str += ",width=" + x + ",innerWidth=" + x;
    if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
	    var xc = (aw - x) / 2;
	    var yc = (ah - y) / 2;
	    str += ",left=" + xc + ",screenX=" + xc;
	    str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open(a, '', str +",scrollbars="+ z);
}
function _add_more() {
		var txt = "<br><input type=\"file\" name=\"item_file[]\" style=\"width:340px\">";
		document.getElementById("dvFile").innerHTML += txt;
	}
function validate(f){
	var chkFlg = false;
	for(var i=0; i < f.length; i++) {
		if(f.elements[i].type=="file" && f.elements[i].value != "") {
			chkFlg = true;
		}
	}
	if(!chkFlg) {
		alert('Please browse/choose at least one file');
		return false;
	}
	f.pgaction.value='upload';
	return true;
}
function Video(vid){
document.getElementById("VIDEO").URL = vid;
document.getElementById("VIDEO").setAttribute('src',vid);
}	
function ChiudiPres(dachiudere){
	document.getElementById(dachiudere).style.display="none";	
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];

    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
		
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
	}else if (o.type=='textarea'){ 
	
		if(v.length<a[i+1]){err=true}
      
    } else
	
    if (!o.type&&o.length>0&&o[0].type=='radio'||o[0].type=='checkbox'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo&&a[i+3]!=''){s+='* '+a[i+3]+'\n'}
      }
	
   // } else if (o[0].type=='checkbox'){
		//alert (o[0].checked);
  //    if((t==1&&o[0].checked==false)||(t==2&&o[0].checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }
    if ((err&&a[i+3]!='')){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}
function Sub(frm){
frm.submit();	
}
function SubCheck(frm){
YY_checkform('newmail','to','#q','0','Field \'to\' is not valid.','titolo','#q','0','Field \'Subject\' is not valid.','testo','2','1','Field \'Message\' is not valid.');
if (document.MM_returnValue==true){
	frm.submit();	
}
}
function fotoCheck(frm){
if (document.getElementById('C1').checked==true){
frm.submit();	
}else{
alert('You must certify that you have the rights');	
}
}
function CheckCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'vis') && (e.type=='checkbox')) {
     e.checked=true
    }
  }
  var txt = '<a href="javascript:UnCheckAll(document.delmail)">DESELECT ALL</a>';
	document.getElementById("Sel").innerHTML = txt;
}
function UnCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'vis') && (e.type=='checkbox')) {
     e.checked=false
    }
  }
   var txt = '<a href="javascript:CheckCheckAll(document.delmail)">SELECT ALL</a>';
	document.getElementById("Sel").innerHTML = txt;
}
function stripHtml(s) {
	return s.replace(/\\&/g, '&amp;').replace(/\\</g, '&lt;').replace(/\\>/g, '&gt;').replace(/\\t/g, '&nbsp;&nbsp;&nbsp;').replace(/\\n/g, '<br />').replace('@','' );
	
	}
function DelMyFoto(id){
	if (confirm('Do you really want to delete this photo?')){
		document.location.href='fotogallery.php?del=' + id;
	}
}
function DelMyVideo(id){
	if (confirm('Do you really want to delete this video?')){
		document.location.href='videogallery.php?del=' + id;
	}
}
function DelMyAd(id){
	if (confirm('Do you really want to delete this contact?')){
		document.location.href='adbook.php?del=' + id;
	}
}
function AjSel(id,cng,larg){
	PostAjax(''+ cng +'','aj_select.php?pd=' + id +'&larg=' +larg,'')
}
function AjSelMod(id,cng,larg){
	PostAjax(''+ cng +'','aj_selectmod.php?pd=' + id +'&larg=' +larg,'')
}
function Rate(num,id){
	for (i=1;i<=num;i++){
	document.getElementById(id+'_'+i).src="img/rat.png";	
	}
	for (i=i;i<=5;i++){
	document.getElementById(id+'_'+i).src="img/rat_off.png";	
	}
	document.getElementById(id).value=num;
}
function RateMe(usr){
var http = createObject();
tta=document.getElementById('tt1').value;
ttb=document.getElementById('tt2').value;
ttc=document.getElementById('tt3').value;
mt=stripHtml(document.getElementById('mot').value);
if ((mt!="") && (tta>0) && (ttb>0) && (ttc>0)){
nocache = Math.random();
http.open("POST", 'aj_rateme.php?tt1=' + tta + '&tt2=' + ttb +'&tt3=' + ttc + '&usr=' + usr , true);
params='&mot=' + mt;
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//http.setRequestHeader("Charset", "iso-8859-1");
//http.setRequestHeader("Content-length", params.length);
//http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		document.getElementById('Rate').innerHTML =http.responseText;
		document.location.reload();
	}else{
		document.getElementById('Rate').innerHTML =Attendere();
	}
}
http.send(params);

}else{
alert('you have to fill all fields');
}
}
function DelRate(){
	if (confirm('Are you sure you want to delete all your ratings')){
		document.location.href='rating.php?del=1';
	}
}
function Stars(a){
	for(i=1;i<=a;i++){
	document.getElementById('S'+i).src='img/st_on.png';
	}
	for(i=i;i<=10;i++){
	document.getElementById('S'+i).src='img/st.png';
	}
}
function expl(){
	if (document.getElementById('acc').value==1){
	document.getElementById('TxOnly').innerHTML='<b>Description</b>:<br> For everything concerning Omnia Models Communication, Advertising, Marketing, Events. And also to have info about Banner Ads in our Website.<br>We will give you an answer as soon as we can, but only if that is not present in our <a href=\"pagine.php?idx=19\" style=\"text-decoration:underline\">FAQ Area</a>. So please check that first. <br>Thank you very much.<br> OM Team ';
	}
	if (document.getElementById('acc').value==2){
	document.getElementById('TxOnly').innerHTML='<b>Description</b>:<br> For every info you need about your OM Card and your Payments.<br>We will give you an answer as soon as we can, but only if that doesn’t depend on the PayPal Service and only if that is not present in our <a href=\"pagine.php?idx=19\" style=\"text-decoration:underline\">FAQ Area</a>. So please check that first.<br> Thank you very much.<br> OM Team ';
	}
	if (document.getElementById('acc').value==3){
	document.getElementById('TxOnly').innerHTML='<b>Description</b>:<br> For every info you need about our Website and our Services.<br>We will give you an answer as soon as we can, but only if that is not present in our <a href=\"pagine.php?idx=19\" style=\"text-decoration:underline\">FAQ Area</a>. So please check that first.<br> Thank you very much.<br> OM Team ';
	}
}
function UNO(a){
if (document.getElementById('C' + a).checked==true){
	document.getElementById(a).submit();
}else{
	alert('you must accept the terms and conditions to join OM');
}
}
function AdMsg(user,ida){
if (document.getElementById('to').value.indexOf(user)==-1){	
if(document.getElementById('to').value.length>=3){
document.getElementById('to').value=document.getElementById('to').value+'; '+user;
document.getElementById(ida).style.color='#FFFFFF';		
}else{
document.getElementById('to').value=user;
document.getElementById(ida).style.color='#FFFFFF';		
}
}
}
function RemoveMe(){
	if (confirm('Do you really want to deactivate your Omnia Models Account?')){
		if (confirm('Are you sure? After this click you will not be able to login!!')){
		document.location.href='remove.php';
		}
	}
}
var message="OmniaModels - right click disabled";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

