function generateFlash(movie, width, height, id, align)
{
  document.write('<object type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'" id="'+id+'" align="'+align+'">');
  document.write('<param name="movie" value="'+movie+'" />');
  document.write('<param name="wmode" value="transparent" />');
  document.write('<param name="autoStart" value="-1" />');
  document.write('</object>');
}

function openurl(obj){
	var url = obj.value;
    if ( url && url != '#' ) {
        eval("document.location='"+url+"'");
    }
}

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = winW;
	var winHeight = winH;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'auto'
	/*if (nn4 || ie4 || dom) {
		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes' }
		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes' }
		posX = Math.round((screen.width - winWidth) / 2);
		posY = Math.round((screen.height - winHeight) / 2);
		posCode = (nn4 || dom)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
	} else {*/
		posCode = "";
	//}
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}

/**
* Обработка поля ввода
*/

function inputController()
{

}

inputController.object = null;
inputController.button = null;
inputController.classActive = '';
inputController.classInactive = '';
inputController.defaultValue = '';
inputController.isSubmitable = ''; 

inputController.prototype.init = function(inputId, buttonId)
{
    // настройки
    this.classInactive = 'inputFieldInactive';
    this.classActive = 'inputFieldActive';
	if (inputId == 'search-input') {
        this.defaultValue = 'введите слово для поиска';   
	} else {
	    if (inputId == 'subscribe-input') {
			this.defaultValue = 'Введите ваш E-mail';   
		}
	}
    this.isSubmitable = false;

    this.object = document.getElementById(inputId);
    this.button = document.getElementById(buttonId);
    
    this.object.className = this.classInactive;
    this.object.value = this.defaultValue;
    
    
    
}

inputController.prototype.clear = function()
{
    if ( this.object.value == this.defaultValue) {
        this.object.value = '';
    }
    this.object.className = this.classActive;
}

inputController.prototype.lostFocus = function()
{
    if (this.object.value == '' ||  this.object.value == this.defaultValue) {
        this.object.value = this.defaultValue;
        this.object.className = this.classInactive;
    }
}

inputController.prototype.keyPressed = function()
{
    if (this.object.value != '') {
        this.isSubmitable = true;
    } else {
        this.isSubmitable = false;
    }
}

inputController.prototype.submit = function()
{
    if (this.isSubmitable) {
        return true;
    } 
    else return false;
}

function set_values()
{
	//f = document.forms['feedback'];
//	msg = document.getElementById('con_msg');
	if (document.forms['feedback'].name.value == ""){
		document.forms['feedback'].name.value = "Ваше имя";
		document.forms['feedback'].name.className = 'com_in_inactive';
	}
	if (document.forms['feedback'].email.value == ""){
		document.forms['feedback'].email.value = "Ваш Email";
		document.forms['feedback'].email.className = 'com_in_inactive';
	}
	if(document.forms['feedback'].phone.value == "")
		document.forms['feedback'].phone.value = "Ваш телефон";
		document.forms['feedback'].phone.className = 'com_in_inactive';
	if (msg.value == ""){
		msg.value = "Текст сообщения";	
		msg.className = 'com_in_inactive';
	}
	return;
}

function showImage(image, w, h, title)
{
	//var im = new Image();
	//im.src = image;

	var w = Math.min(Math.ceil(screen.availWidth * 2 / 3), w);
	var h = Math.min(Math.ceil(screen.availHeight * 2 / 3), h);
    
	var x = Math.ceil((screen.availWidth - w) / 2);
	var y = Math.ceil((screen.availHeight - h) / 2);
    	
	var newwindow = window.open('', 'mywin', 'resizable=1, menubar=0, status=0, width='+w+', height='+h+', top='+y+', left='+x);
	newwindow.document.write('<html><head><title>'+title+'</title></head>');
	newwindow.document.write('<body style="margin:0;padding:0" onclick="window.close();"><a href="javascript:void(0);"><img src="'+image+'" border="0" title="Закрыть окно"></a></body></html>');
	newwindow.document.close();
}

// DOM Navigation functions
// James Gregory 2006 (j.gregory@metalmadness.co.uk)
	
function getNextElement(start, identity, children)
{
	var next, first = arguments[3];
	
	next = (typeof start == 'string') ? document.getElementById(start) : start;
	if (!first) first = next;
	if (!children) children = true;

	do {
		if (!next) {
			return null;
		} else if (next != first && (!identity || isType(next, identity))) {
			return next;
		} else {
			if (children && next.hasChildNodes()) {
				var inner = getFirstChild(next, identity);
				
				if (inner) return inner;
			}
			
			if (next.nextSibling) {
				next = next.nextSibling;
			} else {
				next = getNextElement(getNextParent(next), identity, children, start);
			}
		}
	} while (next)
}

function getPreviousElement(start, identity, children)
{
	var next, first = arguments[3];
	
	next = (typeof start == 'string') ? next = document.getElementById(start) : start;
	if (!first) first = next;
	if (!children) children = true;
	
	do {
		if (!next) {
			return null;
		} else if (next != first && (!identity || isType(next, identity))) {
			return next;
		} else {
			var inner;
			
			if (children && next.hasChildNodes()) {
				inner = getLastChild(next, identity);
				
				if (inner) return inner;
			}

			if (next != first && children && next.hasChildNodes() && inner) {
				return inner;
			} else if (next.previousSibling) {
				next = next.previousSibling;
			} else if (next.parentNode != first && (!identity || isType(next.parentNode, identity))) {
				return next.parentNode;
			} else {
				var parent = next.parentNode;
				
				do {
					if (parent != first && (!identity || isType(parent, identity))) {
						return parent;
					}
					
					parent = parent.parentNode;
				} while (parent)
				next = getPreviousParent(next);
			}
		}
	} while (next)
}

function getFirstChild(el, identity) { return getChild(el, identity, 'forward'); }
function getLastChild(el, identity) { return getChild(el, identity, 'backward'); }

function getChild(el, identity, direction)
{
	if (typeof el == 'string') el = document.getElementById(el);
	
	if (!direction || direction == 'forward') {
		for (var i = 0; i < el.childNodes.length; i++) {
			if (!identity || isType(el.childNodes[i], identity)) {
				return el.childNodes[i];
			} else if (el.childNodes[i].hasChildNodes()) {
				return getChild(el.childNodes[i], identity, direction);
			}
		}
	} else if (direction == 'backward') {
		for (var i = (el.childNodes.length - 1); i > 0; i--) {
			if (!identity || isType(el.childNodes[i], identity)) {
				return el.childNodes[i];
			} else if (el.childNodes[i].hasChildNodes()) {
				return getChild(el.childNodes[i], identity, direction);
			}
		}
	}
	
	return null;
}

function isType(el, identity)
{
	if (typeof el == 'string') el = document.getElementById(el);

	if (!isNaN(identity)) {
		return (el.nodeType == identity);
	} else {
		return (el.tagName == identity.toUpperCase());
	}
}

function getNextParent(el) { return getParentAdjacent(el, 'forward'); }
function getPreviousParent(el) { return getParentAdjacent(el, 'backward'); }

function getParentAdjacent(el, direction)
{
	var next;
	
	if (!direction) direction = 'forward';
	next = (typeof el == 'string') ? document.getElementById(el).parentNode : el.parentNode;
	
	do {
		if (!next) {
			return null;
		} else if (direction == 'forward' && next.nextSibling) {
			return next.nextSibling;
		} else if (direction == 'backward' && next.previousSibling) {
			return next.previousSibling;
		} else {
			return getParentAdjacent(next, direction); 
		}
	}
	while (next)
}

function makeNiceOls() {

	var ols = document.getElementsByTagName('OL');

	for(i=0; i<ols.length; i++) {

		for(j=0, k=1; j<ols[i].childNodes.length; j++) {

			if (ols[i].childNodes[j].tagName == 'LI') {

				ols[i].childNodes[j].innerHTML = '<b>' + k++ + '.</b> ' + ols[i].childNodes[j].innerHTML;

			}

		}

	}

}

window.onload = makeNiceOls;