var cur_dis="";
function popup(action, message, width, height)
{
	if (action == 1)
	{
		$('object').fadeOut();
		$('#popup_message').html(message).css({width: width});
		$('#popup_body').css({width: width}).modal({overlayClose:true});
	}
	else
	{
		$('object').fadeIn();
		$.modal.close();
	}
}
function popup_show(type, id)
{
	$.post(
			base_url + '/json/popup_show',
			{
				type: type,
				id: id,
                dis: cur_dis
			},
			function(data)
			{
				popup(1, data.body, data.width);
			},
			"json"
		);
}

function learn_player_hide(status)
{
	$.getJSON(
			base_url + '/json/learn_player_hide',
			{
				status: status
			},
			function(data)
			{
				if (status)
				{
					$('#property_player').css({display: "none"});
					$('#property_player_maximize').css({display: "block"});
				}
				else
				{
					$('#property_player').css({display: "block"});
					$('#property_player_maximize').css({display: "none"});
				}
			}
		);
}

function player_movie_change(url)
{
	swfobject.embedSWF('http://www.youtube.com/v/' + url +'&ap=%2526fmt%3D22', "flash_player", "700", "275", "10.0.0", false, false, {allowscriptaccess:"always",allowfullscreen:"true",wmode:"opaque"});
}

function view_shared(url)
{
	$.post(
			base_url + '/json/shared',
			{
				url: url
			},
			function(data)
			{
				if (data.status)
				{
					if ($('#v3_view_share').html() == 'Enable Share')
					{
						$('#v3_view_share').html('Disable Share').addClass('v3_view_shared');
						$('#v3_view_shared_border').addClass('v3_view_shared_active');
						$('#v3_view_shared_button').removeClass('display_none');
						$('#v3_view_shared_button_con').addClass('display_none');
						$('#view_embed_url').removeAttr("disabled").attr("readonly", true).css({'background-color': '#FFFFE5', 'color': '#777777'});
						$('#view_embed_text').removeAttr("disabled").attr("readonly", true).css({'background-color': '#FFFFE5', 'color': '#777777'});
					}
					else
					{
						$('#v3_view_share').html('Enable Share').removeClass('v3_view_shared');
						$('#v3_view_shared_border').removeClass('v3_view_shared_active');
						$('#v3_view_shared_button').addClass('display_none');
						$('#v3_view_shared_button_con').removeClass('display_none');
						$('#view_embed_url').removeAttr("readonly").attr("disabled", true).css({'background-color': '#f2f2f2', 'color': '#b2b2b2'});
						$('#view_embed_text').removeAttr("readonly").attr("disabled", true).css({'background-color': '#f2f2f2', 'color': '#b2b2b2'});
					}
					$('#shared_now').html(data.shared_3dphoto);
				}
				else
				{
					popup(1, data.message, 369, 176);
				}
			},
			"json"
		);
}
function view_download(url)
{
	$.post(
		base_url + '/json/view_download',
		{
			'url': url
		},
		function(data)
		{
			if (data.status)
			{
				$('#buy_3dphoto').html($('#buy_3dphoto').html()-1);
				window.location = data.url_swf;
			}
			else
			{
				popup(1, data.message, 369, 176);
			}
		},
		"json"
	);
}

function carousel(id, move)
{
	node = $('#' + id);
	children = node.children('li').size();
	node_width = node.width();
	diff = node_width / children;
	position = node.position().left;
	if (move)
	{
		move = position - diff;
		if ((node_width + move - diff) < 0)
		{
			move = 0;
		}
	}
	else
	{
		move = position + diff;
		if (move > 0)
		{
			move = 0;
		}
	}
	node.animate({left: move +'px'});
}

function input_select(value)
{
	$(value).select();
}
function checkbox(value)
{
	check = $('#' + value);
	img = $('#' + value + '_img');
	if (check.is(':checked'))
	{
		check.attr('checked', '');
		img.attr('src', base_url + '/' + design_current +cur_dis+'/img/shape_passive.gif');
	}
	else
	{
		check.attr('checked', 'checked');
		img.attr('src', base_url + '/' + design_current +cur_dis+ '/img/shape_active.gif');
	}
}

function Dump(d,l)
{
	if (l === null)
	{
		l = 1;
	}
	var s = '';
	if (typeof(d) == "object")
	{
		s += typeof(d) + " {\n";
		for (var k in d)
		{
			for (var i=0; i<l; i++)
			{
				s += "  ";
			}
			s += k+": " + Dump(d[k],l+1);
		}
		for (var m=0; m<l-1; m++)
		{
			s += "  ";
		}
		s += "}\n";
	}
	else
	{
		s += "" + d + "\n";
	}
	return s;
}

function empty( mixed_var )
{
	var key;
	if (mixed_var === "" ||
			mixed_var === 0 ||
			mixed_var === "0" ||
			mixed_var === null ||
			mixed_var === false ||
			mixed_var === undefined
		)
	{
		return true;
	}

	if (typeof mixed_var == 'object')
	{
		for (key in mixed_var)
		{
			return false;
		}
		return true;
	}
	return false;
}

$.fn.hint = function (blurClass) {
	if (!blurClass) {
		blurClass = 'blur';
	}
	return this.each(function () {
		var $input = $(this),
		title = $input.attr('title'),
		isPassword = $input.attr('type') == 'password',
		$form = $(this.form),
		$win = $(window);

		var strategies = {
			changeValue: {
				init: function() {},
					add: function() {
						if ($input.val() === '') {
							$input.addClass(blurClass).val(title);
						}
					},
					remove: function() {
						if ($input.val() === title && $input.hasClass(blurClass)) {
							$input.val('').removeClass(blurClass);
						}
					},
					submit: function() {
						//this.remove();
					}
			},

			replaceElement: {
				init: function() {
					var $alt = $('<input />').clone($input.clone());
					$input.addClass("replaced-for-title");
					$alt.attr("id", null).attr("type", "text").val(title).insertBefore($input).addClass("password-title").addClass(blurClass).hide().focus(function() {
						$d($alt).original.focus();
					});
					$d($input).alternative = $alt;
					$d($alt).original = $input;
				},
				add: function() {
					if ($input.val() === '') {
						$input.hide();
						var id = $input.attr("id");
						$input.attr("id", null);
						$d($input).alternative.attr("id", id).show();
					}
				},
				remove: function() {
					if ($input.is(":hidden")) {
						var id = $d($input).alternative.attr("id");
						$d($input).alternative.attr("id", null).hide();
						$input.attr("id", id).show();
					}
				},
				submit: function() {
					//$d($input).alternative.remove();
				}
			}
		};

		if (title) {
			var strategyName = isPassword ? "replaceElement" : "changeValue";
			var strategy = strategies[strategyName];

			strategy.init();
			$input.blur(strategy.add).focus(strategy.remove).blur();

			$form.submit(strategy.submit);
			$win.unload(strategy.submit);
		}
	});
};

/*disable scroll for flash*/
function cancelEvent(e)
{
	e = e ? e : window.event;
	if (e.stopPropagation)
	{
		e.stopPropagation();
	}
	if (e.preventDefault)
	{
		e.preventDefault();
	}
	e.cancelBubble = true;
	e.cancel = true;
	e.returnValue = false;
	return false;
}
function isOverSwf(mEvent)
{
	var elem;
	if (mEvent.srcElement) {
		elem = mEvent.srcElement.nodeName;
	} else if (mEvent.target) {
		elem = mEvent.target.nodeName;
	}

	if (elem.toLowerCase() == "object" || elem.toLowerCase() == "embed") {
		return true;
	}
	return false;
}
function onMouseWheel(event)
{
	var delta = 0;
	if (!event)
	{
		event = window.event;
	}
	if (event.wheelDelta) {
		delta = event.wheelDelta/120;
		if (window.opera)
		{
			delta = -delta;
		}
	} else if (event.detail) {
		delta = -event.detail/3;
	}

	if (isOverSwf(event)) {
		return cancelEvent(event);
	}

return true;
}
function hookMouseWheel()
{
	if (window.addEventListener)
	{
		window.addEventListener('DOMMouseScroll', onMouseWheel, false);
	}
	window.onmousewheel = document.onmousewheel = onMouseWheel;
}
hookMouseWheel();

var gallery_v3_data = false;
var gallery_v3_focus = false;
var property_photo_data = false;
var property_photo_data_b = false;
var property_photo_more_data = false;
var property_photo_data_select = [];
var property_photo_data_select_all = false;
var property_img = false;
var property_img_more = false;
var property_logo_data = false;
var property_logo_hasfocus = false;
var property_logo_choise = false;
var intro_swf_id = false;
var intro_swf = ['zummarva', 'jdnnyuxo', 'eyovepsu', 'vapcyyqc'];
var intro_banner = false;
var buy_goods = 1;
var buy_is_type = 'auth';
var video_pr_th=[];
var video_select=[];
var video_pr_th_size=0;


function gallery_save_name(value, status)
{
	index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent().parent().parent());
	url = gallery_v3_data[index].url;
	name_old = gallery_v3_data[index].task_name;
	input = $('#gallery_v3 > div:eq(' + index + ') input');
	name = input.val();
	obj = $(value).parent();
	if (status == 1)
	{
		$.post(
				base_url + '/json/gallery_name_save',
				{
					'url': url,
					'task_name': name
				},
				function(data)
				{
					obj.css({display: 'none'});
				},
				"json"
			);
	}
	else
	{
		input.val(name_old);
		obj.css({display: 'none'});
	}
}
function gallery_save(value)
{
	obj = $(value).parent();
	obj.children('div').css({display: 'block'});
}
function gallery_setting(value)
{
	index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent().parent().parent());
	url = gallery_v3_data[index].url;
	window.location = base_url +cur_dis+ '/TaskProperty/' + url;
}
function gallery_delete(value)
{
	index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent().parent().parent());
	url = gallery_v3_data[index].url;
	popup_show('task_rm', url);
}
function gallery_click(value)
{
	index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent().parent());
	if (gallery_v3_data.length <= index)
	{
		popup_show('task_create');
		return false;
	}
	url = gallery_v3_data[index].url;
	if (!empty(gallery_v3_data[index].swf))
	{
		window.location = base_url +cur_dis+ '/3DPhotoView/' + url;
	}
	else
	{
		window.location = base_url +cur_dis+ '/TaskProperty/' + url;
	}
}
function gallery_v3_hover(value, focus, status)
{
	if (!focus)
	{
		if (value.nodeName == 'INPUT')
		{
			$(value).toggleClass('border');
		}
		else
		{
			index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent());
			if (gallery_v3_data[index].process)
			{
				return false;
			}
			if (status)
			{
				$(value).children('div:first').children('div').removeClass('display_none');
				$(value).addClass('hover');
				if (gallery_v3_data[index].shared == 1)
				{
					$(value).children('div:last').html('DISABLE SHARE').removeClass('display_none');
					$(value).children('div.shared_task').addClass('display_none');
				}
				else
				{
					if (!empty(gallery_v3_data[index].swf))
					{
						$(value).children('div:last').html('ENABLE SHARE').removeClass('display_none');
					}
				}
			}
			else
			{
				$(value).children('div:first').children('div').addClass('display_none');
				$(value).removeClass('hover');
				if (gallery_v3_data[index].shared == 1)
				{
					$(value).children('div:last').html('DISABLE SHARE').addClass('display_none');
					$(value).children('div.shared_task').removeClass('display_none');
				}
				else
				{
					if (!empty(gallery_v3_data[index].swf))
					{
						$(value).children('div:last').html('ENABLE SHARE').addClass('display_none');
					}
				}
			}
		}
	}
	else
	{
		if (gallery_v3_focus)
		{
			$(gallery_v3_focus).toggleClass('input_focus');
		}
		$(value).toggleClass('input_focus');
		gallery_v3_focus = value;
	}
}
function gallery_v3_opacity(value)
{
	$(value).toggleClass('opacity');
}
function gallery_v3_blur(value)
{
	$(gallery_v3_focus).toggleClass('input_focus');
	gallery_v3_focus = false;
}
function gallery_inner_clean(place)
{
	var node = $('#gallery_v3 > div:eq(' + place + ')');
	node.empty();
	node.append('<div class="border_free">'+
					'<div class="option">'+
						'<div class="setting opacity display_none">SETTINGS</div>'+
						'<div class="delete opacity display_none">x</div>'+
					'</div>'+
					'<div class="node_click"><!-- --></div>'+
					'<div class="demo_mode display_none"><!-- --></div>'+
					'<div class="shared_task display_none">SHARED</div>'+
					'<div class="share opacity display_none"><!-- --></div>'+
				'</div>'+
				'<div><!--  --></div>');
}
function gallery_inner_state(place, data)
{
	$('#gallery_v3_state_' + place).html(data.state);
}
function gallery_inner(place, data)
{
	gallery_inner_clean(place);
	var node = $('#gallery_v3 > div:eq(' + place + ')');
	node.children('div:first').toggleClass('border').css('background-image', 'url(' + data.thumb +')');
	if (data.process)
	{
		node.children('div:first').toggleClass('border').css('background-image', 'url(\'\')');
		node.children('div:first').html('<div class="gallery_v3_progress">'+
											'<div id="gallery_progress_' + place + '"></div>'+
										'</div>'+
										'<div id="gallery_v3_state_' + place + '" class="gallery_v3_state">' + data.state +'</div>');
		swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'gallery_progress_' + place, "146", "110", "9.0.0", false, false, {wmode:"transparent"});
	}
	if (!empty(data.shared))
	{
		node.children('div:first').addClass('shared');
		node.children('div:first').children('div.shared_task').toggleClass('display_none');
	}
	else
	{
		node.children('div:first').removeClass('shared');
	}
	if (data.demo_mode)
	{
		node.children('div:first').children('div.demo_mode').removeClass('display_none');
	}
	node.children('div:last').append('<input type="text" />');
	node.children('div:last').append('<div class="name_setting"><a onclick="gallery_save_name(this, 1); return false;" class="button_search_node_v" href="#"/><a onclick="gallery_save_name(this, 0); return false;" class="button_search_node_x" href="#"/></div>');
	node.children('div:last').children('input').val(data.task_name).addClass('input_border_free');

	node.children('div:first').mouseover(function () { gallery_v3_hover(this, false, true); }).mouseout(function () { gallery_v3_hover(this); });
	node.children('div:last').children('input').mouseover(function () { gallery_v3_hover(this, false, true); }).mouseout(function () { gallery_v3_hover(this); }).focus(function () { gallery_v3_hover(this, true); }).blur(function () { gallery_v3_blur(this); }).keydown(function () { gallery_save(this); });
	node.children('div:first').children('div.option').children('div').mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
	node.children('div:first').children('div.option').children('div.setting').click(function(){ gallery_setting(this); });
	node.children('div:first').children('div.option').children('div.delete').click(function(){ gallery_delete(this); });
	node.children('div:first').children('div.share').mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
	node.children('div:first').children('div.share').click(function(){ gallery_share(this); });
	node.children('div:first').children('div.node_click').click(function(){ gallery_click(this); });
}
function gallery_v3(resume)
{
	$.getJSON(
			base_url + '/json/gallery_v3',
			{
			},
			function(data)
			{
				var sizeof = data.length;
				var i;
				if (sizeof >= 0)
				{
					if (!gallery_v3_data)
					{
						for (i in data)
						{
							gallery_inner(i, data[i]);
						}
						gallery_v3_data = data;
					}
					else
					{
						if (sizeof < gallery_v3_data.length)
						{
							for (i in gallery_v3_data)
							{
								if (!empty(data[i]))
								{
									if ((data[i].url != gallery_v3_data[i].url) || (data[i].process != gallery_v3_data[i].process) || (data[i].shared != gallery_v3_data[i].shared))
									{
										gallery_inner(i, data[i]);
									}
									if (data[i].process === true && (data[i].update != gallery_v3_data[i].update))
									{
										gallery_inner_state(i, data[i]);
									}
								}
								else if (empty(data[i]))
								{
									gallery_inner_clean(i);
								}
							}
						}
						else
						{
							for (i in data)
							{
								if (!empty(gallery_v3_data[i]))
								{
									if ((data[i].url != gallery_v3_data[i].url) || (data[i].process != gallery_v3_data[i].process) || (data[i].shared != gallery_v3_data[i].shared))
									{
										gallery_inner(i, data[i]);
									}
									if (data[i].process === true && (data[i].update != gallery_v3_data[i].update))
									{
										gallery_inner_state(i, data[i]);
									}
								}
								else if (empty(gallery_v3_data[i]))
								{
									gallery_inner(i, data[i]);
								}
							}
						}
					}
					gallery_v3_data = data;
				}
				if (resume)
				{
					setTimeout('gallery_v3(true)', 1500);
				}
			}
		);
}
function gallery_page_set(page)
{
	$.post(
			base_url + '/json/gallery_page_set',
			{
				page: page
			},
			function(data)
			{
				$('#page_number').html(data.page_current);
				a = $('#button_search_list_first').attr('class', 'button_search_list_first active');
				b = $('#button_search_list_previous').attr('class', 'button_search_list_previous active');
				c = $('#button_search_list_next').attr('class', 'button_search_list_next active');
				d = $('#button_search_list_last').attr('class', 'button_search_list_last active');
				if (data.page_current == 1)
				{
					a.attr('class', 'button_search_list_first passive');
					b.attr('class', 'button_search_list_previous passive');
				}
				if (data.page_current == data.page_all)
				{
					c.attr('class', 'button_search_list_next passive');
					d.attr('class', 'button_search_list_last passive');
				}
				gallery_v3();
			},
			"json"
		);
	return true;
}
function gallery_share(value)
{
	index = $('#gallery_v3 div.gallery_v3_node').index($(value).parent().parent());
	url = gallery_v3_data[index].url;
	$.post(
			base_url + '/json/shared',
			{
				"url": url
			},
			function(data)
			{
				if (data.status)
				{
					$('#shared_now').html(data.shared_3dphoto);
					gallery_v3();
				}
				else
				{
					popup(1, data.message, 369, 176);
				}
			},
			"json"
		);
}
function gallery_view_shared()
{
	$.getJSON(
			base_url + '/json/gallery_view_shared',
			{
			},
			function(data)
			{
				gallery_v3();
				gallery_page_set('init');
			}
	);
}
function gallery_search(value)
{
	if (!value)
	{
		$('#now_search').val('').focus();
	}
	$.post(
			base_url + '/json/gallery_search',
			{
				now_search: $('#now_search').val()
			},
			function(data)
			{
				gallery_v3();
				gallery_page_set('init');
			},
			"json"
		);
}


function property_select_photo_select_is_all()
{
	if (!property_photo_data)
	{
		return false;
	}
	if (empty(property_photo_data[0]))
	{
		return false;
	}
	is_all = true;
	var id;
	for (id in property_photo_data)
	{
		file_id = property_photo_data[id].file_id;
		if (empty(property_photo_data_select[file_id]) || (property_photo_data_select[file_id] === false))
		{
			is_all = false;
		}
	}
	if (is_all)
	{
		property_photo_data_select_all = true;
		$('#pr_select_all').html('Unselect All');
	}
	else
	{
		property_photo_data_select_all = false;
		$('#pr_select_all').html('Select All');
	}
}
function property_zoom_change(value)
{
	if (value == 'property_zoom_f')
	{
		$('#property_zoom_f_img').attr('src', base_url + '/' + design_current +cur_dis+ '/img/circle_active.png');
		$('#property_zoom_n_img').attr('src', base_url + '/' + design_current +cur_dis+ '/img/circle_passive.png');
		$('#property_zoom_f').attr('checked', 'checked');
	}
	else
	{
		$('#property_zoom_f_img').attr('src', base_url + '/' + design_current +cur_dis+ '/img/circle_passive.png');
		$('#property_zoom_n_img').attr('src', base_url + '/' + design_current +cur_dis+ '/img/circle_active.png');
		$('#property_zoom_n').attr('checked', 'checked');
	}
}
function property_height()
{
	height = $('#pr_menu').height() + 20;
	m2 = $('#pr_n1').height() + 60;
	if ($('#pr_n2').size())
	{
		m2 = m2 + $('#pr_n2').height();
	}
	if ($('#pr_n3').size())
	{
		m2 = m2 + $('#pr_n3').height();
	}
	if (height < m2)
	{
		height = m2;
	}
	$('#property_body').css('height', height);
}
function property_photo_inner(place, data)
{
    
	var node = $('#pr_photo > div:eq(' + place + ')');
	node.children('div:first').addClass('border').css({'background-image': 'url(' + data.thumb +')', 'cursor': 'pointer'});
	node.children('div:last').html(data.name);
	node.removeClass('display_none');
	if (!empty(property_photo_data_select[data.file_id]) && (property_photo_data_select[data.file_id] === true))
	{
		node.children('div').children('div.pr_checkbox').removeClass('display_none').children('img').attr('src',  base_url + '/' + design_current +cur_dis+ '/img/shape_active.gif');
	}
	else if (empty(property_photo_data_select[data.file_id]) || (property_photo_data_select[data.file_id] === false))
	{
		node.children('div').children('div.pr_checkbox').addClass('display_none').children('img').attr('src',  base_url + '/' + design_current +cur_dis+ '/img/shape_passive.gif');
	}
}
function property_photo_more_inner(place, data)
{
	var node = $('#pr_photo_more > div:eq(' + place + ')');
	node.children('div:first').addClass('border').css({'background-image': 'url(' + data.thumb +')', 'cursor': 'pointer'});
	node.children('div:last').html(data.name);
}
function property_photo(resume)
{
    sizef=0;
	$.getJSON(
			base_url + '/json/property_thumb',
			{
				url: url
			},
			function(data)
			{
				var sizeof = data.length;
                sizef=sizeof;
				var id;
				if (sizeof >= 0)
				{
					if (!property_photo_data)
					{
						for (id in data)
						{
							property_photo_inner(id, data[id]);
                               video_pr_th[video_pr_th_size]= new Image();
                                        video_pr_th[video_pr_th_size].src=data[id].thumb_1;
                                        video_select[video_pr_th_size]=data[id].select;
                                        video_pr_th_size++;
                                        //alert(data[id].thumb);
						}
					}
					else
					{
						if (sizeof < property_photo_data.length)
						{
							for (id in property_photo_data)
							{
								if (!empty(data[id]) && (data[id].file_id != property_photo_data[id].file_id))
								{
									property_photo_inner(id, data[id]);
                                    
                                  
								}
								else if (empty(data[id]))
								{
								       
									if (id <= 14)
									{
									   
										$('#pr_photo > div:eq(' + id + ')').children('div:first').css({'background-image': '', 'cursor': 'default'});
										$('#pr_photo > div:eq(' + id + ')').children('div:last').html('');
										$('#pr_photo > div:eq(' + id + ')').children('div:first').removeClass('border').removeClass('hover');
										$('#pr_photo > div:eq(' + id + ')').children('div').children('div').addClass('display_none');
									}
									else
									{
										$('#pr_photo > div:eq(' + id + ')').addClass('display_none');
                                        
									}
								}
							}
						}
						else
						{
							for (id in data)
							{
								if (!empty(property_photo_data[id]) && (data[id].file_id != property_photo_data[id].file_id))
								{
								    
									property_photo_inner(id, data[id]);
								}
								else if (empty(property_photo_data[id]))
								{
								    video_pr_th[video_pr_th_size]= new Image();
                                        video_pr_th[video_pr_th_size].src=data[id].thumb_1;
                                        video_select[video_pr_th_size]=data[id].select;
                                        video_pr_th_size++;
									property_photo_inner(id, data[id]);
                           
								}
							}
						}
					}
					property_photo_data = data;
                    
					property_select_photo_select_is_all();
					$.getJSON(
							base_url + '/json/property_thumb_b',
							{
								url: url
							},
							function(data)
							{
								var sizeof = data.length;
								if (sizeof >= 0)
								{
									if (empty(property_photo_data_b[0]) && !empty(data[0]))
									{
										$('#pr_b1').css('background-image', 'url(' + data[0].thumb +')');
									}
									else
									{
										if (!empty(data[0]) && (data[0].file_id != property_photo_data_b[0].file_id))
										{
											$('#pr_b1').css('background-image', 'url(' + data[0].thumb +')');
										}
										else if (empty(data[0]))
										{
											$('#pr_b1').css('background-image', '');
										}
									}
								}
								property_photo_data_b = data;
                                
							}
						);
						$.getJSON(
								base_url + '/json/property_thumb_more',
								{
									url: url
								},
								function(data)
								{
									var sizeof = data.length;
									var id;
									if (sizeof >= 0)
									{
										if (!property_photo_more_data)
										{
											for (id in data)
											{
												property_photo_more_inner(id, data[id]);
											}
										}
										else
										{
											if (sizeof < property_photo_more_data.length)
											{
												for (id in property_photo_more_data)
												{
													if (!empty(data[id]) && (data[id].file_id != property_photo_more_data[id].file_id))
													{
														property_photo_more_inner(id, data[id]);
													}
													else if (empty(data[id]))
													{
														$('#pr_photo_more > div:eq(' + id + ')').children('div:first').css({'background-image': '', 'cursor': 'default'});
														$('#pr_photo_more > div:eq(' + id + ')').children('div:last').html('');
														$('#pr_photo_more > div:eq(' + id + ')').children('div:first').removeClass('border');
														$('#pr_photo_more > div:eq(' + id + ')').children('div').children('div').addClass('display_none');
													}
												}
											}
											else
											{
												for (id in data)
												{
													if (!empty(property_photo_more_data[id]) && (data[id].file_id != property_photo_more_data[id].file_id))
													{
														property_photo_more_inner(id, data[id]);
													}
													else if (empty(property_photo_more_data[id]))
													{
														property_photo_more_inner(id, data[id]);
													}
												}
											}
										}
										property_photo_more_data = data;
                                        
                                        
									}
								}
							);
				}
				if (resume)
				{
					setTimeout('property_photo(true)', 4000);
				}
				property_height();
                if (sizef>0)
                property_show_preview_video(0);
			} 	
 
            
		);
}


	var attributes = {  
		id: "MultiPowUpload",  
		name: "MultiPowUpload"
	};

function property_open(file_type_id)
{
	$.getJSON(
			base_url + '/json/property_file_limit',
			{
				url: url,
				file_type_id: file_type_id
			},
			function(data)
			{
				if (empty(data))
				{
					$.getJSON(
							base_url + '/json/property_open_show',
							{
							},
							function(data)
							{
								popup(1, data.message, 369, 176);
							}
					);
					return true;
				}
				
				$('#property_iu').modal();
				//swfobject.embedSWF(base_url + '/' + design_current + '/swf/iu.swf', "iu", "831", "557", "10.0.0", false, {uploaderUrl: base_url + '/upload/' + session_id + '/' + task_id + '/' + file_type_id, quality:90, fileMaxSize:11000, filesLimit: data, compressMaxSize: 1028, waitUpload: true});
                swfobject.embedSWF(base_url + '/' + design_current + '/swf/multipowupload/ElementITMultiPowUpload.swf',
                 "iu", 
                 "741", 
                 "557", 
                 "10.0.0", 
                 false, 
                 {uploadUrl: base_url + '/upload/' + session_id + '/' + task_id + '/' + file_type_id, 
                 quality:90, 
                 fileMaxSize:11000, 
                 filesLimit: data,
                 compressMaxSize:1028, 
                 waitUpload: true,
                 serialNumber:"008272216916125212785253822171832739286724610217",
                 "language.autoDetect":true,
                 "language.source":base_url+"/designes/3dbin/swf/multipowupload/Extra/Languages/Language_<LANGUAGE_CODE>.xml",
                 "fileView.defaultView":"thumbnails",
                 sendOriginalImages:false,
                 sendThumbnails:true,
                 "thumbnail.width":1280,
                 "thumbnail.height":1280,
                 "thumbnail.resizeMode":"fitByWidth",
                 "thumbnail.jpgQuality":100});
                 //$("#iu").setParameter("language.source",base_url+"/designes/3dbin/swf/multipowupload/Extra/Languages/Language_"+document.getElementById("language").value+".xml");
			}
	);
}
function property_close()
{
	$.modal.close();
	property_photo();
}
function property_upload_stat(size, time)
{
	$.post(
			base_url + '/json/property_upload_stat',
			{
				size: size,
				time: time
			},
			function(data)
			{
			},
			"json"
		);
}





function property_hover(value, type, status)
{
    //
	if (type == 2)
	{
	   
		if (!empty(property_photo_data_b[0]))
		{
			if (status)
			{
				$(value).addClass('hover');
				$(value).children('div').removeClass('display_none');
			}
			else
			{
				$(value).removeClass('hover');
				$(value).children('div').addClass('display_none');
			}
		}
	}
	else if (type == 3)
	{
	   
		index = $('#pr_photo_more div.pr_node_c').index($(value));
		if (!empty(property_photo_more_data[index]))
		{
			if (status)
			{
				$(value).children('div:first').addClass('hover');
				$(value).children('div').children('div').removeClass('display_none');
			}
			else
			{
				$(value).children('div:first').removeClass('hover');
				$(value).children('div').children('div').addClass('display_none');
			}
		}
	}
	else
	{
	   if (!($("#video_url").size()) )
       {
		index = $('#pr_photo div.pr_node_c').index($(value));
		if (empty(property_photo_data[index]))
		{
			return false;
		}
		file_id = property_photo_data[index].file_id;
		if (!empty(property_photo_data[index]))
		{
			if (status)
			{
				$(value).children('div:first').addClass('hover');
				$(value).children('div:first').children('div').removeClass('display_none');
			}
			else
			{
				$(value).children('div:first').removeClass('hover');
				$(value).children('div:first').children('div').addClass('display_none');
				if (!empty(property_photo_data_select[file_id]) || (property_photo_data_select[file_id] === true))
				{
					$(value).children('div:first').children('div.pr_checkbox').removeClass('display_none');
				}
			}
		}
        }
	}
}

function property_set_b_show(value)
{
	index = $('#pr_photo div.pr_node_c').index($(value).parent().parent());
	file_id = property_photo_data[index].file_id;
	$.getJSON(
			base_url + '/json/property_set_b_show',
			{
				file_id: file_id
			},
			function(data)
			{
				popup(1, data.message, 369, 176);
			}
	);
}
function property_set_b(file_id)
{
	$.getJSON(
			base_url + '/json/property_set_b',
			{
				file_id: file_id
			},
			function(data)
			{
				if ($('#pr_b1').css('background-image') == 'none')
				{
					property_zoom_change('property_zoom_f');
					if (!$('#property_aclean').is(':checked'))
					{
						checkbox('property_aclean');
					}
				}
				popup();
				property_photo();
			}
	);
}
function property_delete_show(value, type)
{
	if (type == 2)
	{
		file_id = property_photo_data_b[0].file_id;
	}
	else if (type == 3)
	{
		index = $('#pr_photo_more div.pr_node_c').index($(value).parent().parent());
		file_id = property_photo_more_data[index].file_id;
	}
	else if (type == 5)
	{
		index = $('#pr_logo_select_container li').index($(value).parent().parent());
		logo_id = property_logo_data[index].logo_id;
		if (!logo_id)
		{
			return false;
		}
		file_id = 'lg_' + logo_id;
	}
	else
	{
		index = $('#pr_photo div.pr_node_c').index($(value).parent().parent());
		file_id = property_photo_data[index].file_id;
	}
	$.getJSON(
			base_url + '/json/property_delete_show',
			{
				file_id: file_id
			},
			function(data)
			{
				popup(1, data.message, 369, 176);
			}
	);
}
function property_logo_show(status)
{
	if (status)
	{
		$('#pr_logo_select_container').removeClass('display_none');
	}
	else
	{
		if (!property_logo_hasfocus)
		{
			$('#pr_logo_select_container').addClass('display_none');
		}
	}
}
function property_logo_hover(value, status)
{
	index = $('#pr_logo_select_container li').index($(value).parent());
	is_local = true;
	if (property_logo_data[index].logo_id)
	{
		is_local = false;
	}
	if (status)
	{
		$(value).addClass('hover');
		if (!is_local)
		{
			$(value).children('div').removeClass('display_none');
		}
	}
	else
	{
		$(value).removeClass('hover');
		$(value).children('div').addClass('display_none');
	}
}
function property_logo_change(value)
{
	index = $('#pr_logo_select_container li').index($(value).parent());
	$('#pr_logo').css('background-image', 'url(' + property_logo_data[index].url +')');

	$('#pr_logo_select_container li:eq(' + property_logo_choise + ')').children('div').removeClass('shared');
	property_logo_choise = index;

	$(value).addClass('shared');

	property_logo_hasfocus = false;
	property_logo_show();
}

function property_logo_init(is_new)
{
	$.post(
			base_url + '/json/property_logo_init',
			{
				url: url
			},
			function(data)
			{
				con = $('#pr_logo_select_container ul');
				con.html('');
				var sizeof = data.length;
				var id;
				for (id in data)
				{
					con.append('<li><div class="pr_logo_node center border" style="float: none; background-image: url(' + data[id].url + ');"><div class="pr_delete opacity display_none" style="float: right;">x</div></div></li>');
					if (!is_new && data[id].is_select)
					{
						$('#pr_logo').css('background-image', 'url(' + data[id].url +')');
						property_logo_choise = id;
						con.children('li:last').children('div').addClass('shared');
					}
					else if (is_new && (id == (sizeof -1) ))
					{
						$('#pr_logo').css('background-image', 'url(' + data[id].url +')');
						property_logo_choise = id;
						con.children('li:last').children('div').addClass('shared');
					}
				}
				$('#pr_logo_select_container div.pr_logo_node').mouseover(function () { property_logo_hover(this, 1); }).mouseout(function () { property_logo_hover(this); }).click(function(){ property_logo_change(this); });
				$('#pr_logo_select_container div.pr_delete').click(function(){ property_delete_show(this, 5); }).mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
				property_logo_data = data;
			},
			"json"
	);
}
function property_logo_check()
{
	$.post(
			base_url + '/json/property_logo_check',
			{
			},
			function(data)
			{
				property_logo_init(true);
				if (!data.status)
				{
					popup(1, data.message, 369);
				}
			},
			"json"
		);
}
function property_upload_logo(file_type_id)
{
	
	$('#pr_ulogo').swfupload({
		upload_url: base_url + '/upload/' + session_id + '/' + task_id + '/' + file_type_id,
		file_size_limit : "10 MB",
		file_types : "*.jpg;*.jpeg;*.png;*.gif;*.bmp",
		file_types_description : "Images",
		file_upload_limit : "0",
		flash_url : base_url + '/' + design_current + '/swf/swfupload.swf',
		button_image_url : base_url + '/' + design_current +cur_dis+ '/img/v3_property_logo.png',
		button_width : 112,
		button_height : 28,
		button_placeholder : $('#pr_ulogo_button')[0],
		debug: false,
		button_window_mode: 'opaque',
		button_cursor: SWFUpload.CURSOR.HAND
	})
	.bind('fileQueued', function(event, file){
		$('#property_upload_progress').modal();
		$(this).swfupload('startUpload');
		$('#property_upload_progress_can').bind('click', function(){
			var swfu = $.swfupload.getInstance('#pr_ulogo');
			swfu.cancelUpload(file.id);
			property_close();
		});
	})
	.bind('fileQueueError', function(event, file, errorCode, message){
		$.post(
				base_url + '/json/property_swfupload_warning',
				{
					message: message
				},
				function(data)
				{
					popup(1, data.message, 369, 200);
				},
				"json"
			);
	})
	.bind('uploadStart', function(event, file){
	})
	.bind('uploadProgress', function(event, file, bytesLoaded, bytesAll){
		value = parseInt(bytesLoaded*100/bytesAll, 10);
		$('#property_upload_progress_n').css('width', value + '%');
		$('#property_upload_progress_p').html(value + '%');
	})
	.bind('uploadSuccess', function(event, file, serverData){
		property_close();
		property_logo_check();
	});
}
function property_upload_bg(file_type_id)
{
	$('#pr_ub1').swfupload({
		upload_url: base_url + '/upload/' + session_id + '/' + task_id + '/' + file_type_id,
		file_size_limit : "10 MB",
		file_types : "*.jpg;*.jpeg;*.png;*.gif;*.bmp",
		file_types_description : "Images",
		file_upload_limit : "0",
		flash_url : base_url + '/' + design_current + '/swf/swfupload.swf',
		button_image_url : base_url + '/' + design_current +cur_dis+ '/img/blank.gif',
		button_width : 110,
		button_height : 65,
		button_placeholder : $('#pr_b1_button')[0],
		debug: false,
		button_window_mode: 'transparent',
		button_cursor: SWFUpload.CURSOR.HAND
	})
	.bind('fileQueued', function(event, file){
		$('#property_upload_progress').modal();
		$(this).swfupload('startUpload');
		$('#property_upload_progress_can').bind('click', function(){
			var swfu = $.swfupload.getInstance('#pr_ub1');
			swfu.cancelUpload(file.id);
			property_close();
		});
	})
	.bind('fileQueueError', function(event, file, errorCode, message){
		$.post(
				base_url + '/json/property_swfupload_warning',
				{
					message: message
				},
				function(data)
				{
					popup(1, data.message, 369, 200);
				},
				"json"
			);
	})
	.bind('uploadStart', function(event, file){
		is_bg = false;
		if ($('#pr_b1').css('background-image') != 'none')
		{
			is_bg = true;
		}
	})
	.bind('uploadProgress', function(event, file, bytesLoaded, bytesAll){
		value = parseInt(bytesLoaded*100/bytesAll, 10);
		$('#property_upload_progress_n').css('width', value + '%');
		$('#property_upload_progress_p').html(value + '%');
	})
	.bind('uploadSuccess', function(event, file, serverData){
		property_close();
		if (!is_bg)
		{
			property_zoom_change('property_zoom_f');
			if (!$('#property_aclean').is(':checked'))
			{
				checkbox('property_aclean');
			}
		}
	});
}
function property_delete(file_id)
{
	$.getJSON(
			base_url + '/json/property_delete_photo',
			{
				file_id: file_id
			},
			function(data)
			{
				popup();
				property_photo();
				property_logo_init();
			}
	);
}

function get_video_state_thums()
{
    kadr=video_pr_th_size*100/80;
    $('#video_state').val("Obrabotka kadrov:"+kadr+"%");
    if (kadr>90)
    {
        $('#video_state').val("Done");
        return;
    }
    else
    {
        setTimeout('get_video_state_thums()',500);
    }
}

function get_video_state(key)
{
    $.post(
				base_url + '/json/get_video_state',
				{
					url: $('#video_url').val()
				},
				function(data)
				{
				    if (data.status==false)
                    {
                        
                        if (data.count == 0)
                        {
                            $('#video_state').val("Obrabotka video");
                        }
                        else
                        {
                            $('#video_state').val("Zagruzka kadrov:"+data.count+"%");    
                        }
                        
                        setTimeout('get_video_state("'+key+'")',500);
                    }
                    else
                    {
                        get_video_state_thums();
                        //property_photo(true);
                        //window.location = base_url + '/FreePhotoFromVideo/' + $('#url').val();
                    }
                    
				    
				    //alert(data.status+":"+data.message);
					//popup(1, data.message, 369, 200);
				},
				"json"
			);
}


//new 3dbin functions 
function video_upload(value_name, width, height, img, key)
{ 

 //alert($('#' + value_name));
  
	$('#' + value_name).swfupload({
		upload_url: base_url + '/upload/' + 'kjbcuhbaaby' + '/' + key + '/61' ,
		file_size_limit : "300 MB",
		file_types : "*.wmv;*.avi;*.flv;*.mpg;*.mp4",
		file_types_description : "Video",
		file_upload_limit : "0",
		flash_url : base_url + '/designes/3dbin/swf/swfupload.swf',
		button_image_url : img,
		button_width : width,
		button_height : height,
		button_placeholder : $('#' + value_name)[0],
		debug: false,
		button_window_mode: 'transparent',
		button_cursor: SWFUpload.CURSOR.HAND
	})
	.bind('fileQueued', function(event, file){
		//$('#property_upload_progress').modal();
			$('#property_upload_progress').modal({
	     opacity:80,
	     overlayCss: {backgroundColor:"#000"}
	});
		$(this).swfupload('startUpload');
		/*$('#property_upload_progress_can').bind('click', function(){//alert(value_name);
			var swfu = $.swfupload.getInstance('#' + value_name);
			swfu.stopUpload();
			swfu.cancelUpload();
		});*/
	})
	.bind('fileQueueError', function(event, file, errorCode, message){
	/*	$.post(
				base_url + '/json/property_swfupload_warning',
				{
					message: message
				},
				function(data)
				{
					popup(1, data.message, 369, 200);
				},
				"json"
			);*/;
	})
	.bind('uploadStart', function(event, file){
	})
	.bind('uploadProgress', function(event, file, bytesLoaded, bytesAll){
		value = parseInt(bytesLoaded*100/bytesAll, 10);
		$('#property_upload_progress_n').css('width', value + '%');
		$('#property_upload_progress_p').html(value + '% / '+bytesLoaded+" / "+bytesAll);
	})
	.bind('uploadSuccess', function(event, file, serverData){
		$.modal.close();
		//alert('Video uploaded');
		$.post(
				base_url + '/json/property_pars_video',
				{
					url: $('#video_url').val()
				},
				function(data)
				{
				    get_video_state(key);
				    //alert(data.status+":"+data.message);
					//popup(1, data.message, 369, 200);
				},
				"json"
			);
		//automatically_processed_(key);
		
	});
}




function get_image_size(url)
{
    $.post(
		base_url + '/json/get_image_size',
		{
			url: url
		},
		function(data)
		{
			if (!data.status)
			{
			     setTimeout('get_image_size("'+url+'")',500);
			     $("#sizer").css("display","none");
			}
			else
			{
			     $("#sizer").css("display","block");
                 $("#pr_size1").append('<option value="w800;'+data.h800+'">800x'+data.h800+'*</option>');
                 $("#pr_size1").append('<option value="w660;'+data.h660+'">660x'+data.h660+'*</option>');
                 $("#pr_size1").append('<option value="w530;'+data.h530+'">530x'+data.h530+'*</option>');
                 $('#pr_size1').selectbox({
			         onChangeCallback: property_size_change,
			         inputClass: 'pr_selectbox',
			         containerClass: 'pr_selectbox_wrapper pr_selectbox_wrapper_main',
			         hoverClass: 'pr_selectbox_current',
			         currentClass: 'pr_selectbox_selected'
		          });
                 $("#pr_size1_input_600").after('<li id="inf_chb" style="background-image: none;font-size:10px;color:#000000" class="">*Original image proportion</li>');
			}
		},
		"json");
}


function smooth_select(type)
{
    $('#pr_smooth').val(type);
    if (type==0)
    {
        $('#notsmooth').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/smooth_2_btn.png");
        $('#smooth').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/smooth_1_btn.png");
    }
    else
    {
        $('#notsmooth').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/smooth_1_btn.png");
        $('#smooth').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/smooth_2_btn.png");
    }
}



function f360_view_select(type)
{
    $('#pr_rotate').val(type);
    if (type==2)
    {
        $('#less_360').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/less360_2_btn.png");
        $('#full_360').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/360_1_btn.png");
    }
    else
    {
        $('#less_360').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/less360_1_btn.png");
        $('#full_360').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/360_2_btn.png");
    }
}


function select_text_instr(type)
{
    $('#tab_text1').css("background-color","#939EAE");
    $('#tab_text2').css("background-color","#939EAE");
    $('#tab_text3').css("background-color","#939EAE");
    $('#instr_1').css('display','none');
    $('#instr_2').css('display','none');
    $('#instr_3').css('display','none');
    if (type==1){$('#tab_text1').css("background-color","#578ad9");$('#instr_1').css('display','block');$('#main_instr').css("height","3360px");};
    if (type==2){$('#tab_text2').css("background-color","#578ad9");$('#instr_2').css('display','block');$('#main_instr').css("height","3300px");};
    if (type==3){$('#tab_text3').css("background-color","#578ad9");$('#instr_3').css('display','block');$('#main_instr').css("height","3860px");};
}


function check_discount_code()
{
		$.post(
			base_url + '/json/check_discount_code',
			{
				code: $('#pr_code').val()
			},
			function(data)
			{
				if (data.state=="true")
				{
					 property_change_price(1);
				}
				else
				{
					 property_change_price(0);
				}
				setTimeout('check_discount_code()',500);
			},
			"json"
		);
}


function property_change_price(type)
{
	if (type==0)
	{
		$('#price_now').empty();
		$('#price_now').append("4.99$");
		$('#amount').val("4.99");
		$('#ver_code').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/pass_no.gif");
		discard = 0;
	}
	else
	{
		$('#price_now').empty();
		$('#price_now').append("3.60$");
		$('#amount').val("3.60");
		$('#ver_code').attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/pass_yes.gif");
		discard = 1;
	}
} 

function property_payment_choose(type)
{
	if (type==0)
	{
		payment_type=0;
		$("#type_visa_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/visa_2_btn.png");
		$("#type_pay_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/paypal_1_btn.png");
		$("#type_sms_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/sms_1_btn.png");
		$("#dstep3").css("display","block");
	}
	if (type==1)
	{
		payment_type=0;
		$("#type_visa_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/visa_1_btn.png");
		$("#type_pay_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/paypal_2_btn.png");
		$("#type_sms_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/sms_1_btn.png");
		$("#dstep3").css("display","block");
	}
	if (type==2)
	{
		payment_type=0;
		$("#type_visa_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/visa_1_btn.png");
		$("#type_pay_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/paypal_1_btn.png");
		$("#type_sms_img").attr("src",base_url+"/designes/3dbin"+cur_dis+"/img/sms_2_btn.png");
		$("#dstep3").css("display","block");
	}
}

function property_logo_check_free()
{
	$.post(
			base_url + '/json/property_logo_check',
			{
			},
			function(data)
			{
				property_logo_init_free(true);
				if (!data.status)
				{
					popup(1, data.message, 369);
				}
			},
			"json"
		);
}
function property_upload_logo_free(file_type_id)
{
    	$('#pr_ulogo').swfupload({
		upload_url: base_url + '/upload/' + 'kjbcuhbaaby' + '/' + task_id + '/' + file_type_id,
		file_size_limit : "10 MB",
		file_types : "*.jpg;*.jpeg;*.png;*.gif;*.bmp",
		file_types_description : "Images",
		file_upload_limit : "0",
		flash_url : base_url + '/' + design_current + '/swf/swfupload.swf',
		button_image_url : base_url + '/' + design_current + cur_dis+'/img/v3_property_logo.png',
		button_width : 112,
		button_height : 28,
		button_placeholder : $('#pr_ulogo_button')[0],
		debug: false,
		button_window_mode: 'opaque',
		button_cursor: SWFUpload.CURSOR.HAND
	})
	.bind('fileQueued', function(event, file){
		$('#property_upload_progress').modal();
		$(this).swfupload('startUpload');
		$('#property_upload_progress_can').bind('click', function(){
			var swfu = $.swfupload.getInstance('#pr_ulogo');
			swfu.cancelUpload(file.id);
			property_close();
		});
	})
	.bind('fileQueueError', function(event, file, errorCode, message){
		$.post(
				base_url + '/json/property_swfupload_warning',
				{
					message: message
				},
				function(data)
				{
					popup(1, data.message, 369, 200);
				},
				"json"
			);
	})
	.bind('uploadStart', function(event, file){
	})
	.bind('uploadProgress', function(event, file, bytesLoaded, bytesAll){
		value = parseInt(bytesLoaded*100/bytesAll, 10);
		$('#property_upload_progress_n').css('width', value + '%');
		$('#property_upload_progress_p').html(value + '%');
	})
	.bind('uploadSuccess', function(event, file, serverData){
		property_close();
		property_logo_check_free();
	});
}


function property_logo_init_free(is_new)
{
	$.post(
			base_url + '/json/property_logo_init_free',
			{
				url: url
			},
			function(data)
			{
				con = $('#pr_logo_select_container ul');
				con.html('');
				var sizeof = data.length;
				var id;
				for (id in data)
				{
					con.append('<li><div class="pr_logo_node center border" style="float: none; background-image: url(' + data[id].url + ');"><div class="pr_delete opacity display_none" style="float: right;">x</div></div></li>');
					if (!is_new && data[id].is_select)
					{
						$('#pr_logo').css('background-image', 'url(' + data[id].url +')');
						property_logo_choise = id;
						con.children('li:last').children('div').addClass('shared');
					}
					else if (is_new && (id == (sizeof -1) ))
					{
						$('#pr_logo').css('background-image', 'url(' + data[id].url +')');
						property_logo_choise = id;
						con.children('li:last').children('div').addClass('shared');
					}
				}
				$('#pr_logo_select_container div.pr_logo_node').mouseover(function () { property_logo_hover(this, 1); }).mouseout(function () { property_logo_hover(this); }).click(function(){ property_logo_change(this); });
				$('#pr_logo_select_container div.pr_delete').click(function(){ property_delete_show(this, 5); }).mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
				property_logo_data = data;
			},
			"json"
	);
	}


function learn_text_hide(status)
{
	if (status)
	{
		$('#property_text').css({display: "none"});
		$('#property_text_maximize').css({display: "block"});
	}
	else
	{
		$('#property_text').css({display: "block"});
		$('#property_text_maximize').css({display: "none"});
	}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function property_show_preview_video(index)
{
    $('#video_preview_img').attr("src",video_pr_th[index].src);
     for (i=0;i<video_pr_th_size;i++)
     {
        if (video_select[i]==1)
        {
            $('#pr_node_l'+i).css("border","2px solid rgb(0, 200, 0)");
            $('#pr_node_text_id'+i).css("color","#000000");
            
            
        }
        if (video_select[i]==0)
        {
            $('#pr_node_l'+i).css("border","2px solid rgb(200, 200, 200)");
            $('#pr_node_text_id'+i).css("color","#B3B3B3");
        }
     }
     $('#pr_node_l'+index).css("border","2px solid rgb(200, 200, 0)");
     $('#pr_node_text_id'+index).css("color","#ff0000");
}


var show_select;



function hide_non_selected()
{
    if (show_select==0)
    {
        $('#pr_hide_select').empty();
        $('#pr_hide_select').append("Show non selected");
        for (i=0;i<video_pr_th_size;i++)
        {
            if (video_select[i]==0)
            {
                $('#pr_node_l'+i).parent().css("display","none");
            }
            else
            {
                $('#pr_node_l'+i).parent().css("display","block");
            }
        }
        show_select=1;   
    }
    else
    {
        $('#pr_hide_select').empty();
        $('#pr_hide_select').append("Hide non selected");
        for (i=0;i<video_pr_th_size;i++)
        {
            $('#pr_node_l'+i).parent().css("display","block");
        }
        show_select=0;
    }
}



$(document).ready(function(){
    if ($('#video_url'))
    {
        show_select=0;
        //video_pr_th[0]= new Image();
        video_pr_th_size=0;
		//file_id = property_photo_data[index].file_id;
        video_upload('video_upload', 302, 136, base_url+'/designes/3dbin'+cur_dis+'/img/upload_video_button.png', $('#video_url').val());
        $('#video_preview').mousemove(function(e){
            sum=0;
            for (i=0;i<video_pr_th_size;i++)
            {
                if (video_select[i]==1)
                    sum++;
            }
            
            var offset = $('#video_preview').offset();
            var x=(-offset.left+ e.pageX);
            var y=-offset.top +e.pageY;
            x=Math.round((sum*x*100/240)/100);
            sum1=0;
            index=0;
            for (i=0;i<video_pr_th_size;i++)
            {
                 if (video_select[i]==1)
                    sum1++;
                if (sum1==x)
                {
                    index=i+1;
                }
            }
            
            property_show_preview_video(index);
            $('#video_preview_img').attr("src",video_pr_th[index].src);
        });
    }
    if ($('#url_size').size())
    {
        //alert('asd');
        get_image_size($('#url_size').val());
    }
    if ($('#rotator').size())
    {
        //alert('asd');
        //swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rotator', "150", "150", "9.0.0", false, false, {wmode:"window"});
    }
	if ($('#task_url_q').size())
	{
		swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'proc_k', "300", "300", "9.0.0", false, false, {wmode:"transparent"});
		processing_check($('#task_url_q').val());
	}
	if ($('#type_pay_img').size())
	{
		property_payment_choose(1);
	}
	if ($('#3dbin_button').size())
	{
	   
			
		$('#3dbin_button_').mouseover(function () {
			
	       	
			$('#iproc_img_preview').attr('src',$('#3dbin_button_').attr('src_link')); 
			$('#proc_img_preview').css('display','block'); 
			}
		).mouseout(function () { 
			$('#proc_img_preview').css('display','none'); 
			}
		);
		$("#3dbin_button_").mousemove(function(e){
			  $('#proc_img_preview').css('top',  e.pageY -350);
		      $('#proc_img_preview').css('left', e.pageX -$('#proc_img_preview').width()-10);
		    });
            if ($('#autoprocess').size())
                property_logo_init_free();
	}
    if ($('#instr_1').size())
    {
        
        f360_view_select($('#pr_rotate').val());
        smooth_select($('#pr_smooth').val());
        select_text_instr(1);
    }
    if ($('#property_body').size())
    {
        f360_view_select($('#pr_rotate').val());
        smooth_select($('#pr_smooth').val());
        select_text_instr(1);
    }
}
)
function processing_check(url)
{
	$.post(
			base_url + '/json/free_task_state',
			{
				url: url
			},
			function(data)
			{
				if (data.state>=100)
				{
					location.reload(); 
				}
				else
				{
					$('#proc_text').empty();
					$('#proc_text').append(data.state+'%');
					setTimeout("processing_check('"+url+"');",1000);
				}
			},
			"json"
		);
}

function freephoto_download()
{
	if ($('#paidin').val()=="true")
	{
		window.location = base_url + '/Download/zip/' + url;
	}
	else
	{
		window.location = base_url + '/Download/zip/' + url;
		//alert('Please buy this model for downloading');
	}
}

function freephoto_showbuy()
{
	if ($('#buy_download_panel').css('display')=='none')
	{
		$('#buy_download_panel').css('display','block');
	}
	else
		$('#buy_download_panel').css('display','none');
	$('#property_logo_s_img').click(function(){ property_3dlogo_change('property_logo_s'); });
	$('#property_logo_f_img').click(function(){ property_3dlogo_change('property_logo_f'); });

	$('#pr_logo_select_input').click(function(){ property_logo_show(true); }).blur(function(){ property_logo_show(); });
	$('#pr_logo_select_container').mouseover(function(event) { property_logo_hasfocus = true; }).mouseout(function(event) { property_logo_hasfocus = false; });

	property_upload_logo_free(5);
	check_discount_code();
}

function create_free_photo()
{
	$.post(
			base_url + '/json/free_task_create',
			{
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/FreePhoto/' + data;
			},
			"json"
		);
}

function create_free_photo_from_video()
{
    $.post(
			base_url + '/json/free_task_create',
			{
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/FreePhotoFromVideo/' + data;
			},
			"json"
		);
}


function property_make_ver_free_video(url,type)
{
	var t=0;
	if (type==5) t=0;
	if (type==2) t=1;
	if (type==1) t=4;
	if (type==3) t=2;
	if (type==4) t=3;
	$.post(
			base_url + '/json/property_make_ver_video',
			{
				url: url,
				type: t
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/Autoprocess/'+url;
			},
			"json"
		);
}


function property_make_ver_free(url,type)
{
	var t=0;
	if (type==5) t=0;
	if (type==2) t=1;
	if (type==1) t=4;
	if (type==3) t=2;
	if (type==4) t=3;
	$.post(
			base_url + '/json/property_make_ver',
			{
				url: url,
				type: t
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/Autoprocess/'+url;
			},
			"json"
		);
}

function property_make_ver(url,type)
{
	var t=0;
	if (type==5) t=0;
	if (type==2) t=1;
	if (type==1) t=4;
	if (type==3) t=2;
	if (type==4) t=3;
	$.post(
			base_url + '/json/property_make_ver',
			{
				url: url,
				type: t
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/My3DPhotoGallery';
			},
			"json"
		);
}


function property_get_ver(url)
{
	
	$.post(
			base_url + '/json/property_get_pre_image',
			{
				url: url
			},
			function(data)
			{
				var total = parseInt($('#proc_count').val());
				if (data.status==true)
				{
					var im;
					im = document.getElementById('im2');
					//alert(im);
					if (im==null)
					if (data.img1!="none")
					{
						total++;
						$('#img_ver2').empty();
						$('#img_ver2').append('<img id="im2" onclick="property_make_ver(\''+url+'\',2)" src="'+data.img1+'" style="width:110px;height:80px;"/>');
						$('#img_ver2').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im2').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver2").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
					im = document.getElementById('im3');
					//alert(im);
					if (im==null)
					if (data.img2!="none")
					{
						total++;
						$('#img_ver3').empty();
						$('#img_ver3').append('<img id="im3" onclick="property_make_ver(\''+url+'\',3)" src="'+data.img2+'" style="width:110px;height:80px;"/>');
						$('#img_ver3').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im3').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver3").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
					im = document.getElementById('im4');
					//alert(im);
					if (im==null)
					if (data.img3!="none")
					{
						total++;
						$('#img_ver4').empty();
						$('#img_ver4').append('<img id="im4" onclick="property_make_ver(\''+url+'\',4)" src="'+data.img3+'" style="width:110px;height:80px;"/>');
						$('#img_ver4').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im4').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver4").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX -500);
						    });
					}
					im = document.getElementById('im5');
					//alert(im);
					if (im==null)
					if (data.img4!="none")
					{
						total++;
						$('#img_ver5').empty();
						$('#img_ver5').append('<img id="im5" onclick="property_make_ver(\''+url+'\',1)" src="'+data.img4+'" style="width:110px;height:80px;"/>');
						$('#img_ver5').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im5').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver5").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
				}
				$('#proc_count').val(total);
				if ($('#proc_count').val()!='5')
					setTimeout("property_get_ver('"+url+"');",1000);
			},
			"json"
		);
}

function property_get_ver_free(url)
{
	
	$.post(
			base_url + '/json/property_get_pre_image',
			{
				url: url
			},
			function(data)
			{
				var total = parseInt($('#proc_count').val());
				if (data.status==true)
				{
					var im;
					im = document.getElementById('im2');
					//alert(im);
					if (im==null)
					if (data.img1!="none")
					{
						total++;
						$('#img_ver2').empty();
						$('#img_ver2').append('<img id="im2" onclick="property_make_ver_free(\''+url+'\',2)" src="'+data.img1+'" style="width:110px;height:80px;"/>');
						$('#img_ver2').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im2').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver2").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
					im = document.getElementById('im3');
					//alert(im);
					if (im==null)
					if (data.img2!="none")
					{
						total++;
						$('#img_ver3').empty();
						$('#img_ver3').append('<img id="im3" onclick="property_make_ver_free(\''+url+'\',3)" src="'+data.img2+'" style="width:110px;height:80px;"/>');
						$('#img_ver3').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im3').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver3").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
					im = document.getElementById('im4');
					//alert(im);
					if (im==null)
					if (data.img3!="none")
					{
						total++;
						$('#img_ver4').empty();
						$('#img_ver4').append('<img id="im4" onclick="property_make_ver_free(\''+url+'\',4)" src="'+data.img3+'" style="width:110px;height:80px;"/>');
						$('#img_ver4').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im4').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver4").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX -500);
						    });
					}
					im = document.getElementById('im5');
					//alert(im);
					if (im==null)
					if (data.img4!="none")
					{
						total++;
						$('#img_ver5').empty();
						$('#img_ver5').append('<img id="im5" onclick="property_make_ver_free(\''+url+'\',1)" src="'+data.img4+'" style="width:110px;height:80px;"/>');
						$('#img_ver5').mouseover(function () {
							$('#iproc_img_preview').attr('src',$('#im5').attr('src')); 
							$('#proc_img_preview').css('display','block'); 
							}
						).mouseout(function () { 
							$('#proc_img_preview').css('display','none'); 
							}
						);
						$("#img_ver5").mousemove(function(e){
							  $('#proc_img_preview').css('top',  e.pageY +10);
						      $('#proc_img_preview').css('left', e.pageX +10);
						    });
					}
				}
				$('#proc_count').val(total);
				if ($('#proc_count').val()!='5')
					setTimeout("property_get_ver_free('"+url+"');",1000);
			},
			"json"
		);
}



function property_make_free(url)
{
	$.modal.close();
	$('#proc_count').val('0');
	$('#img_ver1').empty();
	$('#img_ver2').empty();
	$('#img_ver3').empty();
	$('#img_ver4').empty();
	$('#img_ver5').empty();
	$('#img_ver1').append('<div id="rot1"></div>');
	$('#img_ver2').append('<div id="rot2"></div>');
	$('#img_ver3').append('<div id="rot3"></div>');
	$('#img_ver4').append('<div id="rot4"></div>');
	$('#img_ver5').append('<div id="rot5"></div>');
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot1', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot2', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot3', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot4', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot5', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	$('#proc_popup').modal({overlayClose:false});
	$.post(
			base_url + '/json/property_task_multy_preview',
			{
				url: url,
				type: 1
			},
			function(data)
			{
				$('#img_ver1').empty();
				$('#img_ver1').append('<img id="im1" onclick="property_make_ver_free(\''+url+'\',5)" src="'+data.message+'"  style="width:110px;height:80px;"/>');
				$('#img_ver1').mouseover(function () {
					$('#iproc_img_preview').attr('src',$('#im1').attr('src')); 
					$('#proc_img_preview').css('display','block'); 
					}
				).mouseout(function () { 
					$('#proc_img_preview').css('display','none'); 
					}
				);
				$("#img_ver1").mousemove(function(e){
					  $('#proc_img_preview').css('top',  e.pageY +10);
				      $('#proc_img_preview').css('left', e.pageX -500);
				    });
				$('#proc_count').val('1');
				property_get_ver_free(url);
			},
			"json"
		);
}



function property_make(url)
{
	$.modal.close();
	$('#proc_count').val('0');
	$('#img_ver1').empty();
	$('#img_ver2').empty();
	$('#img_ver3').empty();
	$('#img_ver4').empty();
	$('#img_ver5').empty();
	$('#img_ver1').append('<div id="rot1"></div>');
	$('#img_ver2').append('<div id="rot2"></div>');
	$('#img_ver3').append('<div id="rot3"></div>');
	$('#img_ver4').append('<div id="rot4"></div>');
	$('#img_ver5').append('<div id="rot5"></div>');
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot1', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot2', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot3', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot4', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	swfobject.embedSWF( base_url + '/' + design_current + '/swf/task_progress.swf', 'rot5', "110", "80", "9.0.0", false, false, {wmode:"transparent"});
	$('#proc_popup').modal({overlayClose:false});
	$.post(
			base_url + '/json/property_task_multy_preview',
			{
				url: url,
				type: 1
			},
			function(data)
			{
				$('#img_ver1').empty();
				$('#img_ver1').append('<img id="im1" onclick="property_make_ver(\''+url+'\',5)" src="'+data.message+'" style="width:110px;height:80px;"/>');
				$('#img_ver1').mouseover(function () {
					$('#iproc_img_preview').attr('src',$('#im1').attr('src')); 
					$('#proc_img_preview').css('display','block'); 
					}
				).mouseout(function () { 
					$('#proc_img_preview').css('display','none'); 
					}
				);
				$("#img_ver1").mousemove(function(e){
					  $('#proc_img_preview').css('top',  e.pageY +10);
				      $('#proc_img_preview').css('left', e.pageX -500);
				    });
				$('#proc_count').val('1');
				property_get_ver(url);
			},
			"json"
		);
}

function property_make_check_free()
{
	logourl = $('#pr_url').val();
	if ($('#pr_url').attr('title') == $('#pr_url').val())
	{
		logourl = '';
	}
	$.post(
		base_url + '/json/property_make_check_free',
		{
			url: url,
			name: $('#property_name').val(),
			size: $('#pr_size1 option:selected').val(),
			rotate: $('#pr_rotate').val(),
            is_smooth: $('#pr_smooth').val(),
			clean: true,
			align: $('#property_aalign').is(':checked'),//true,
			crop: true,
			logo3d: false,
			logourl:base_url, //logourl,
			text: '',
			demo_mode: false,
			logo_ch: 1,//property_logo_choise,
			logo_id: false//property_logo_data[property_logo_choise].logo_id
		},
		function(data)
		{
			//alert(data.message);
			//return ;
			if (!data.status)
			{
				//alert(data.message);
				//property_make_free(url);
				popup(1, data.message, 369, 200);
			}
			else
			{
				property_make_free(url);
			}
		},
		"json"
	);
}

function property_make_check_buy()
{
	logourl = $('#pr_url').val();
	if ($('#pr_url').attr('title') == $('#pr_url').val())
	{
		logourl = '';
		
	}
	var p;
	if (!property_logo_choise)
	{
		p="-1";
	}
	else
		p=property_logo_data[property_logo_choise].logo_id;
	$.post(
		base_url + '/json/property_make_check_buy',
		{
			url: url,
			logo3d: $('#property_logo_f').is(':checked'),
			logourl: logourl,
			logo_ch: property_logo_choise,
			logo_id: p,
			email: $('#pr_email').val(),
			code: $('#pr_code').val()
			
		},
		function(data)
		{
			//return false;
			if (!data.status)
			{
				document.getElementById('buy_now').submit(); return false;
				//popup(1, data.message, 369, 200);
			}
			else
			{
				document.getElementById('buy_now').submit(); return false;
			}
		},
		"json");
}

//!new 3dbin functions
function property_make_check()
{
	logourl = $('#pr_url').val();
	if ($('#pr_url').attr('title') == $('#pr_url').val())
	{
		logourl = '';
	}
	$.post(
		base_url + '/json/property_make_check',
		{
			url: url,
			name: $('#property_name').val(),
			size: $('#pr_size1 option:selected').val(),
			rotate: $('#pr_rotate option:selected').val(),
            is_smooth: $('#pr_smooth').val(),
			clean: $('#property_aclean').is(':checked'),
			align: $('#property_aalign').is(':checked'),
			crop: $('#property_zoom_n').is(':checked'),
			logo3d: $('#property_logo_f').is(':checked'),
			logourl: logourl,
			text: $('#pr_text').val(),
			demo_mode: $('#property_demo_mode').is(':checked'),
			logo_ch: property_logo_choise,
			logo_id: property_logo_data[property_logo_choise].logo_id
		},
		function(data)
		{
			if (!data.status)
			{
				property_make(url);
				//popup(1, data.message, 369, 200);
			}
			else
			{
				property_make(url);
			}
		},
		"json"
	);
}
function property_3dlogo_change(value)
{
	if (value == 'property_logo_s')
	{
		$('#property_logo_s_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_active.png');
		$('#property_logo_f_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');
		$('#property_logo_s').attr('checked', 'checked');
	}
	else
	{
		$('#property_logo_s_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');
		$('#property_logo_f_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_active.png');
		$('#property_logo_f').attr('checked', 'checked');
	}
}
function property_tinymce()
{
	$('#pr_text').tinymce({
		script_url : base_url + '/' + design_current + '/tiny_mce/tiny_mce.js',
		theme : "advanced",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyful,|,link,unlink",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		forced_root_block : false,
		force_p_newlines : false,
		remove_linebreaks : false,
		force_br_newlines : true,
		remove_trailing_nbsp : false,
		verify_html : false,
		plugins : "inlinepopups, safari",
		dialog_type : "modal"
	});
}
function property_demo_mode()
{
	check = $('#property_demo_mode').is(':checked');
	if (check)
	{
		$('#pr_demo_text_off').removeClass('display_none');
		$('#pr_demo_text_on').addClass('display_none');
		$('#pr_menu_more').addClass('display_none');
		$('#pr_n2').addClass('display_none');
		$('#pr_demo_button').removeClass('pr_demo_button_d').html('Activate Demo Mode');
		$('#property_demo_mode').attr('checked', '');
		$('#pr_size1').val('300');
		$('#pr_size1_input').val('300x300');
	}
	else
	{
		$('#pr_demo_text_off').addClass('display_none');
		$('#pr_demo_text_on').removeClass('display_none');
		$('#pr_menu_more').removeClass('display_none');
		//$('#pr_n2').removeClass('display_none');
		$('#pr_demo_button').addClass('pr_demo_button_d').html('Deactivate Demo Mode');
		$('#property_demo_mode').attr('checked', 'checked');
		property_tinymce();
	}
	property_height();
}
function property_size_change()
{
	if ($('#pr_size1 option:selected').val() == 300)
	{
		$('#pr_size_warning').removeClass('display_none');
	}
	else
	{
		$('#pr_size_warning').addClass('display_none');
	}
	if (paid == 'true')
	{
		return false;
	}
	check = $('#property_demo_mode').is(':checked');
	if (!check && ($('#pr_size1 option:selected').val() > 300))
	{
		$('#pr_n3').css({'border': '2px solid red'});
		$('#pr_n3').animate({'borderBottomColor': 'white', 'borderLeftColor': 'white', 'borderRightColor': 'white', 'borderTopColor': 'white'}, 3000);
		property_demo_mode();
	}
}
function property_click(value, type)
{
    if ($('#video_url').size())
    {
        index = $('#pr_photo div.pr_node_c').index($(value).parent().parent());
  		file_id = property_photo_data[index].file_id;
    	property_img = index;
        if (video_select[index]==0)
        {
            video_select[index]=1;
        }
        else
            video_select[index]=0;
        property_show_preview_video(index);
        //property_video_select
        $.post(
    			base_url + '/json/property_video_select',
    			{
    				'file_id': file_id,
    				'select': video_select[index]
    			},
    			function(data)
    			{
    				return;
    			},
    			"json"
    		);
        //alert(index+"___"+file_id);
    }
    else
    {
	   if (type == 2)
	   {
    		index = $('#pr_photo_more div.pr_node_c').index($(value).parent().parent());
    		file_id = property_photo_more_data[index].file_id;
    		property_img_more = index;
    	}
    	else
    	{
    		index = $('#pr_photo div.pr_node_c').index($(value).parent().parent());
    		file_id = property_photo_data[index].file_id;
    		property_img = index;
    	}
    	$.post(
    			base_url + '/json/property_click',
    			{
    				'file_id': file_id,
    				'type': type
    			},
    			function(data)
    			{
    				popup(1, data.message, 488);
    			},
    			"json"
    		);
    }
}
function property_img_popup(status, type)
{
	if (type == 2)
	{
		sizeof = property_photo_more_data.length;
		if (status)
		{
			property_img_more++;
			if (sizeof <= property_img_more)
			{
				property_img_more = 0;
			}
		}
		else
		{
			property_img_more--;
			if (property_img_more < 0)
			{
				property_img_more = sizeof-1;
			}
		}
		file_id = property_photo_more_data[property_img_more].file_id;
		name = property_photo_more_data[property_img_more].name;
	}
	else
	{
		sizeof = property_photo_data.length;
		if (status)
		{
			property_img++;
			if (sizeof <= property_img)
			{
				property_img = 0;
			}
		}
		else
		{
			property_img--;
			if (property_img < 0)
			{
				property_img = sizeof-1;
			}
		}
		file_id = property_photo_data[property_img].file_id;
		name = property_photo_data[property_img].name;
	}
	$.post(
			base_url + '/json/property_click',
			{
				'file_id': file_id,
				'url_only': true
			},
			function(data)
			{
				$('#pr_img_popup').attr('src', data);
				$('#pr_img_name').html(name);
			},
			"json"
		);
}
function property_select_photo(value)
{
	index = $('#pr_photo div.pr_node_c').index($(value).parent().parent());
	file_id = property_photo_data[index].file_id;
	if (empty(property_photo_data_select[file_id]) || (property_photo_data_select[file_id] === false))
	{
		$(value).children('img').attr('src',  base_url + '/' + design_current + cur_dis+'/img/shape_active.gif');
		property_photo_data_select[file_id] = true;
	}
	else
	{
		$(value).children('img').attr('src',  base_url + '/' + design_current + cur_dis+'/img/shape_passive.gif');
		property_photo_data_select[file_id] = false;
	}
	property_select_photo_select_is_all();
}
function property_select_photo_all()
{
	var id;
	var node;
	for (id in property_photo_data)
	{
		place = id;
		file_id = property_photo_data[id].file_id;
		if (property_photo_data_select_all)
		{
			if (!empty(property_photo_data_select[file_id]) && (property_photo_data_select[file_id] === true))
			{
				node = $('#pr_photo > div.pr_node_c:eq(' + place + ')');
				node.children('div').children('div.pr_checkbox').addClass('display_none').children('img').attr('src',  base_url + '/' + design_current + cur_dis+'/img/shape_passive.gif');
				property_photo_data_select[file_id] = false;
				$('#pr_select_all').html('Select All');
			}
		}
		else
		{
			if (empty(property_photo_data_select[file_id]) || (property_photo_data_select[file_id] === false))
			{
				node = $('#pr_photo > div.pr_node_c:eq(' + place + ')');
				node.children('div').children('div.pr_checkbox').removeClass('display_none').children('img').attr('src',  base_url + '/' + design_current + cur_dis+'/img/shape_active.gif');
				property_photo_data_select[file_id] = true;
				$('#pr_select_all').html('Unselect All');
			}
		}
	}
	if (property_photo_data_select_all)
	{
		property_photo_data_select_all = false;
	}
	else
	{
		property_photo_data_select_all = true;
	}
}
function property_select_photo_del_show()
{
	is_one = false;
	var id;
	for (id in property_photo_data)
	{
		file_id = property_photo_data[id].file_id;
		if (!empty(property_photo_data_select[file_id]) && (property_photo_data_select[file_id] === true))
		{
			is_one= true;
		}
	}
	if (is_one)
	{
		popup_show('delete_photos');
	}
	else
	{
		popup_show('delete_none');
	}
}
function property_select_photo_del()
{
	var id;
	for (id in property_photo_data)
	{
		file_id = property_photo_data[id].file_id;
		if (!empty(property_photo_data_select[file_id]) && (property_photo_data_select[file_id] === true))
		{
			property_delete(file_id);
		}
	}
	popup();
	property_photo();
	property_logo_init();
	property_photo_data_select_all = false;
	$('#pr_select_all').html('Select All');
}

function mask_save(task_id)
{
	
	$.post(
			base_url + '/json/mask_make',
			{
				'task_id': task_id
			},
			function(data)
			{
				
				if ($('#url').size())
				{
					window.location = base_url + cur_dis+'/Autoprocess/'+$('#url').val();
				}
				else
					window.location = base_url + cur_dis+'/My3DPhotoGallery';
			},
			"json"
		);
}
function mask_delete(url)
{
	$.post(
			base_url + '/json/property_make',
			{
				'url': url
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/My3DPhotoGallery';
			},
			"json"
		);
}
function mask_cancel()
{
    if ($('#free_mask_is').size())
    {
        window.location = base_url + cur_dis+'/Autoprocess/'+$('#url').val();
    }
    else
    {
        window.location = base_url +cur_dis+ '/My3DPhotoGallery';
    }
	
}

function task_create(value)
{
	$.post(
			base_url + '/json/task_create',
			{
				'task_name': $('#task_name_new').val(),
				'type': value
			},
			function(data)
			{
				window.location = base_url + cur_dis+'/TaskProperty/' + data;
			},
			"json"
		);
}
function task_rm(url)
{
	$.post(
			base_url + '/json/task_rm',
			{
				'url': url
			},
			function(data)
			{
				popup();
				gallery_v3();
			},
			"json"
		);
}

function send_me_mail()
{
	$.post(
			base_url + '/json/send_me_mail',
			{
				'email': $('#fb_email').val(),
				'message': $('#fb_message').val(),
				'url': $('#fb_url').val(),
				'swf': GetSwfVer()
			},
			function(data)
			{
				popup();
			},
			"json"
		);
}


function feedback_send()
{
	$.post(
			base_url + '/json/feedback_send',
			{
				'email': $('#fb_email').val(),
				'message': $('#fb_message').val(),
				'url': $('#fb_url').val(),
				'swf': GetSwfVer()
			},
			function(data)
			{
				popup();
			},
			"json"
		);
}
function contact_send()
{
	$.post(
			base_url + '/json/contact_send',
			{
				'email': $('#c_email').val(),
        		        'phone': $('#c_phone').val(),
				'message': $('#c_message').val(),
				'url': $('#fb_url').val(),
				'swf': GetSwfVer()
			},
			function(data)
			{
				popup();
			},
			"json"
		);
}



function intro_height()
{
	height = $('#intro_ex').height() + 0;
	m2 = $('#intro_n1').height() + 0;
	if (height < m2)
	{
		height = m2;
	}
	$('#v3_intro').css('height', height);
}
function intro_swf_show(id)
{
	if (!id)
	{
		m = 0;
		n = intro_swf.length - 1;
		id = Math.floor( Math.random( ) * (n - m + 1) ) + m;
	}
	swfobject.embedSWF('http://3dbin.com/ps/' + intro_swf[id], "intro_swf_example", "530", "400", "9.0.0", false, false);
	intro_swf_id = id;
}
function intro_swf_more()
{
	id = intro_swf_id + 1;
	if (id > (intro_swf.length - 1))
	{
		id = 0;
	}
	intro_swf_show(id);
	intro_swf_id = id;
}
function intro_banner_switch(value)
{
	if (value)
	{
		$('#v3_intro_btn_1').addClass('btn_a');
		$('#v3_intro_btn_2').removeClass('btn_a');
		$('#v3_intro_step_1').removeClass('display_none');
		$('#v3_intro_stepa_1').addClass('display_none');
		$('#v3_intro_step_2').removeClass('display_none');
		$('#v3_intro_stepa_2').addClass('display_none');
		$('#v3_intro_step_3').removeClass('display_none');
		$('#v3_intro_stepa_3').addClass('display_none');
		swfobject.embedSWF(base_url + '/' + design_current + '/swf/v3_intro_step_2.swf', "v3_intro_step_2_swf", "182", "165", "9.0.0", false, false);
		intro_banner = false;
	}
	else
	{
		$('#v3_intro_btn_1').removeClass('btn_a');
		$('#v3_intro_btn_2').addClass('btn_a');
		$('#v3_intro_step_1').addClass('display_none');
		$('#v3_intro_stepa_1').removeClass('display_none');
		$('#v3_intro_step_2').addClass('display_none');
		$('#v3_intro_stepa_2').removeClass('display_none');
		$('#v3_intro_step_3').addClass('display_none');
		$('#v3_intro_stepa_3').removeClass('display_none');
		swfobject.embedSWF(base_url + '/' + design_current + '/swf/v3_intro_stepa_2.swf', "v3_intro_stepa_2_swf", "182", "165", "9.0.0", false, false);
		intro_banner = true;
	}
}

function hint_show(node, h_diff, v_diff )
{
	id = $(node).attr('id');
	if (!$(id + '_hint').size())
	{
		offset = $(node).offset();
        ///alert(offset.top +" " +offset.left);
		$(node).append('<span id="' + id + '_hint" style="top: ' + (offset.top-15+h_diff) + 'px; left: ' + (offset.left+25+v_diff) +'px; position:absolute; z-index: 12001;"><img alt="" src="' + base_url + '/' + design_current + cur_dis+'/img/' + id + '.gif"></span>');
	}
}
function hint_hide(node)
{
	$(node).children('span').remove();
}

function user_login(value)
{
	remember = 0;
	if (value)
	{
		email = $('#lo_email_s').val();
		passwd = $('#lo_passwd_s').val();
		if ($('#lo_remember_s').is(':checked'))
		{
			remember = 1;
		}
	}
	else
	{
		email = $('#lo_email').val();
		passwd = $('#lo_passwd').val();
		if ($('#lo_remember').is(':checked'))
		{
			remember = 1;
		}
	}
	$.post(
			base_url + '/json/user_login',
			{
				email: email,
				passwd: passwd,
				remember: remember,
				swf: GetSwfVer()
			},
			function(data)
			{
				if (data.status)
				{
					window.location = base_url + cur_dis+'/My3DPhotoGallery';
				}
				else
				{
					popup(1, data.message, 369);
				}
			},
			"json"
		);
}
function user_exit()
{
	$.getJSON(
			base_url + '/json/user_exit',
			{
			},
			function(data)
			{
				window.location = base_url+cur_dis;
			}
	);
}
function user_reset()
{
	$.post(
			base_url + '/json/user_reset',
			{
				email: $('#reset').val()
			},
			function(data)
			{
				popup();
			},
			"json"
		);
}
function user_register(value)
{
	su_term = 0;
	if (value)
	{
		su_email = $('#su_email_s').val();
		su_passwd = $('#su_passwd_s').val();
		su_cpasswd = $('#su_cpasswd_s').val();
		if ($('#su_term_s').is(':checked'))
		{
			su_term = 1;
		}
	}
	else
	{
		su_email = $('#su_email').val();
		su_passwd = $('#su_passwd').val();
		su_cpasswd = $('#su_cpasswd').val();
		if ($('#su_term').is(':checked'))
		{
			su_term = 1;
		}
	}
	$.post(
		base_url + '/json/user_register',
		{
			su_email: su_email,
			su_passwd: su_passwd,
			su_cpasswd: su_cpasswd,
			su_term: su_term,
			swf: GetSwfVer()
		},
		function(data)
		{
			if (data.status === false)
			{
				popup(1, data.message, 369);
			}
			else
			{
				window.location = base_url + cur_dis+'/My3DPhotoGalleryHello';
			}
		},
		"json"
	);
}
function user_password_change()
{
	$.post(
			base_url + '/json/user_password_change',
			{
				'passwd_old': $('#cp_passwd_old').val(),
				'passwd': $('#cp_passwd').val(),
				'passwd_c': $('#cp_passwd_c').val()
			},
			function(data)
			{
				if (data.status === false)
				{
					popup(1, data.message, 369);
				}
				else
				{
					window.location = base_url +cur_dis+ '/My3DPhotoGallery';
				}
			},
			"json"
		);
}

function buy_select(value)
{
	$('#buy_1').attr('checked', '');
	$('#buy_2').attr('checked', '');
	$('#buy_3').attr('checked', '');
	$('#buy_4').attr('checked', '');
	$('#buy_img_1').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');
	$('#buy_img_2').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');
	$('#buy_img_3').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');
	$('#buy_img_4').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');

	$('#buy_' + value).attr('checked', 'checked');
	$('#buy_img_' + value).attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_active.png');

	buy_goods = value;
	name = $('#buy_name_' + value).val();
	price = $('#buy_price_' + value).val();
	if (price == 'Free')
	{
		price = '0.00';
		$('#buy_type_header').addClass('display_none');
		$('#buy_type').addClass('display_none');
		$('#buy_type_code').removeClass('display_none');
	}
	else
	{
		$('#buy_type_header').removeClass('display_none');
		$('#buy_type').removeClass('display_none');
		$('#buy_type_code').addClass('display_none');
	}
	$('#arb_amount').val(price);
	$('#buy_name_paypal').val(name + ' 3DPhoto');
	$('#buy_amount_paypal').val(price);
}
function buy_make()
{
	$.post(
			base_url + '/json/buy_make',
			{
				'goods_id': buy_goods,
				'cart_id': $('#item_number_paypal').val(),
				'buy_is_type': buy_is_type
			},
			function(data)
			{
				if(data.status === false)
				{
					if (data.message == 'redirect')
					{
						window.location = base_url + cur_dis+'/My3DPhotoGallery';
						return false;
					}
					popup(1, data.message, 369);
					$('#button_buy').html('Change Your Subscription');
				}
				else
				{
					if (buy_is_type == 'paypal')
					{
						document.forms.paypal_form_post.submit();
					}
					else if (buy_is_type == 'auth')
					{
						$.post(
							base_url + '/json/arb',
							{
								'firstName': $("#arb_firstName").val(),
								'lastName': $("#arb_lastName").val(),
								'cardNumber': $("#arb_cardNumber").val(),
								'cvv': $("#arb_cvv").val(),
								'expirationDateMonth': $("#arb_expirationDateMonth").val(),
								'expirationDateYear': $("#arb_expirationDateYear").val(),
								'amount': $("#arb_amount").val(),
								'cart_id': $("#item_number").val()
							},
							function(data)
							{
								if(data.status === false)
								{
									popup(1, data.message, 369, 176);
									$('#button_buy').html('Change Your Subscription');
								}
								else
								{
									window.location = base_url +cur_dis+ '/PaypalDone';
								}
							},
							"json"
						);
					}
					return false;
				}
			},
			"json"
		);
}
function buy_type(value)
{
	$('#buy_type_auth_img').attr('src', base_url + '/' + design_current +cur_dis+ '/img/circle_passive.png');
	$('#buy_type_paypal_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_passive.png');

	$('#buy_type_auth_form').removeClass('display_inline').addClass('display_none');
	$('#buy_type_paypal_form').removeClass('display_inline').addClass('display_none');

	$('#buy_type_' + value + '_img').attr('src', base_url + '/' + design_current + cur_dis+'/img/circle_active.png');
	$('#buy_type_' + value).attr('checked', 'checked');
	$('#buy_type_' + value + '_form').removeClass('display_none').addClass('display_inline');
	buy_is_type = value;
}
function buy_code()
{
	$.post(
			base_url + '/json/redeem_code',
			{
				'code': $("#redeem_code").val()
			},
			function(data)
			{
				if(data.status === false)
				{
					if (data.message == 'redirect')
					{
						window.location = base_url + cur_dis+'/My3DPhotoGallery';
						return false;
					}
					popup(1, data.message, 369, 176);
					$('#button_buy').html('Change Your Subscription');
				}
				else
				{
					window.location = base_url + cur_dis+'/PaypalDone';
				}
			},
			"json"
		);
}

var login_out1;
var login_out2;


$(document).ready(function(){
	if (typeof($d) != "function") {
		$d = function(param) {
			var node = jQuery(param)[0];
			var id = jQuery.data(node);
			jQuery.cache[id] || (jQuery.cache[id] = {});
			jQuery.cache[id].node = node;
			return jQuery.cache[id];
		};
	}
	$('#feedback_copyright').click(function(){ popup_show('contact', base_url + request_uri); return false; });
	$('#top_logo').click(function(){ window.location = base_url+cur_dis; });
	$('#top_logout').click(function(){ user_exit(); });
	if ($('#v3_intro').size())
	{
		intro_swf_show();
		intro_height();
		swfobject.embedSWF(base_url + '/' + design_current + '/swf/v3_intro_step_2.swf', "v3_intro_step_2_swf", "182", "165", "9.0.0", false, false);
		$('#intro_swf_more').click(function(){ intro_swf_more(); });
		$('#v3_intro_btn_1').click(function(){ intro_banner_switch(true); });
		$('#v3_intro_btn_2').click(function(){ intro_banner_switch(); });
	}
	if ($('#gallery_v3').size())
	{
		gallery_v3(true);
		gallery_page_set('init');
		$('#gallery_task_new_a').click(function(){ popup_show('task_create'); });
		$('#gallery_task_new_b').click(function(){ popup_show('task_create'); });
		$('#gallery_v3 div.node_click').click(function(){ gallery_click(this); });
	}
	if (!$('#v3_view').size())
	if ($('#property_body').size())
	{
		property_height();
		property_photo(true);
		property_upload_logo(5);
		property_upload_bg(2);
		property_logo_init();
		if (paid != 'false' || demo_mode != 'false')
		{
			property_tinymce();
		}
        if (($('#instr_1').size()))
        {
		/*$('#pr_size').selectbox({
			onChangeCallback: property_size_change,
			inputClass: 'pr_selectbox',
			containerClass: 'pr_selectbox_wrapper pr_selectbox_wrapper_main',
			hoverClass: 'pr_selectbox_current',
			currentClass: 'pr_selectbox_selected'
		});*/
        }
        /*if (!($('#instr_1').size()))
        {
    		$('#pr_rotate').selectbox({
    			inputClass: 'pr_selectbox',
    			containerClass: 'pr_selectbox_wrapper pr_selectbox_wrapper_main',
    			hoverClass: 'pr_selectbox_current',
    			currentClass: 'pr_selectbox_selected'
    		});
        }*/
		$('#pr_logo_select_input').click(function(){ property_logo_show(true); }).blur(function(){ property_logo_show(); });
		$('#pr_logo_select_container').mouseover(function(event) { property_logo_hasfocus = true; }).mouseout(function(event) { property_logo_hasfocus = false; });
		$('#pr_demo_button').click(function(){ property_demo_mode(); });

		$('#property_upload').click(function(){ property_open(1); });
		$('#property_upload_a').click(function(){ property_open(1); });
		$('#property_upload_more').click(function(){ property_open(3); });

		$('#pr_m1').click(function(){ property_make_check(); });
		$('#pr_n1 .pr_delete').click(function(){ property_delete_show(this); });
		$('#pr_menu .pr_delete').click(function(){ property_delete_show(this, 2); });
		$('#pr_n2 .pr_delete').click(function(){ property_delete_show(this, 3); });
		$('#property_body .pr_set_b').click(function(){ property_set_b_show(this); });

		$('#property_body .pr_delete').mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
		$('#property_body .pr_set_b').mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); });
		$('#property_body .pr_checkbox').mouseover(function () { gallery_v3_opacity(this); }).mouseout(function () { gallery_v3_opacity(this); }).click(function(){ property_select_photo(this); });
        
        {
		  $('#pr_n1 .pr_node_c').mouseover(function () { property_hover(this, 1, true); }).mouseout(function () { property_hover(this, 1, false); });
		  $('#pr_n2 .pr_node_c').mouseover(function () { property_hover(this, 3, true); }).mouseout(function () { property_hover(this, 3, false); });
        }
		$('#pr_b1').mouseover(function () { property_hover(this, 2, true); }).mouseout(function () { property_hover(this, 2, false); });
		$('#pr_n1 .pr_node_c .node_click').click(function(){ property_click(this, 1); });
		$('#pr_n2 .pr_node_c .node_click').click(function(){ property_click(this, 2); });

		$('#pr_select_all').click(function(){ property_select_photo_all(); });
		$('#pr_del_select').click(function(){ property_select_photo_del_show(); });

		$('#property_logo_s_img').click(function(){ property_3dlogo_change('property_logo_s'); });
		$('#property_logo_f_img').click(function(){ property_3dlogo_change('property_logo_f'); });
		$('#property_zoom_f_img').click(function(){ property_zoom_change('property_zoom_f'); });
		$('#property_zoom_n_img').click(function(){ property_zoom_change('property_zoom_n'); });
		$('#v3_hint_name').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_bground').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_size').mouseover(function () { hint_show(this, 35, -130); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_rotate').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_clean').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_align').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_zoom').mouseover(function () { hint_show(this, -146, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_logo').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_text').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_additional').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });
	}
	if ($('#v3_view').size())
	{
        $('#v3_hint_logo').mouseover(function () {  hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_sharing').mouseover(function () { hint_show(this, 35, -205); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_url').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
		$('#v3_hint_embed').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
        $('#v3_hint_embed1').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
        $('#v3_hint_embed2').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
	}
	if ($('#buy_body').size())
	{
		$('#button_buy').click(function(){
			$('#button_buy').html('Please Wait');
			buy_make();
			return false;
		});
		$('#buy_type_auth_img').click(function(){ buy_type('auth'); });
		$('#buy_type_paypal_img').click(function(){ buy_type('paypal'); });
		$('#buy_type_auth_logo').click(function(){ buy_type('auth'); });
		$('#buy_type_paypal_logo').click(function(){ buy_type('paypal'); });
		$('#button_code').click(function(){ buy_code(); });
		$('#arb_expirationDateMonth').selectbox({
			inputClass: 'pr_selectbox',
			containerClass: 'pr_selectbox_wrapper buy_selectbox_wrapper_month',
			hoverClass: 'pr_selectbox_current',
			currentClass: 'pr_selectbox_selected'
		});
		$('#arb_expirationDateYear').selectbox({
			inputClass: 'pr_selectbox buy_selectbox',
			containerClass: 'pr_selectbox_wrapper buy_selectbox_wrapper_year',
			hoverClass: 'pr_selectbox_current',
			currentClass: 'pr_selectbox_selected'
		});
		buy_select(buy_goods);
	}
	if ($('#howto').size())
	{
		$('#gallery_task_new_a').click(function(){ popup_show('task_create'); });
		$('#gallery_task_new_b').click(function(){ popup_show('task_create'); });
		$('#tab_text').click(function(){ window.location = base_url +cur_dis+ '/HowTo'; });
		$('#tab_video').click(function(){ window.location = base_url + cur_dis+'/WatchVideo'; });
	}

	$('input[title!=""]').hint();
	$('#r_feedback').click(function(){ popup_show('feedback', base_url + request_uri); });
    $('#r_contact').click(function(){popup_show('contact', base_url + request_uri); });
   
	$('#r_twitter').click(function(){ window.location = 'http://twitter.com/3DBin_com'; });
	$('#r_facebook').click(function(){ window.location = 'http://www.facebook.com/3DBin'; });
    $('#popup_login_con').mouseover(
        function()
        { 
            login_out1=2;
            
            }
            );
	$('#popup_login').mouseover(
        function()
        { 
            login_out1=2;
            $('#popup_login_con').removeClass('display_none'); 
            $('#popup_login').addClass('popup_login_a'); 
            $('#popup_signup_con').addClass('display_none'); 
            $('#popup_signup').removeClass('popup_signup_a'); 
            }
        );
    $('#popup_login').mouseleave(function (){login_out1=1;});
    $('#popup_login_con').mouseleave(function (){login_out1=1;});
    $('#popup_signup_con').mouseover(function(){login_out2=2;});
	$('#popup_signup').mouseover(function(){ login_out2=2;$('#popup_signup_con').removeClass('display_none'); $('#popup_signup').addClass('popup_signup_a'); $('#popup_login_con').addClass('display_none'); $('#popup_login').removeClass('popup_login_a'); });
    $(document).click(
    function () 
        {
            if (login_out1==1)
            {
                $('#popup_login_con').addClass('display_none'); 
                $('#popup_login').removeClass('popup_login_a');
            }
            if (login_out2==1)
            {
                $('#popup_signup_con').addClass('display_none'); 
                $('#popup_signup').removeClass('popup_signup_a');
            }
        }
    )
   $('#popup_signup').mouseleave(function (){login_out2=1;});
   $('#popup_signup_con').mouseleave(function (){login_out2=1;});
	$('#popup_login').click(
        function () 
        { 
            $('#popup_login_con').addClass('display_none'); 
            $('#popup_login').removeClass('popup_login_a'); 
            }
        );
	$('#popup_signup').click(function () { $('#popup_signup_con').addClass('display_none'); $('#popup_signup').removeClass('popup_signup_a'); });
	$.trackPage('UA-8871630-1');
	$('a').mousedown(function(){ return false; });
});
