﻿var img = new Image();
var img =  new Array('','');

var count=0;
var inner_string = '';
var index = '0';
var count_right;
var count_img;
var max=7;
var max_dw=7;

//face block
function go(vector){
	count = thumb.length;
    var inner_string = '';
    if (vector == 'left') {
        index++;
    } else {
        index--;
    }
    if (index > count) {
        index = 1;
    }
    if (index < 0) {
        index = count - 1;
    }
    j = index;
    count_img = '0';
    for (i = 0; max > i; i++) {
        if(count_img < count){
            new_name = "conteiner_" + i;
            new_quote_name = "quote_block_" + i;
            //$('#conteiner_'+i).hideElement(200);
            count_img++;
            if ( j > count-1 ){
                j=0;
            }
            if (thumb[j]) {
                inner_string = inner_string+
				"<div class=\"face_img\" onmouseover=\"showElement('quote_block_"+j+"');\" onmouseout=\"hideElement('quote_block_"+j+"');\">" +
					"<div class=\"quote_block\" id=\"quote_block_"+j+"\" style=\"display:none\">" +
						"<div class=\"quote_top\">" +
						"</div>" +
						"<div class=\"quote_middle\">" +
							"<p>"+quote_text[j]+"</p>" +
						"</div>" +
						"<div class=\"quote_bottom\">" +
						"</div>" +
					"</div>" +
					"<div class=\"face_img_bg\">" +
						"<div style=\"overflow:hidden;width:75px\">" +
							"<a href=\""+youth_images[j]+"\" onclick=\"return hs.expand(this)\" target=\"_blank\">"+
							"<img src=\""+thumb[j]+"\" height=\"100\" alt=\""+alt[j]+"\" /></a>" +
						"</div>" +
					"</div>" +
					"<a href=\""+youth_images[j]+"\" onclick=\"return hs.expand(this)\" target=\"_blank\">"+names[j]+"</a>" +
				"</div>";
            } j++;
        }
    }
    inner_tag = document.getElementById('img_block');
    inner_tag.innerHTML = inner_string;
//$('#img_block').show(200);
}

//direction of worc block
function go_dw(vector){
	count = thumb_dw.length;
    var inner_string = '';
    if (vector == 'up') {
        index++;
    } else {
        index--;
    }
    if (index > count) {
        index = 1;
    }
    if (index < 0) {
        index = count - 1;
    }
    j = index;
    count_img = '0';
    for (i = 0; max_dw > i; i++) {
        /*if(count_img < count){
            new_name = "conteiner_" + i;
            new_quote_name = "quote_block_" + i;
            count_img++;*/
            if ( j > count-1 ){
                j=0;
            }
            if (thumb_dw[j]) {
                inner_string = inner_string +
					"<div class=\"dw_item\">" + thumb_dw[j] +
						"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>" +
							"<td valign=\"middle\" height=\"54px\">"+
								"<strong>"+name_dw[j]+"</strong>" +
							"</td>" +
						"</tr></table>" +
					"</div>";
            }  j++;
        //}
    }
    inner_tag = document.getElementById('dw_block');
    inner_tag.innerHTML = inner_string;
}

function showElement(element){
    obj = document.getElementById(element);
    obj.style.display = 'block';
    
}
function hideElement(element){
    objhideElement = document.getElementById(element);
    objhideElement.style.display = 'none';
}
//End scroll menu;

function inner_img() {
    var inner_string = '';
    if(max > 0) {
    	if(thumb.length < max) {
    		max = thumb.length;
    	}
        for (i = 0; i < max; i++) {
            if (thumb[i]) {
                inner_string = inner_string + 
               "<div class=\"face_img\" onmouseover=\"showElement('quote_block_"+i+"');\" onmouseout=\"hideElement('quote_block_"+i+"');\">" +
					"<div class=\"quote_block\" id=\"quote_block_"+i+"\" style=\"display:none\">" +
						"<div class=\"quote_middle\">" +
							"<p>"+quote_text[i]+"</p>" +
						"</div>" +
						"<div class=\"quote_bottom\">" +
						"</div>" +
					"</div>" +
					"<div class=\"face_img_bg\" style=\"overflow:hidden\">" +
						"<div style=\"overflow:hidden;width:75px\">" +
							"<a href=\""+youth_images[i]+"\" onclick=\"return hs.expand(this)\" target=\"_blank\">"+
							"<img src=\""+thumb[i]+"\" height=\"100\" alt=\""+alt[i]+"\" align=\"center\" /></a>" +
						"</div>" +
					"</div>" +
					"<a href=\""+youth_images[i]+"\" rel=\"lightbox\" onclick=\"return hs.expand(this)\" target=\"_blank\">"+names[i]+"</a>" +
				"</div>";
				
            } else {
                break;
            }
        }
    }
    //left and right buttom;
	inner_tag = document.getElementById('img_block');
    inner_tag.innerHTML = inner_string;
}

//inner direction of work
function inner_dw() {
    var inner_string = '';
    if(max_dw > 0 && this['thumb_dw'] && this['name_dw'] && this['text_dw']) {
    	if(thumb_dw.length < max_dw) {
    		max_dw = thumb_dw.length;
    	}
        for (i = 0; i < max_dw; i++) {
            if (thumb[i]) {                
                inner_string = inner_string + 
					"<div class=\"dw_item\">" + thumb_dw[i] +
						"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>" +
							"<td valign=\"middle\" height=\"54px\">"+
								"<strong>"+name_dw[i]+"</strong>" +
							"</td>" +
						"</tr></table>" +
					"</div></div>";				
            } else {
                break;
            }
        }
    }
    //left and right buttom;
	inner_tag = document.getElementById('dw_block');
	if(inner_tag) {
    	inner_tag.innerHTML = inner_string;
	}    	
}

function FTextHide(item) {
	var stat = document.getElementById(item);
	if(stat.value == 'Пароль' || stat.value == 'Логин') {
		stat.value = '';
	}
}
function FTextShow(item) {
	var stat = document.getElementById(item);
	if(stat.value == '') {
		if(item == 'pass') {
			stat.value = 'Пароль';
		} else {
			stat.value = 'Логин';
		}
	}
}


function setCookie(name, value, expiredays, path, domain, secure) {
   if (expiredays) {
      var exdate=new Date();
      exdate.setDate(exdate.getDate()+expiredays);
      var expires = exdate.toGMTString();
   }
   document.cookie = name + "=" + escape(value) +
   ((expiredays) ? "; expires=" + expires : "") +
   ((path) ? "; path=" + path : "") +
   ((domain) ? "; domain=" + domain : "") +
   ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
function delCookie(name) {
	document.cookie = name +'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
