function getscrollingsocument(what) {
	res=false;
	if (what==1)
		res=window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
	if (what==0)
		res=window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
	return res;
}
function commentform( id )
{
	var a = new Date();
	if ( $('#'+id).attr('open')=='true' )
	{
		$('#'+id).attr('open',false)
		$('#'+id).hide();
	}
	else
	{
		$('#'+id).attr('open',true)
		$('#'+id).show();
	}
}
function sendComment( obj )
{
	return true;
}

$(document).ready( function() {
	$('a[rel*=facebox]').facebox();
							});

function doDeleteComment( f )
{
	if ( document.getElementById('c_image') && f.c_image.value.length == 0 )
		{ 	f.c_image.style.border='1px solid #F00';
			setTimeout(function() {f.c_image.style.border='inset #555 1px';} , 1000 );
			f.c_image.focus();
			return false; }
	if ( f.key.value.length < 3 )
		{ 	f.key.style.border='1px solid #F00';
			setTimeout(function() {f.key.style.border='inset #555 1px';} , 1000 );
			f.key.focus();
			return false; }
	productID = $('#productID').attr('value');
	commentID = $('#delete_review').attr('value');
	lang_iso2 = $('#lang_iso2').attr('value');
	if (document.getElementById('c_image')) c_image = f.c_image.value;
	key = f.key.value;
	$('#facebox .content').css( 'display' , 'none' );
	$('#facebox .footer').css( 'display' , 'none' );
	$('#facebox .body').append('<div class="loading"><img src="/published/SC/html/scripts/js/plugins/facebox/loading.gif"/></div>');
	if (document.getElementById('c_image'))
	$.get('/ajax.php',{ 
		  'productID' : productID,
		  'delete_review' : commentID,
		  'lang_iso2' : lang_iso2,
		  'c_image' : c_image,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	else
			$.get('/ajax.php',{ 
		  'productID' : productID,
		  'delete_review' : commentID,
		  'lang_iso2' : lang_iso2,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	return false;
}
function deleteComment( DID )
{
	$('#comment_'+DID).slideUp('fast', function() { $('#comment_'+DID).remove(); } );	
}
function doRenameProduct( f )
{
	if ( f.new_name.value.length < 3 )
		{ 	f.new_name.style.border='1px solid #F00';
			setTimeout(function() {f.new_name.style.border='inset #555 1px';} , 1000 );
			f.new_name.focus();
			return false; }
	if ( document.getElementById('c_image') && f.c_image.value.length == 0 )
		{ 	f.c_image.style.border='1px solid #F00';
			setTimeout(function() {f.c_image.style.border='inset #555 1px';} , 1000 );
			f.c_image.focus();
			return false; }
	if ( f.key.value.length < 3 )
		{ 	f.key.style.border='1px solid #F00';
			setTimeout(function() {f.key.style.border='inset #555 1px';} , 1000 );
			f.key.focus();
			return false; }
	productID = $('#productID').attr('value');
	new_name = $('#new_name').attr('value');
	lang_iso2 = $('#lang_iso2').attr('value');
	if (document.getElementById('c_image')) c_image = f.c_image.value;
	key = f.key.value;
	$('#facebox .content').css( 'display' , 'none' );
	$('#facebox .footer').css( 'display' , 'none' );
	$('#facebox .body').append('<div class="loading"><img src="/published/SC/html/scripts/js/plugins/facebox/loading.gif"/></div>');
	if (document.getElementById('c_image'))
	$.get('/ajax.php',{ 
		  'productID' : productID,
		  'rename_product' : productID,
		  'lang_iso2' : lang_iso2,
		  'new_name' : new_name,
		  'c_image' : c_image,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	else
	$.get('/ajax.php',{ 
		  'productID' : productID,
		  'rename_product' : productID,
		  'lang_iso2' : lang_iso2,
		  'new_name' : new_name,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	return false;
}
function renameProduct( new_name )
{
	$('.cpt_product_name h1').html( new_name );	
}
function doAddTagToCloud( f )
{
	if (lang_iso2=='en')
		var reg = new RegExp( '^[a-z0-9-]{3,50}$' , 'i' );
	else
		var reg = new RegExp( '^[0-9а-я-]{3,50}$' , 'i' );

	if ( f.new_tag.value<3 )
		{ 	f.new_tag.style.border='1px solid #F00';
			setTimeout(function() {f.new_tag.style.border='inset #555 1px';} , 1000 );
			f.new_tag.focus();
			return false; }
	if ( f.key.value.length < 3 )
		{ 	f.key.style.border='1px solid #F00';
			setTimeout(function() {f.key.style.border='inset #555 1px';} , 1000 );
			f.key.focus();
			return false; }
	productID = $('#productID').attr('value');
	new_tag = $('#new_tag').attr('value');
	lang_iso2 = $('#lang_iso2').attr('value');
	if (document.getElementById('c_image')) c_image = f.c_image.value;
	key = f.key.value;
	$('#facebox .content').css( 'display' , 'none' );
	$('#facebox .footer').css( 'display' , 'none' );
	$('#facebox .body').append('<div class="loading"><img src="/published/SC/html/scripts/js/plugins/facebox/loading.gif"/></div>');
	$.get('/ajax.php',{ 
		  'productID' : productID,
		  'addmytag' : productID,
		  'lang_iso2' : lang_iso2,
		  'new_tag' : new_tag,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	return false;
}
function removePoint( f )
{
	if ( f.key.value.length < 3 )
		{ 	f.key.style.border='1px solid #F00';
			setTimeout(function() {f.key.style.border='inset #555 1px';} , 1000 );
			f.key.focus();
			return false; }
	productID = $('#productID').attr('value');
	remove_point = $('#remove_point').attr('value');
	lang_iso2 = $('#lang_iso2').attr('value');
	key = f.key.value;
	$('#facebox .content').css( 'display' , 'none' );
	$('#facebox .footer').css( 'display' , 'none' );
	$('#facebox .body').append('<div class="loading"><img src="/published/SC/html/scripts/js/plugins/facebox/loading.gif"/></div>');
	$.get('/ajax.php',{ 
		  'productID' : productID,
		  'remove_point' : remove_point,
		  'lang_iso2' : lang_iso2,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });
	return false;	
}
function doSendEmail( f )
{
	if ( f.your_name.value.length < 3 )
		{ 	f.your_name.style.border='1px solid #F00';
			setTimeout(function() {f.your_name.style.border='inset #555 1px';} , 1000 );
			f.your_name.focus();
			return false; }
	var reg_mail = new RegExp( '^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$' , 'i' );		
	if ( !reg_mail.test( f.friend_email.value ) )
		{ 	f.friend_email.style.border='1px solid #F00';
			setTimeout(function() {f.friend_email.style.border='inset #555 1px';} , 1000 );
			f.friend_email.focus();
			return false; }
	if ( f.mail_text.value.length < 3 )
		{ 	f.mail_text.style.border='1px solid #F00';
			setTimeout(function() {f.mail_text.style.border='inset #555 1px';} , 1000 );
			f.mail_text.focus();
			return false; }
	if ( f.key.value.length < 3 )
		{ 	f.key.style.border='1px solid #F00';
			setTimeout(function() {f.key.style.border='inset #555 1px';} , 1000 );
			f.key.focus();
			return false; }
	productID = $('#productID').attr('value');
	lang_iso2 = $('#lang_iso2').attr('value');
	your_name = $('#your_name').attr('value');
	friend_email = $('#friend_email').attr('value');
	mail_text = $('#mail_text').attr('value');
	key = f.key.value;
	$('#facebox .content').css( 'display' , 'none' );
	$('#facebox .footer').css( 'display' , 'none' );
	$('#facebox .body').append('<div class="loading"><img src="/published/SC/html/scripts/js/plugins/facebox/loading.gif"/></div>');
	$.post('/ajax.php?productID='+productID+'&friend_help=1',{ 
		  'your_name' : your_name,
		  'mail_text' : escape(mail_text),
		  'friend_email' : friend_email,
		  'lang_iso2' : lang_iso2,
		  'key' : key
		  }, function( data ) {
			$('#facebox .content').html( data );
			$('#facebox .content').attr('style',null);
			$('#facebox .footer').attr('style',null);
			$('#facebox .body .loading').remove();
		  });

	return false;
}
function count_text( f ) {
		
}
