var siteUrl = 'http:/sex-voyage.com';

	var azWin = '     Ё               ё       АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя';
	var azKoi = 'ё                Ё           юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ';
	var AZ=azWin;
	var azURL = '0123456789ABCDEF';
	var b64s  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
	var b64a  = b64s.split('');

	function enBASE64(str) {
		var a=Array(), i
		for( i=0; i<str.length; i++ ){
			var cch=str.charCodeAt(i)
			if( cch>127 ){  cch=AZ.indexOf(str.charAt(i))+163; if(cch<163) continue; }
			a.push(cch)
		};
		var s=Array(), lPos = a.length - a.length % 3
		for(i=0;i<lPos;i+=3){
			var t=(a[i]<<16)+(a[i+1]<<8)+a[i+2]
			s.push( b64a[(t>>18)&0x3f]+b64a[(t>>12)&0x3f]+b64a[(t>>6)&0x3f]+b64a[t&0x3f] )
		}
		switch ( a.length-lPos ) {
			case 1 : var t=a[lPos]<<4; s.push(b64a[(t>>6)&0x3f]+b64a[t&0x3f]+'=='); break
			case 2 : var t=(a[lPos]<<10)+(a[lPos+1]<<2); s.push(b64a[(t>>12)&0x3f]+b64a[(t>>6)&0x3f]+b64a[t&0x3f]+'='); break
		}
		return s.join('')
	}

function translitAlbumPath(){
		var text = document.forms['searchform'].cattitle.value;
		var url = '/system/ajax/translitAlbumPath.php';
		var pars = 'text='+enBASE64(text);
		var myAjax = new Ajax.Updater({success: 'albumResultPath'}, url, 	{method: 'get', parameters: pars});
}


	

function translitPgPath(){
		var text = document.forms['contentAdd'].title.value;
		var url = '/system/ajax/translitPgPath.php';
		var pars = 'text='+enBASE64(text);
		var myAjax = new Ajax.Updater({success: 'pgPathResult'}, url, 	{method: 'get', parameters: pars});
}


var next = 1;


function addImaga(){
	s = document.getElementById('imagamaga');
	n = next;
	input = document.createElement('input');
	input.setAttribute('type', 'file');
	input.setAttribute('size', '50');
	input.setAttribute('name', 'image[]');
	s.appendChild(input);
	
	s.appendChild(document.createTextNode(' '));

	input = document.createElement('select');
	input.setAttribute('name', 'watr[]');

		var gOpt1 = document.createElement('OPTION');
		gOpt1.setAttribute('value', 'yes');

		var gOpt2 = document.createElement('OPTION');
		gOpt2.setAttribute('value', 'no');
		gOpt2.setAttribute('selected', 'selected');

		// Этим двум OPTION задаются надписи “One” и “Two”
		gOpt1.appendChild(document.createTextNode("знак: да"));
		gOpt2.appendChild(document.createTextNode("знак: нет"));

		// Эти две OPTION прикручиваются к созданному SELECT
		input.appendChild(gOpt1);
		input.appendChild(gOpt2);

	s.appendChild(input);

	s.appendChild(document.createElement('br'));
	n.setAttribute('value', parseInt(n.getAttribute('value'))+1);

	next++;
}

function addTour(){
	s = document.getElementById('tourid');
	n = next;
	input = document.createElement('input');
	input.setAttribute('type', 'text');
	input.setAttribute('size', '50');
	input.setAttribute('name', 'bUrl[]');
	s.appendChild(input);
	
	s.appendChild(document.createTextNode(' '));

	input = document.createElement('select');
	input.setAttribute('name', 'tour_color[]');

		var gOpt1 = document.createElement('OPTION');
		gOpt1.setAttribute('value', 'white');

		var gOpt2 = document.createElement('OPTION');
		gOpt2.setAttribute('value', 'white');
		gOpt2.setAttribute('disabled', 'disabled');
		
		var gOpt3 = document.createElement('OPTION');
		gOpt3.setAttribute('value', 'white');
		var gOpt4 = document.createElement('OPTION');
		gOpt4.setAttribute('value', 'white_bold');
		gOpt4.setAttribute('style', 'font-weight: bold;');
		var gOpt5 = document.createElement('OPTION');
		gOpt5.setAttribute('value', 'red');
		gOpt5.setAttribute('style', 'color: red;');
		var gOpt6 = document.createElement('OPTION');
		gOpt6.setAttribute('value', 'red_bold');
		gOpt6.setAttribute('style', 'color: red;font-weight: bold;');

		gOpt1.appendChild(document.createTextNode("выберите цвет:"));
		gOpt2.appendChild(document.createTextNode("- - - - - - -"));
		gOpt3.appendChild(document.createTextNode("Белый"));
		gOpt4.appendChild(document.createTextNode("Белый жирный"));
		gOpt5.appendChild(document.createTextNode("Красный"));
		gOpt6.appendChild(document.createTextNode("Красный жирный"));

		input.appendChild(gOpt1);
		input.appendChild(gOpt2);
		input.appendChild(gOpt3);
		input.appendChild(gOpt4);
		input.appendChild(gOpt5);
		input.appendChild(gOpt6);

	s.appendChild(input);
	
	s.appendChild(document.createTextNode(' '));

	input = document.createElement('select');
	input.setAttribute('name', 'flag[]');

		var gOpt1 = document.createElement('OPTION');
		gOpt1.setAttribute('value', '');

		var gOpt2 = document.createElement('OPTION');
		gOpt2.setAttribute('value', 'fr');
		
		var gOpt3 = document.createElement('OPTION');
		gOpt3.setAttribute('value', 'it');
		var gOpt4 = document.createElement('OPTION');
		gOpt4.setAttribute('value', 'gr');

		gOpt1.appendChild(document.createTextNode("выберите флаг:"));
		gOpt2.appendChild(document.createTextNode("Франция"));
		gOpt3.appendChild(document.createTextNode("Италия"));
		gOpt4.appendChild(document.createTextNode("Греция"));

		input.appendChild(gOpt1);
		input.appendChild(gOpt2);
		input.appendChild(gOpt3);
		input.appendChild(gOpt4);

	s.appendChild(input);	

	s.appendChild(document.createElement('br'));
	n.setAttribute('value', parseInt(n.getAttribute('value'))+1);

	next++;
}

function check(elX){
	k=0;
	i=0;
	l=document.forms[elX].elements.length;
	for (i=0; i<l-1; i++){
		elValue=document.forms[elX].elements[i].value;
		if (elValue==""){
			if (k==0){
				f=i;
			}
			k++;
		}
	}
	if (k>0){
		alert("Вы должны заполнить все поля, помеченые знаком *");
		document.forms[elX].elements[f].focus();
		return false;
	}
	else{
		return true;
	}
}

function toggleDisplay(myElement){	
	boxElement = document.getElementById(myElement);
	if (boxElement.style.display == 'none') {
		boxElement.style.display = 'block';
	} else {
		boxElement.style.display = 'none';
	}
}


function out() {
	// empty function
}

function refreshCaptcha() {
	var rndval = new Date().getTime(); 
	document.getElementById('antibot').innerHTML = '<img src="/system/antibot/img.png?rand=' + rndval + '" alt="Введите код" />';
	
}


var regTime = 3;

function regTimer() {
    regTime--;
    frm = document.confirmation;

    if (frm)
      frm.accept.value = 'Принять ('+regTime+')';

    if (regTime>0)
      window.setTimeout("regTimer()",1000);
    else if (frm){
		frm.accept.value = 'Принять';
		frm.accept.disabled = 0;
    }
}


/*function disableButton(id) {
	butt = document.getElementById(id);
	butt.disabled = 1;
}*/
	


	function submitForm(formname){
		document.forms[formname].submit();
	}


	function checkContacts() {
		fio = document.getElementById('cfio');
		mail = document.getElementById('cmail');
		subj = document.getElementById('csubj');


		if (fio.value != "" && mail.value != "" && subj.value != "" && fio.value != "Your Name" && mail.value != "Ypur City" && subj.value != "Your Email Address")
		{ 
			document.contactsForm.submit();			
		}
		else {
			alert('Please fill all fields!');
		}

	}

