function swap(block){
 	document.getElementById(block).style.display= (document.getElementById(block).style.display=='none')?"block":"none";}

function vis(block){
	if(document.getElementById(block).className=='vis_f'){document.getElementById(block).className='vis_t';}
	else{document.getElementById(block).className='vis_f';}
}

function checkmailer(){
  num= document.mailer.length;
  for(i=0;i<document.mailer.length;i++){
	if(document.mailer.elements[i].id!='') {
		if(document.mailer.elements[i].value!='') {
			num--;
		}
	} else {
		num--;
	}
  }
  if(num==0){
	  document.mailer.submit();
  }
  else{
	alert('Заполните все поля');
  }
}



function reg_cntrl(frm){
  num= frm.length;
  for(i=0;i<frm.length;i++){
	  (frm.elements[i].id=='')?num--:(frm.elements[i].value!='')?num--:"";
  }
	if(num==0){
		if(frm.pass1.value==frm.pass2.value){
                    if (frm.agree.checked) {
                        return true;
                    } else {
                        alert ('To register you must agree to contract');
                        return false;
                    }
		}
		else{alert('We introduce different passwords');}
	}
	else{alert('Fill in the required fields');}
	return false;
}



function edit_cntrl(frm){
  num= frm.length;
  for(i=0;i<frm.length;i++){
	(frm.elements[i].id=='')?num--:(frm.elements[i].value!='')?num--:"";
  }
  num?alert("Fill in the required fields"):"";
  return num?false:true;
}



function faq_f(id){
 if(document.getElementById('faq'+id).className=='vis_f'){
    location.href='#'+id;
 	document.getElementById('faq'+id).className= 'vis_t';
 }
 else{
  document.getElementById('faq'+id).className='vis_f';
 }
}


function ctrl_country(op){
    if(op==0){
		document.getElementById('other_countr').className='vis_t';
	}
	else{
		document.getElementById('other_countr').className='vis_f';
	}
	for(i=1;i<5;i++){
		 document.getElementById("c"+i).className= "vis_f";
	}
	document.getElementById("c"+op).className="vis_t";
}	



function control_frm(min,frm,summa){
	n= frm.length;
	for(i=0;i<frm.length;i++){
		n= (frm.elements[i].id!='')?(frm.elements[i].value!='')?n-1:n:n-1;
    }
	(n)?alert('Fill in the fields'):'';
	if(document.getElementById(summa).value*1>=min*1){return true;}
	else{ alert("The minimum transfer amount $"+min);}
	return false;
}

function control_co(min,max,frm,summa){
	n= frm.length;

	for(i=0;i<frm.length;i++){
            if(frm.elements[i].id!='') {
                var value = '';
                if(frm.elements[i].type == 'select-one') {
                    value = frm.elements[i].options[frm.elements[i].selectedIndex].value;

                    if(value == '' || value == null) {
                        value = frm.elements[i].options[frm.elements[i].selectedIndex].text;
                    }

                    if(value == '-' || value == 'Select') {
                        value = '';
                    }
                } else {
                    value = frm.elements[i].value;
                }

                n = (value!='') ? n-1 : n;
            } else {
                n--;
            }
        }

	if(n){alert('Fill in the fields'); return false;}
	
	if(document.getElementById(summa).value*1<min*1) {
		alert("The minimum transfer amount $"+min);
		return false;
	}
	
	if(document.getElementById(summa).value*1>max*1) {
		alert('The amount available for withdrawal: $'+max);
		return false;
	}
	
	return true;
}

function frm(frm){

	n= frm.length;

	for(i=0;i<frm.length;i++){

		n= (frm.elements[i].id!='')?(frm.elements[i].value!='')?n-1:n:n-1;

    }

	(n)?alert('Fill in the fields'):"";

	return n?false:true;

}

// Отправка письма
function pochta(addr) {
	location.href='mailto:' + addr + '@mmcis-investments.com';
}



function obmen_kurs(id_pole,pole,kurs){

	document.getElementById(id_pole).value=Math.round(pole.value*kurs*100)/100;

}

function popUpWindow(URLStr,v_width,v_height) {		
	if(typeof(screen.height)=="undefined"){
		v_left=0;
		v_top=0;
	}else{
		v_top=(screen.height-v_height)/2-150;		
		v_left=(screen.width-v_width)/2;
	}
	
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+v_width+',height='+v_height+',left='+v_left+', top='+v_top+',screenX='+v_left+',screenY='+v_top+'');
}

function addInvite(){
    var tableS = document.createElement('table');
    tableS.setAttribute('width', '80%');tableS.setAttribute('border', '0'); tableS.setAttribute('cellpadding', '0'); tableS.setAttribute('cellspacing', '0');
    var row1 = document.createElement('tr');
    var td1 = document.createElement('td');td1.setAttribute('class','text');td1.innerHTML = "Your friend's name:";
    var td2 = document.createElement('td'); var nInput = document.createElement('input'); nInput.setAttribute('type', 'text');nInput.setAttribute('name', 'name[]');
    nInput.setAttribute('class', 'input_invite');  td2.appendChild(nInput);row1.appendChild(td1);row1.appendChild(td2);
    var row2 = document.createElement('tr'); var tdr = document.createElement('td');
    tdr.setAttribute('height', '10px'); row2.appendChild(tdr);
    var row4 = document.createElement('tr'); var tdr2 = document.createElement('td');
    tdr2.setAttribute('height', '30px'); row4.appendChild(tdr2);
    var row3 = document.createElement('tr'); var td3 = document.createElement('td');
    td3.setAttribute('class','text');  td3.innerHTML = "Your friend's e-mail:";
    var td4 = document.createElement('td'); var eInput = document.createElement('input');
    eInput.setAttribute('type', 'text'); eInput.setAttribute('name', 'mail[]');
    eInput.setAttribute('class', 'input_invite'); td4.appendChild(eInput);
    row3.appendChild(td3);row3.appendChild(td4);  tableS.appendChild(row1);
    tableS.appendChild(row2);tableS.appendChild(row3);tableS.appendChild(row4);
    document.getElementById('bodyInvite').appendChild(tableS);
    return false;
}
function popUpWindowFriend(URLStr,friend,v_width,v_height) {
	if(typeof(screen.height)=="undefined"){
		v_left=0;
		v_top=0;
	}else{
		v_top=(screen.height-v_height)/2-150;
		v_left=(screen.width-v_width)/2;
	}

	popUpWin = open(URLStr, friend, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+v_width+',height='+v_height+',left='+v_left+', top='+v_top+',screenX='+v_left+',screenY='+v_top+'');
}
