/* toggle an element's display */
function toggle(nr,way){
	var current = false;
	if(way) current = way;
	if(document.getElementById){
		if(!current) current=(document.getElementById(nr).style.display=='none')?'block':'none';
		document.getElementById(nr).style.display=current;
	}else if(document.layers){
		if(!current) current=(document.layers[nr].display=='none')?'block':'none';
		document.layers[nr].display=current;
	}else if(document.all){
		if(!current) current=(document.all[nr].style.display=='none')?'block':'none';
		document.all[nr].style.display=current;
	}
	document.body.focus();
} 
/* get, set, and delete cookies */
function getCookie( c_name ) {
	var c_start = document.cookie.indexOf( c_name + '=' );
	var c_len = c_start + c_name.length + 1;
	if ( ( !c_start ) && ( c_name != document.cookie.substring( 0, c_name.length ) ) ) {
		return null;
	}
	if ( c_start == -1 ) return null;
	var c_end = document.cookie.indexOf( ';', c_len );
	if ( c_end == -1 ) c_end = document.cookie.length;
	return unescape( document.cookie.substring( c_len, c_end ) );
}
function setCookie( c_name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = c_name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
function deleteCookie( c_name, path, domain ) {
	if ( getCookie( c_name ) ) document.cookie = c_name + '=' +
		( ( path ) ? ';path=' + path : '') +
		( ( domain ) ? ';domain=' + domain : '' ) +
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
function fixHomePage(obj){
    var homepage = "http://autoconsulting.com.ua";
    if (obj.style.behavior) obj.setHomePage(homepage);
    else if (netscape
              && netscape.security
              && netscape.security.PrivilegeManager
              && navigator.preference)
    {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
        navigator.preference("browser.startup.homepage", homepage);
    }
}
function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( window.opera && window.print ) {
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else if( document.all ) {  
		window.external.AddFavorite( url, title);  
	}
}
function checkMail(it) {
	var x = it.value;
	var flt  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (flt.test(x)) return true;
	return false;
}
function popu(pic,wi,hi) {
	wij=wi+20;
	hij=hi+30;
	openpopu = window.open("", "", "width="+wij+",height="+hij+",left=100,top=10,resizable=no");
	openpopu.document.write('<body bgcolor=lightgrey><script language=JavaScript>\n<!--\nvar message="ups...";function clickIE() {if (document.all) {(message);return false;}}function clickNS(e) {if (document.layers||(document.getElementById&&!document.all)) {if (e.which==2||e.which==3) {(message);return false;}}}if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}document.oncontextmenu=new Function("return false")\n// -->\n<'+'/script><a href="#" onclick="window.close();" title="click for close"><img src="/photo/view/?'+pic+'.jpg" width='+wi+' height='+hi+' border=0></a></body>');
	openpopu.focus();
}
function openw(url,wi,hi) {
	if(wi==undefined) wi = 670;
	if(hi==undefined) hi = 690;
	window.open(url,'popup','top=100, left=100,fullscreen=no,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width='+wi+',height='+hi+',scrollbars=no').focus();
	return false;
} 
function grabIt(it) {
	if(window.clipboardData) {
		if(window.clipboardData.setData('text',$('#'+it).innerHTML)) alert('Код скопирован в буфер обмена');
		else alert('Unexpected error...');
	}else alert('Ваш браузер не поддерживает данную функцию, пожалуйста используйте Ctrl-C');
} 
function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
$(document).ready(function(){
	$('.gallery').scrollable({  
		vertical: true,
	    size: 3,
		next:'#g-prev',
		prev:'#g-next',
	    speed:400,
		items:'.galleryitems'
	}).mousewheel();
	$('.cloned').removeClass('here');
	//loading pic to gallery inside post	
	$('.gallery li').live("click", function(){
		$('.gallery li').removeClass('here');
		$(this).addClass('here');
		newpic = $(this).children('a').attr('href');
		descr = $(this).children('a').children('img').attr('alt').split('|');
		$('.loadpic').html('<img src="'+newpic+'" width="500" />')
		return false;
	});
	$('.gallery2').scrollable({  
		vertical: true,
	    size: 3,
		next:'#g2-prev',
		prev:'#g2-next',
	    speed:400,
		items:'.gallery2items'
	}).mousewheel();
	//disabling link behaviour
	$('#g-next, #g-prev, #g2-next, #g2-prev').click(function() {return false;});
	$('.postpic').height($('.postpic').children('ul').height());
}); 
