var drop = 0;
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
window.onload = function() {
    Resize();
}
window.onresize = function() {
    Resize();
}

function TrimString (sInString){
	sInString = sInString.replace(/ /g,' ');
	return sInString.replace(/(^\s+)|(\s+$)/g, '');
}

function GetWidth() {
	if (self.innerWidth) {
		return self.innerWidth;
	} else
	if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientWidth;
	} else
	if (document.body) {
		return document.body.clientWidth;
	}
}

function GetHeight() {
	if (self.innerHeight) {
		return self.innerHeight;
	} else
	if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else
	if (document.body) {
		return document.body.clientHeight;
	}
}

function ShowHide(id){
if (id != '') {
	var itm = null;
	var pitm= null;
	if (document.getElementById) { 
  		itm = document.getElementById(id); 
	} else if (document.all) { 
		itm = document.all[id]; 
	} else if (document.layers) { 
		itm = document.layers[id]; 
	}
   	if (!itm) { /* do nothing */ 
	} else if (itm.style) {
   		if (itm.style.display == "none") { 
			itm.style.display = "block"; 
		} else { 
			itm.style.display = "none";
		}
    } else { itm.visibility = "show"; }
 }
}
function blockdiv (this_) {
	document.getElementById(this_).style.display = 'block';
}
function nonediv (this_) {
	document.getElementById(this_).style.display = 'none';
}

function setnulltext(this_, mess, typ) {
	if (typ == 0) {
		if (this_.value == mess) {this_.value = ""};
	} else {
		if (this_.value == "") {this_.value = mess};
	}
}
function transparent(im) {
   if (!im.transparented && (/\.png/.test(im.src))) {
      im.transparented = 1;
      var picture = im.src; var w = im.width; var h = im.height;
      im.src = "./images/no.gif";
      im.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='scale', src='"+picture+"');";
    //  im.width = w; im.height = h;
   }
   return "transparent";
}

function bi (el) {
	return document.getElementById(el);
}

function Resize() {
    bi('ajaxcontent').style.left = Math.round((GetWidth()-500)/2);
}

function FeedBack() {
	var name = bi('name').value;
	var message = bi('message').value;
	var email = bi('email').value;
	message = message.replace(/\n/, "<br>");
	var _error_ = 0;

	if (name == '') 		{bi('name').style.backgroundColor = '#FFAAAA'; 			_error_ = 1;} else {bi('name').style.backgroundColor = '#FFFFFF';}
	if (message == '') 		{bi('message').style.backgroundColor = '#FFAAAA'; 		_error_ = 1;} else {bi('message').style.backgroundColor = '#FFFFFF';}
	if (email == '')	 	{bi('email').style.backgroundColor = '#FFAAAA';			_error_ = 1;} else {bi('email').style.backgroundColor = '#FFFFFF';}
	if (_error_ == 0) {
        return true;
	} else {
		alert('Заполните поля указаные поля');
        return false;
	}
}

function FeedBackAjax() {
	var name = bi('name').value;
	var message = bi('message').value;
	var email = bi('email').value;
	var lang = bi('lang').value;
	message = message.replace(/\n/, "<br>");
	var _error_ = 0;

	if (name == '') 		{bi('name').style.backgroundColor = '#FFAAAA'; 			_error_ = 1;} else {bi('name').style.backgroundColor = '#FFFFFF';}
	if (message == '') 		{bi('message').style.backgroundColor = '#FFAAAA'; 		_error_ = 1;} else {bi('message').style.backgroundColor = '#FFFFFF';}
	if (email == '')	 	{bi('email').style.backgroundColor = '#FFAAAA';			_error_ = 1;} else {bi('email').style.backgroundColor = '#FFFFFF';}
	if (_error_ == 0) {
		myAjax('feedback.php?name='+name+'&message='+message+'&email='+email+'&ok=1&lang='+lang+'&act=send_email', 'ajaxcontent');
	} else {
		alert('Заполните поля указаные поля');
	}
}

function ShowDropH (target_) {
	if (bi(target_).style.display == 'none') {
		blockdiv(target_);	
		drop = 1;
	} else {
		nonediv(target_);	
		drop = 0;
	}
}

function ShowDrop (target_) {
		blockdiv(target_);	
		drop = 1;
}

function HideDrop (target_) {
	if (!drop) {
		id = setTimeout("nonediv('"+target_+"')",1000);	
	} else {
		id = setTimeout("HideDrop('"+target_+"')",1000);	
	}
	drop = 0;
}
