<!--
// предподгрузка сменяющихся картинок
var ims=new Array();
ims[1]="http://yo-foto.ru/i/p1.jpg";
ims[2]="http://yo-foto.ru/i/p2.jpg";
ims[3]="http://yo-foto.ru/i/p3.jpg";
ims[4]="http://yo-foto.ru/i/p4.jpg";



function ImPreload()
{
  for(i=1; i<=4; i++)
  {
   ims_p[i]=new Image; ims_p[i].src=ims[i];
  }
}
// конец загрузки
var lines = new Array("1", "2", "3", "4");

function MkIndexPhoto() {
lines.sort(RandomSort);  // Случайное перемешивание
var IndexPhoto = '<A href="javascript:;" onClick="change_photo();"><IMG SRC="http://yo-foto.ru/i/p'+lines[1]+'.jpg" BORDER="0" ALT="твоя фотосессия - твои яркие воспоминания" align=right hspace=0 id=index_photo></A>';
p_now = lines[1];
document.write(IndexPhoto);
}

function change_photo() {
lines.sort(RandomSort);  // Случайное перемешивание
if(lines[1] == p_now) { p_now = lines[2];}
else {p_now = lines[1];}
document.getElementById("index_photo").src = "http://yo-foto.ru/i/p"+lines[1]+".jpg";
}

function getDaysLeft(oDeadLineDate, oToday){
  return oDeadLineDate > oToday ? Math.ceil((oDeadLineDate - oToday) / (1000 * 60 * 60 * 24)) : null;
}

function MkDaysLeft(sDeadLineDate, sDeadLineText){
  var oToday = new Date();
  var sTime = sDeadLineDate + " " + oToday.getHours() + ":" + oToday.getMinutes() + ":" + oToday.getSeconds();
  var oDeadLineDate = new Date(sTime);
  var nDaysLeft = getDaysLeft(oDeadLineDate, oToday);
  if (nDaysLeft){
    var sDaysLeft = String(nDaysLeft);
    var sDaysText = "дней";
    var nDaysLeftLength = sDaysLeft.length;
    if (sDaysLeft.charAt(nDaysLeftLength - 2) != "1"){
      if (sDaysLeft.charAt(nDaysLeftLength - 1) == "2" || sDaysLeft.charAt(nDaysLeftLength - 1) == "3" || sDaysLeft.charAt(nDaysLeftLength - 1) == "4"){
        sDaysText = "дня";
      }else if (sDaysLeft.charAt(nDaysLeftLength - 1) == "1"){
        sDaysText = "день";
      }
    }
    var sLeftText = sDaysText == "день" ? "остался" : "осталось";
    document.write(sLeftText + " " + nDaysLeft + " " + sDaysText + "!");
  }else{
    document.write(sDeadLineText);
  }
}
// Вспомогательная функция "сортировки"
function RandomSort(a,b)
{
 if (Math.random() > 0.49) return -1;
 if (Math.random() < 0.49) return  1;
 return 0
}

// функция изменения фотокнопок и подложек

function change_bm(id, img, inner){
	if(inner != 1) {	document.getElementById("bm"+id).src = "i/iphoto_"+id+"_"+img+".gif";}
	document.getElementById("pl"+id).src = "i/pl_"+img+".gif";
}

// функция изменения кновок в item_list 
function change_item(id, img){
	document.getElementById("item_arr_"+id).src = "i/item_arr_1_"+img+".gif";
	document.getElementById("item_bm_"+id).src = "i/item_list_bm_"+img+".gif";
}

// управление флешем
function flashGo(frame){
	document.scen.GotoFrame(frame);
}
// функция преобразования числа по разрядам
function toString(num)
{
	num = num.toFixed(0);
	var parts = num.split('.');
	parts[0] = parts[0].substr(0, parts[0].length%3)+parts[0].substr(parts[0].length%3).replace(/(\d{3})/g,' \$1');
	return parts.join(',');
}

// функция перерасчета стоимости заказа
function re_price(){
	mask_price = document.getElementById("price").value;
	lense_price= document.getElementById("lense_type").value;
	lense_color= document.getElementById("lense_color").value;
	if(lense_color != "без окраски" ) {work = 600;} else {work = 500;};

	temp = lense_price.split('#');
	itog_sum = mask_price*1 + temp[1]*1 + work;
	itog_sum_str = toString(itog_sum)+" руб.";
	document.getElementById("sum_itog").value = itog_sum_str;
	lense_type = lense_price.split(' ');
if(lense_type[0] == "Organic") {
	document.getElementById('lense_color_block').style.display = 'none';
	document.getElementById('lense_color').value="без окраски";
	//alert("Линзы Organic Supersin 1,5 не подлежат окраске!");
	} else {document.getElementById('lense_color_block').style.display = 'block';}
}

// функция проверки заполнения полей форм и отправка
function sendform(){
	if(document.getElementById('fio').value == "0"){
		alert('Укажите Ваше Имя');
		document.getElementById('fio').focus();
		return false;
	}
	if(document.getElementById('email').value == "0"){
		alert('Укажите контактный e-mail');
		document.getElementById('email').focus();
		return false;
	}
	if(document.getElementById('phone').value == "0"){
		alert('Укажите контактный телефон');
		document.getElementById('phone').focus();
		return false;
	}
	
	if(document.getElementById('fotosessiya_type').value == ""){
		alert('Укажите тип фотосессии');
		document.getElementById('fotosessiya_type').focus();
		return false;
	}

document.forms.order_form.submit();
}


function sendform_get_gallery(){
	if(document.getElementById('ID').value == "" || document.getElementById('ID').value == "ID заказа"){
		alert('Укажите ID вашей фотосессии');
		document.getElementById('ID').focus();
		return false;
	}
	if(document.getElementById('FNAME').value == "" || document.getElementById('FNAME').value == "Фамилия"){
		alert('Укажите фамилию на кого оформлена фотосессия');
		document.getElementById('FNAME').focus();
		return false;
	}
document.forms.get_gallery_form.submit();
}


function sendform_for_frens(){
	if(document.getElementById('INAME').value == ""){
		alert('Укажите ваше имя');
		document.getElementById('INAME').focus();
		return false;
	}
	if(document.getElementById('FRIENDS_MAIL').value == ""){
		alert('Укажите e-mail, кому отправить намек');
		document.getElementById('FRIENDS_MAIL').focus();
		return false;
	}
document.forms.send_for_frens_form.submit();
}



function clear_form(id){
	if(id == "ID"){
		if(document.getElementById("ID").value == "") {document.getElementById("ID").value = "ID заказа";}
		else {
			if(document.getElementById("ID").value == "ID заказа") {document.getElementById("ID").value = "";}
		}
	}
	if(id == "FNAME"){
		if(document.getElementById("FNAME").value == "") {document.getElementById("FNAME").value = "Фамилия";}
		else {
			if(document.getElementById("FNAME").value == "Фамилия") {document.getElementById("FNAME").value = "";}
		}
	}
	
}


function sendform_response(){
	if(document.getElementById('fio').value == ""){
		alert('Укажите Ваше Имя и Фамилию');
		document.getElementById('fio').focus();
		return false;
	}
	if(document.getElementById('comment').value == ""){
		alert('Напишите Ваш отзыв');
		document.getElementById('comment').focus();
		return false;
	}
document.forms.response_form.submit();
}

function change_color(razdel, item){
	mask_color = document.getElementById("mask_color").value;
	if(mask_color!="0"){
		temp = mask_color.split('#');
		if(temp[1] != "") { document.getElementById("model_photo").src = "photo/"+razdel+"/"+item+"_"+temp[1]+".jpg";}
	} else {document.getElementById("model_photo").src = "photo/"+razdel+"/"+item+".jpg";}
}

function addbookmark(){
var bookmarkurl="http://yo-foto.ru/index.php";
var bookmarktitle="yo-foto.ru - моя фотосессия";
if (document.all) {window.external.AddFavorite(bookmarkurl,bookmarktitle);}
}
//-->