$(document).ready(function ()
{
	$(".hover_src").hover_src();
});

// Host
	var _host='';
	function host()
	{
		return _host;
	}
	var _host_folder='';
	function host_folder()
	{
		return _host_folder;
	}
// Host End

// Popup
	function popup(http, w, h)
	{
		if ((w==undefined)||(w=='')) { w=850; }
		if ((h==undefined)||(h=='')) { h=600; }
		win=window.open(http, '', "height="+h+",width="+w+",scrollbars=1,resizable=1");
		win.focus();
	}
// Popup End

// Temp Img
	var img_temp_arr=new Array();
	var img_temp_num=0;
	function temp_img(src)
	{
		img_temp_num++;
		img_temp_arr[img_temp_num]=new Image();
		img_temp_arr[img_temp_num].src=src;
	}
// Temp Img End

// Vis Hid
	jQuery.fn.hid_vis=function ()
	{
		if (($(this).is(".hid"))||($(this).is(":hidden")))
		{
			$(this).removeClass("hid").show();
		}
		else
		{
			$(this).hide();
		}
	
		return this;
	};
// Vis Hid End

// Hid
	jQuery.fn.hid=function ()
	{
		return (($(this).is(":hidden"))||($(this).is(".hid")));
	};
// Hid End

// Hover Class
	jQuery.fn.hoverClass=function (_class)
	{
		$(this).hover(function ()
		{
			$(this).addClass(_class);
		},
		function ()
		{
			$(this).removeClass(_class);
		});
		
		return this;
	};
// Hover Class End

// Hover Src
	jQuery.fn.hover_src=function (_src_params)
	{
		$(this).each(function ()
		{
			var _src;
			var _attr_src=$(this).attr("_hover_src");
			
			if (und(_attr_src))
			{
				_src=_attr_src;
			}
			else
			{
				_src=_src_params;
			}
			
			temp_img(_src);
			
			$(this).hover(function ()
			{
				if ($(this).attr("_src_out")==undefined)
				{
					$(this).attr("_src_out", $(this).attr("src"));
				}
				
				$(this).attr("src", _src);
			},
			function ()
			{
				$(this).attr("src", $(this).attr("_src_out"));
			});
		});
		
		return this;
	};
// Hover Src End

// Vis
	jQuery.fn.vis=function ()
	{
		$(this).removeClass("hid").show();
		
		return this;
	};
// Vis End

// Z Index
	var _z_index=1;
	function z_index()
	{
		_z_index++;
		return _z_index;
	}
// Z Index End

// Und
	function und(val)
	{
		if (val!=undefined)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
// Und End

// Is_object
	function is_object (mixed_var){
	 
		if (mixed_var instanceof Array) {
			return false;
		} else {
			return (mixed_var !== null) && (typeof( mixed_var ) == 'object');
		}
	}
// Is_object End

// Is Array
 function is_array(input){
    return typeof(input)=='object'&&(input instanceof Array);
  }
// Is Array End

// Urlencode
	function urlencode (str) {
		str = (str+'').toString();
		return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
																		replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
	}
// Urlencode End

// Is_numeric
	function is_numeric(input){
		return typeof(input)=='number';
	  }
	function input_is_numeric(input){
		return !isNaN(input);
	  }
// Is_numeric End

// Ctrl
	var ctrl=false;
	var shift=false;
	$(document).ready(function ()
	{
		$("body").keydown(function (e)
		{
			if (e.keyCode==17)
			{
				ctrl=true;
			}
			if (e.keyCode==16)
			{
				shift=true;
			}
		}).keyup(function (e)
		{
			if (e.keyCode==17)
			{
				ctrl=false;
			}
			if (e.keyCode==16)
			{
				shift=false;
			}
		});
	});
// Ctrl End

// Cubator
	var _cubator=false;

	function cubator()
	{
		return _cubator;
	}
// Cubator End

// externalInterface
	function externalInterface(movieName)
	{
		 if (navigator.appName.indexOf("Microsoft") != -1)
		 {
             return document[movieName];
         }
		 else
		 {
             return document[movieName];
         }
	}
// externalInterface End

// SwfObject
	jQuery.fn.swfobject=function (params)
	{
		params=$.extend({
			version:"9.0.0",
			expressinstall:"expressInstall.swf"
		}, params);
		
		$(this).each(function ()
		{
			var _do_id=$(this).attr("id");
			
			var _temp_id="swf_object_temp_"+swf_object_id();
			$(this).attr("id", _temp_id);
			swfobject_2.embedSWF(params.swf, _temp_id, params.width, params.height, params.version,params.expressinstall, params.flashvars, params.params, params.attributes);
			/*if (_do_id!=undefined)
			{
				$(this).attr("id", _do_id);
			}
			else
			{
				$(this).removeAttr("id");
			}*/
		});
		
		return this;
	};
	
	var swf_object_id_n=0;
	function swf_object_id()
	{
		swf_object_id_n++;
		return swf_object_id_n;
	}
// SwfObject End

// HTML Img
	jQuery.fn.html_img=function ()
	{
		var _arr=this;
		
		if (!$(_arr).is(".html_img"))
		{
			_arr=$(this).find(".html_img");
		}
		
		$(_arr).each(function ()
		{
			$(this).html('').unbind();
			/*if ($(this).attr("_html_img_builded")==1)
			{
				return;
			}*/
			$(this).attr("_html_img_builded", 1);
			var _lit=$(this).attr("_lit");
			var _big=$(this).attr("_big");
			var _file=$(this).attr("_file");
			var _src_lit=$(this).attr("_src_lit");
			var _src_big=$(this).attr("_src_big");
			var _width=$(this).attr("_width");
			var _height=$(this).attr("_height");
			var _size=$(this).attr("_size");
			var _tip=$(this).attr("_tip");
			var _bits=$(this).attr("_bits");
			var _a=$(this).attr("_a");
			
			if (_a==1)
			{
				// Img
					var _img;
					
					if (_lit)
					{
						_img=$("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"html_img_div\"><img src=\""+_src_lit+"\" border=\"0\" class=\"html_imgage\" align=\"absmiddle\" /></td></tr></table>");
					}
				// Img End
				
				// File
					else
					{
						_img=$("<span class=\"a\">"+_file+"</span>");
					}
				// File End
				
				// A
					if (_big==1)
					{
						$(_img).find(".html_img_div").addClass("pointer").hoverClass("html_img_div_over");
						$(_img).click(function ()
						{
							okno_w=Math.max(Number(_width)+20, 340);
							
							okno({
								title:"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
										"  <tr>"+
										"	<td class=\"pop_title_table_td\"><input type=\"text\" value=\""+host_folder()+"box/img/"+_file+"\" class=\"pop_title_input_adress\" /></td>"+
										"	<td class=\"pop_title_table_td\">"+_size+"</td>"+
										//"	<td class=\"pop_title_table_td\">"+_bits+"</td>"+
										"	<td class=\"pop_title_table_td\">"+_tip+"</td>"+
										"  </tr>"+
										"</table>", 
								text: "<div align=\"center\"><img src=\""+_src_big+"\" border=\"0\" class=\"html_imgage html_imgage_big\" /></div>",
								width:okno_w,
								height:Number(_height)+20
							});
						});
					}
				// A End
				
				$(this).append(_img);
			}
			else
			{
				$(this).html(_file);
			}
		});
		
		return this;
	};
// HTML Img End

// HTML File
	jQuery.fn.html_file=function ()
	{
		var _arr=this;
		
		if (!$(_arr).is(".html_file"))
		{
			_arr=$(this).find(".html_file");
		}
		
		$(_arr).each(function ()
		{
			if ($(this).html()=='')
			{
				var _file=$(this).attr("_file");
				if ($(this).attr("_a")==1)
				{
					$(this).html("<a href=\"box/files/"+_file+"\" target=\"blank\">"+_file+"</a>");
				}
				else
				{
					$(this).html(_file);
				}
			}
		});
		
		return this;
	};
// HTML File End

// Tini Dop Pos
	function tini_dop_pos(e)
	{
		var ret= {
			x : ( $(e).offset().left - $(window).scrollLeft() ),
			y : ( $(e).offset().top - $(window).scrollTop() )
		};
		return ret;	
	}
// Tini Dop Pos End

// Search This
	jQuery.fn.search_this=function (_sel)
	{
		var _this=this;
		
		if (!$(_this).is(_sel))
		{
			_this=$(this).find(_sel);
			
			if ($(_this).length==0)
			{
				_this=$(this).closest(_sel);
			}
		}
		
		return _this;
	};
// Search This End

// Http Test
	function http_test(_http)
	{
		alert(_http);
		$.get(_http, function (ob)
		{
			alert(ob);
		});
	}
// Http Test End

// Load
	jQuery.fn.load=function ()
	{
		$(this).html('').flash({
			swf:"box/load.swf",
			width:20,
			height:20,
			wmode:'transparent'
		});
		
		return this;
	};
// Load End

// Alert ob
	function alert_ob(_ob)
	{
		var _str='';
		for(n in _ob)
		{
			if (_str!='') { _str+='\n'; }
			_str+=n+': '+_ob[n];
		}
		alert(_str);
	}
// Alert ob End

// Пароль
var m_strUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZЙЦУКЕНГШЩХЪЭЖДЛОРПАВЫФЯЧСМИТЬБЮ";
var m_strLowerCase = "abcdefghijklmnopqrstuvwxyzйцукенгшщзхъэждлорпавыфячсмитьбю";
var m_strNumber = "0123456789";
var m_strCharacters = "!@#$%^&*?_~"
function checkPassword(strPassword)
{
	// Reset combination count
	var nScore = 0;
	
	// Password length
	// -- Less than 4 characters
	if (strPassword.length < 5)
	{
		nScore += 5;
	}
	// -- 5 to 7 characters
	else if (strPassword.length > 4 && strPassword.length < 8)
	{
		nScore += 10;
	}
	// -- 8 or more
	else if (strPassword.length > 7)
	{
		nScore += 25;
	}

	// Letters
	var nUpperCount = countContain(strPassword, m_strUpperCase);
	var nLowerCount = countContain(strPassword, m_strLowerCase);
	var nLowerUpperCount = nUpperCount + nLowerCount;
	// -- Letters are all lower case
	if (nUpperCount == 0 && nLowerCount != 0) 
	{ 
		nScore += 10; 
	}
	// -- Letters are upper case and lower case
	else if (nUpperCount != 0 && nLowerCount != 0) 
	{ 
		nScore += 20; 
	}
	
	// Numbers
	var nNumberCount = countContain(strPassword, m_strNumber);
	// -- 1 number
	if (nNumberCount == 1)
	{
		nScore += 10;
	}
	// -- 3 or more numbers
	if (nNumberCount >= 2)
	{
		nScore += 20;
	}
	
	// Characters
	var nCharacterCount = countContain(strPassword, m_strCharacters);
	// -- 1 character
	if (nCharacterCount == 1)
	{
		nScore += 10;
	}	
	// -- More than 1 character
	if (nCharacterCount > 1)
	{
		nScore += 25;
	}
	
	// Bonus
	// -- Letters and numbers
	if (nNumberCount != 0 && nLowerUpperCount != 0)
	{
		nScore += 2;
	}
	// -- Letters, numbers, and characters
	if (nNumberCount != 0 && nLowerUpperCount != 0 && nCharacterCount != 0)
	{
		nScore += 3;
	}
	// -- Mixed case letters, numbers, and characters
	if (nNumberCount != 0 && nUpperCount != 0 && nLowerCount != 0 && nCharacterCount != 0)
	{
		nScore += 5;
	}
	
	
	return nScore;
}
function countContain(strPassword, strCheck)
{ 
	// Declare variables
	var nCount = 0;
	
	for (i = 0; i < strPassword.length; i++) 
	{
		if (strCheck.indexOf(strPassword.charAt(i)) > -1) 
		{ 
	        	nCount++;
		} 
	} 
 
	return nCount; 
} 
// Пароль End

// Id (для связи flash и html)
	var file_id_n=0;
	
	function file_id()
	{
		file_id_n++;
		return file_id_n;
	}
// Id End

// Ob To Text
	function ob_to_text(_ob, otstup)
	{
		if (otstup==undefined) { otstup=''; }
		var _str='';
		for(n in _ob)
		{
			if (_str!='') { _str+='<BR>'; }
			var _val=_ob[n];
			if ((is_object(_val))||(is_array(_val)))
			{
				_str+=otstup+' '+n+': <BR>'+ob_to_text(_val, otstup+'>')+'';
			}
			else
			{
				_str+=otstup+' '+n+': '+_ob[n];
			}
		}
		return (_str);
	}
// Ob To Text End


















