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
			},
			function(data)
			{
				popup(1, data.body, data.width);
			},
			"json"
		);
}

function user_login(value)
{
	remember = 0;
	if (value)
	{
		email = $('#email').val();
		passwd = $('#password').val();
		if ($('#remember_s').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;
				}
				else
				{
			   user_dialog_visible_4();
				}
			},
			"json"
		);
}

function user_exit()
{
	$.getJSON(
			base_url + '/json/user_exit',
			{
			},
			function(data)
			{
				window.location = base_url;
			}
	);
}
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 + '/after_register';
			}
		},
		"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 + '/My3DPhotoGallery';
				}
			},
			"json"
		);
}
function user_get_api()
{
	$.getJSON(
			base_url + '/json/user_get_api',
			{
			},
			function(data)
			{
				$('#api_key').val(data);
			}
	);
}

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

function feedback_view()
{
  $('#feedback_form').css('display', 'block');
  $('#feedback_form').modal({
	opacity:80,
	overlayCss: {backgroundColor:"#000"}
});
}

$('#feedback_form').click(function()
{ 
//popup_show('feedback', base_url + request_uri); 
});


function feedback_hidden()
{
$.modal.close();
  $('#feedback_form').css('display', 'none');
}

function feedback_send()
{
//alert("qwe");
	$.post(
			base_url + '/json/feedback_send',
			{
				'email': $('#fb_email').val(),
				'message': $('#fb_message').val()
			//	'url': $('#fb_url').val(),
			//	'swf': false
			},
			function(data)
			{
			  $.modal.close();
			  $('#feedback_form').css('display', 'none');
			},
			"json"
		);
}

function input_select(value)
{
	$(value).select();
}


/*function hint_hide(node)
{
	$(node).children('span').remove();
}
*/
function intro_photo_init()
{
	$.post(
			base_url + '/json/intro_photo_init',
			{
			},
			function(data)
			{
				if (data[1])
				{
					$('#image_main_con').css('background-image', 'url(\'' + data[1].thumb + '\')');
				}
				if (data[2])
				{
					$('#image_bg_con').css('background-image', 'url(\'' + data[2].thumb + '\')');
				}
			},
			"json"
		);
}
function upload_swf(value_name, file_type_id, upload_type, width, height, img)
{
	$('#' + value_name).swfupload({
		upload_url: base_url + '/upload/' + session_id + '/' + file_type_id + '/' + upload_type,
		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 + 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();
		$(this).swfupload('startUpload');
		$('#property_upload_progress_can').bind('click', function(){
			var swfu = $.swfupload.getInstance('#' + value_name);
			swfu.cancelUpload(file.id);
		});
	})
	.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){
		$.modal.close();
		intro_photo_init();
	});
}


//function gallery_upload_swf(value_name, file_type_id, upload_type, width, height, img, key)
//{
//alert(key);
/*	$('#' + value_name).swfupload({
		upload_url: base_url + '/Galleryupload/' + session_id + '/' + file_type_id + '/' + upload_type + '/' + key ,
		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 + 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();
		$(this).swfupload('startUpload');
		$('#property_upload_progress_can').bind('click', function(){
			var swfu = $.swfupload.getInstance('#' + value_name);
			swfu.cancelUpload(file.id);
		});
	})
	.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){
		$.modal.close();
		
		intro_photo_init();
	});*/

//	document.getElementById('Uploader_div').style.display="block";
	 //$('#Uploader_di').css('visibility', 'visible');
	
//}

/*function gallery_uploader_new(key)
{
alert(key);
  if(key != false)
  {
  window.location = base_url + '/galleries/gallery_uploader/' + key;
  }
}
*/
var id

function uploader_hide()
{
	//document.getElementById('Uploader_div').style.display="none";
  window.close();
  clearInterval(id);
}

function reset_show_img_()
{
  alert('qwe');
  id = setTimeout('reset_show_img_()', 100);
  return true;
  //window.location.reload();
}


function image_cleanup()
{
	$.post(
			base_url + '/json/image_cleanup',
			{
			},
			function(data)
			{
				if (data.status)
				{
					window.location = base_url + '/public/' + data.url;
				}
				else
				{
					popup(1, data.message, 369, 176);
				}
			},
			"json"
		);
}

/*function public_show(url)
{
	$.post(
			base_url + '/json/public_show',
			{
				'url': url
			},
			function(data)
			{
				if (data.status)
				{
					if (data.thumb)
					{
						$('#image_res_con').css('background-image', 'url(\'' + data.thumb + '\')');
						$('#view_embed_text').val('<img src="' + base_url + '/gs/' + url + '" alt="http://2dbin.com/public/' + url + '" width="' + data.width + '" height="' + data.height + '" />');
						$('#public_picvik').children('a').attr("href", data.picnik);
						popup();
					}
					else
					{
						popup(1, 'Please Wait', 369, 176);
						setTimeout('public_show(url)', 1000);
					}
				}
				else
				{
					window.location = base_url;
				}
			},
			"json"
		);
}*/
function public_download(url)
{
	$.post(
			base_url + '/json/public_download',
			{
				'url': url
			},
			function(data)
			{
				if (data.status)
				{
					window.location = data.url;
				}
			},
			"json"
		);
}

function new_gallery()
{
		$.post(
			base_url + '/json/create_user_gallery',
			{
				'gallery_name':  $('#gallery_name').val(),
		    'gallery_description' : $('#gallery_description').val()
			},
			function(data)
			{
					window.location = base_url + '/galleries';
			},
			"json"
		);
}

function back_to_new_gallery()
{
  window.location = base_url + '/galleries';
}


function back_to_album()
{
  
  //key = $('#gallery_key_').val();
  key_ = document.getElementById('gallery_key_').value;  
  window.location = base_url + '/galleries/img_show/' + key_;
}
/*

  function start_scenario_task_auto()
  {
		$.post(
			base_url + '/json/start_scenario_task_auto',
			{
			  'mark' : -1,
        'task_id': $("#name").val()
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
  }
  
    function start_scenario_task_hand()
  {
  alert()
		$.post(
			base_url + '/json/start_scenario_task_hand',
			{
			  'mark' : -1,
        'task_id': $("#name").val()
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
  }

  
  function test()
  {
 // alert('qwe');
  var action = $('#action').val();
  switch(action)
		{
		  case "get_images":
		  //alert('asd');
		
      $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val(),
				    'count': $('#count').val(),
				    'type': $('#type').val()
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		
    case "moderate_image":
    $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val(),
				    'vote': $('#vote').val(),
				    'task_id': $('#task_id').val()
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		
		case "get_moderated_images":
    $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val()
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		
    case "cancel_image":
      $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val(),
				    'task_id': $('#task_id').val()
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		
		case "get_user_info":
      $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val() 
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		
		case "get_steps":
      $.post(
			 base_url + '/test1/test1',
			 {
				//'user':  $('#email').val(),
			//	'passwd': $('#password').val(),
				    'action': $('#action').val() 
        },
        function(data)
			{
			},
			"test1"
		);
		break;
		}
		//return false; 
  }
  
  */
//----------------------------------------tema-------------------------------------------

/*
function hint_show(node, size1, size2, url1, url2 )
{

 // url = $(node).attr('id').val();
	//alert(url1);
	id = $(node).attr('id');
	if (!$(id + '_hint').size())
	{
		offset = $(node).offset();
	$(node).append('<span id="' + id + '_hint" style="top: ' + (offset.top+size1-15) + 'px; left: ' + (offset.left+size2+25) +'px; position:absolute; z-index: 500;"><img alt="" src="' + url1+ '"><img alt="" src="'+url2+'"> </span>');
  }
}
*/
function hint_show_gallery(node, size1, size2, url1 )
{

 // url = $(node).attr('id').val();
	//alert(url1);
	id = $(node).attr('id');
	if (!$(id + '_hint').size())
	{
		offset = $(node).offset();
		$(node).append('<span id="' + id + '_hint" style="top: ' + (offset.top+size1-15) + 'px; left: ' + (offset.left+size2+25) +'px; position:absolute; z-index: 500;"><img alt="" src="' + url1+ '"></span>');
  }
}


function hint_show(node, size1, size2, url1, url2 )
{

 // url = $(node).attr('id').val();
	//alert(url1);
	id = $(node).attr('id');
	if (!$(id + '_hint').size())
	{
		offset = $(node).offset();
	$(node).append('<div id="image_zoom" style="top: ' +(offset.top + size1) + 'px; left:'+ (offset.left + size2) + 'px; vertical-align: middle;" ><img id="image_prev_" alt="" src="' + url1+ '"><div id="image_zoom_arrow">&nbsp;</div><img id="image_after_" src="' + url2 + '"></div>');
  }
}

function hint_hide(node)
{
	$(node).children('div').remove();
}


function hint_hide_gallery(node)
{
	$(node).children('span').remove();
}


function delete_gallery_question(key)
{
  if(key)
  {
	 $('#delete_dialog').css('visibility', 'visible');
  }
}

function delete_gallery_question_hide()
{
	$('#delete_dialog').css('visibility', 'hidden');
}

function delete_gallery(key)
{
	$.post(
			base_url + '/json/delete_gallery',
			{
				'key': key
			},
			function(data)
			{
		    window.location = base_url + '/Galleries';
			},
			"json"
		);
}

function change_style_menu()
{
//alert('qwe');
  //$("a").add("<span>");
$('a').replaceWith("<span>" + $(a).text() + "</span>");
 // window.location = base_url;
  //$(this).css("delete_album_btn_d");
  //$('#delete_album_btn').addClass("delete_album_btn");
	
}


 //$('#').mouseover(function () { hint_show(this, -16, 0); }).mouseout(function () { hint_hide(this); });


function select_image_byid(id)
{
  if(id != false)
  {
    window.location = base_url + '/Galleries' + '/select_image/' + id;
  } 
}


function old_section()
{
  $('#image_prev').css('visibility', 'visible');
  $('#image_view_arrow').css('visibility', 'hidden');
  $('#image_after').css('visibility', 'hidden');
  $('.bottom_panel_old_btn').addClass('bottom_panel_old_btn_dn');
  $('.bottom_panel_oldnew_btn_dn').removeClass('bottom_panel_oldnew_btn_dn');
  $('.bottom_panel_new_btn_dn').removeClass('bottom_panel_new_btn_dn');
  
}

function new_section()
{
  $('#image_prev').css('visibility', 'hidden');
  $('#image_view_arrow').css('visibility', 'hidden');
  $('#image_after').css('visibility', 'visible');
  $('.bottom_panel_old_btn_dn').removeClass('bottom_panel_old_btn_dn');
  $('.bottom_panel_oldnew_btn_dn').removeClass('bottom_panel_oldnew_btn_dn');
  $('.bottom_panel_new_btn').addClass('bottom_panel_new_btn_dn');
}

function old_new_section()
{
  $('#image_prev').css('visibility', 'visible');
  $('#image_view_arrow').css('visibility', 'visible');
  $('#image_after').css('visibility', 'visible');
  $('.bottom_panel_old_btn_dn').removeClass('bottom_panel_old_btn_dn');
  $('.bottom_panel_oldnew_btn').addClass('bottom_panel_oldnew_btn_dn');
  $('.bottom_panel_new_btn_dn').removeClass('bottom_panel_new_btn_dn');
  
}

 $(document).ready(function(){
  
  Height = document.documentElement.clientHeight;
  Width = document.documentElement.clientWidth;
  $('#feedback_form').css('top', Height/2-40);
  $('#feedback_form').css('left', Width/2-268);
 });

/*$("span").click(function() {
      
     // alert($(this).attr("name"));
     if($(this).attr("type_s") == "task")
     {
      if ($(this).attr("sc")=="1" )
      {
      $.post(
			base_url + '/json/start_scenario_task_hand',
			{
			  'mark' : -1,
      //	'key': '662aee78e5333e5006c7e0f2adbb0046'//$('#').val()	
			 //'key': $('#start_hand_gallery').val()
        'task_id': $(this).attr("id_s")
      //  'key': mode
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
		}
		else
		{
		$.post(
			base_url + '/json/start_scenario_task_auto',
			{
			  'mark' : -1,
      //	'key': '662aee78e5333e5006c7e0f2adbb0046'//$('#').val()	
			 //'key': $('#start_hand_gallery').val()
        'task_id': $(this).attr("id_s")
      //  'key': mode
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
  }
		return false;
    }
    if($(this).attr("type_s") == "gallery")
    {
      if ($(this).attr("sc")=="1" )
      {
      $.post(
			base_url + '/json/start_scenario',
			{
			  'mark' : -1,
      //	'key': '662aee78e5333e5006c7e0f2adbb0046'//$('#').val()	
			 //'key': $('#start_hand_gallery').val()
        'key': $(this).attr("id_s")
      //  'key': mode
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
		}
		else
		{
		$.post(
			base_url + '/json/start_scenario_task_auto',
			{
			  'mark' : -1,
      //	'key': '662aee78e5333e5006c7e0f2adbb0046'//$('#').val()	
			 //'key': $('#start_hand_gallery').val()
        'key': $(this).attr("id_s")
      //  'key': mode
      },
			function(data)
			{
						//window.location = base_url + '/MyGallery';
			},
			"json"
		);
   }
		return false;
  } 
});
  
*/

 //----------------------------------function for verstki stranici--------------------------------------------


    
    
 

 



function utf8_decode ( str_data ) {

    var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;

    str_data += '';

    while ( i < str_data.length ) {
        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {
            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);
            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }

    return tmp_arr.join('');
}

function unserialize (data) {

    var that = this;
    var utf8Overhead = function(chr) {
        var code = chr.charCodeAt(0);
        if (code < 0x0080) {
            return 0;
        }
        if (code < 0x0800) {
             return 1;
        }
        return 2;
    };


    var error = function (type, msg, filename, line){throw new that.window[type](msg, filename, line);};
    var read_until = function (data, offset, stopchr){
        var buf = [];
        var chr = data.slice(offset, offset + 1);
        var i = 2;
        while (chr != stopchr) {
            if ((i+offset) > data.length) {
                error('Error', 'Invalid');
            }
            buf.push(chr);
            chr = data.slice(offset + (i - 1),offset + i);
            i += 1;
        }
        return [buf.length, buf.join('')];
    };
    var read_chrs = function (data, offset, length){
        var buf;

        buf = [];
        for (var i = 0;i < length;i++){
            var chr = data.slice(offset + (i - 1),offset + i);
            buf.push(chr);
            length -= utf8Overhead(chr);
        }
        return [buf.length, buf.join('')];
    };
    var _unserialize = function (data, offset){
        var readdata;
        var readData;
        var chrs = 0;
        var ccount;
        var stringlength;
        var keyandchrs;
        var keys;

        if (!offset) {offset = 0;}
        var dtype = (data.slice(offset, offset + 1)).toLowerCase();

        var dataoffset = offset + 2;
        var typeconvert = function(x) {return x;};

        switch (dtype){
            case 'i':
                typeconvert = function (x) {return parseInt(x, 10);};
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
            break;
            case 'b':
                typeconvert = function (x) {return parseInt(x, 10) !== 0;};
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
            break;
            case 'd':
                typeconvert = function (x) {return parseFloat(x);};
                readData = read_until(data, dataoffset, ';');
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 1;
            break;
            case 'n':
                readdata = null;
            break;
            case 's':
                ccount = read_until(data, dataoffset, ':');
                chrs = ccount[0];
                stringlength = ccount[1];
                dataoffset += chrs + 2;

                readData = read_chrs(data, dataoffset+1, parseInt(stringlength, 10));
                chrs = readData[0];
                readdata = readData[1];
                dataoffset += chrs + 2;
                if (chrs != parseInt(stringlength, 10) && chrs != readdata.length){
                    error('SyntaxError', 'String length mismatch');
                }

                // Length was calculated on an utf-8 encoded string
                // so wait with decoding
                readdata = that.utf8_decode(readdata);
            break;
            case 'a':
                readdata = {};

                keyandchrs = read_until(data, dataoffset, ':');
                chrs = keyandchrs[0];
                keys = keyandchrs[1];
                dataoffset += chrs + 2;

                for (var i = 0; i < parseInt(keys, 10); i++){
                    var kprops = _unserialize(data, dataoffset);
                    var kchrs = kprops[1];
                    var key = kprops[2];
                    dataoffset += kchrs;

                    var vprops = _unserialize(data, dataoffset);
                    var vchrs = vprops[1];
                    var value = vprops[2];
                    dataoffset += vchrs;

                    readdata[key] = value;
                }

                dataoffset += 1;
            break;
            default:
                error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
            break;
        }
        return [dtype, dataoffset - offset, typeconvert(readdata)];
    };

    return _unserialize((data+''), 0)[2];
}



  //---------------------------------------------------------------------------------------------------------



//------------------------------Images-----------------------------------------------------------

/*
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)
{
	$.getJSON(
			base_url + '/json/property_photo_src',
			{
				url: url
			},
			function(data)
			{
				var sizeof = data.length;
				var id;
				if (sizeof >= 0)
				{
					if (!property_photo_data)
					{
						for (id in data)
						{
							property_photo_inner(id, data[id]);
						}
					}
					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]))
								{
									property_photo_inner(id, data[id]);
								}
							}
						}
					}
					property_photo_data = data;
					property_select_photo_select_is_all();
					$.getJSON(
							base_url + '/json/property_photo_dsc',
							{
								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_photo_gallery',
								{
									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)', 6000);
				}
				property_height();
			}
		);
} 
  
  */
  //--------------------------------------PROPERTY_HEIGHT----------------------------------
  /*
  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);
}
  
  
  
var property_photo_data = false;  
var property_photo_data_select_all = 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;



 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_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_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 + '/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');
			}
		}
	});
} 
  
*/  
 
/* var auth = false;
 
 $(document).ready(function()
 {
  if(auth)
  {
    $('#user_panel').css('visibility', 'visible');
  }
  else
  {
    $('#user_panel').css('visibility', 'hidden');
  }
 }); 
  */
//--------------------------------------------------------------------------------------------  
  

/*$(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];
		};
	}
  
  
    
 

  //$('#pr_b1').mouseover(function () { property_hover(this, 2, true); }).mouseout(function () { property_hover(this, 2, false); });     
	
	
	//-------------------------------------------------------------------------------------------------------------
 /* $('#r_feedback').click(function(){ popup_show('feedback', base_url + request_uri); });
	$('#feedback_copyright').click(function(){ popup_show('feedback', base_url + request_uri); return false; });
	$('#top_logo').click(function(){ window.location = base_url; });
	$('#top_logout').click(function(){ user_exit(); });
	


	if ($('#intro_main').size())
		{
		upload_swf('image_main_button', 1, 1, 424, 294, '/img/blank.gif');
		upload_swf('image_main_btn', 1, 1, 177, 38, '/img/bt_u_ph.gif');
		
	
    intro_photo_init();
		$('#button_cl').click(function(){ image_cleanup(); });
		$('#intro_examples_btn').click(function(){ window.location = base_url + '/Examples'; });
	}

	if ($('#public_main').size())
	{
		$('#hint_url').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
		$('#hint_embed').mouseover(function () { hint_show(this, -8, 0); }).mouseout(function () { hint_hide(this); });
		public_show(url);
		$('#public_download').click(function(){ public_download(url); });
	}
	
	//$('#gallery').click(function(){ task_auto(); });

	$('#popup_login').mouseover(function(){ $('#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_signup').mouseover(function(){ $('#popup_signup_con').removeClass('display_none'); $('#popup_signup').addClass('popup_signup_a'); $('#popup_login_con').addClass('display_none'); $('#popup_login').removeClass('popup_login_a'); });
	$('#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-3');
	$('a').mousedown(function(){ return false; });
	*/
	/*
});
*/




