<div class="container-fluid">
    <div class="yes"></div>
            <div class="row-fluid content"><div class="span6" id="POP"><div class=span10> <br>Перемещайте очки в нужное место<br><br><div class="designContainer" id="printable">
                <div class="imageContainerLimit">
                    <div class="span12" id="imagesContainer" >
                    </div>	
		


	
	
	
		
        <img id="Tshirtsrc" src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/2.png" alt="">
        </div>
		

        </div><div class=span12> <div class="div2">
  <div class="added-to-cart" ></div>
  <div class="product-title" style="font-family: Arial,sans-serif;color:rgb(25, 1, 1);font-weight: bold;"></div>
  <div id="product-description" style="font-family: Arial,sans-serif;color:rgb(25, 1, 1)"> </div><br>
  <div id="product-price" style="font-family: Arial,sans-serif;color:rgb(25, 1, 1);font-weight: bold;"> </div>
   <div class="navbar" align="right"><div class="Purchase">            
			  	<a href="#" class="exp">  
				Подробнее...</a>						   
                    </div>
                    </div> <div id="productname"></div> 
					<div class="proceeed">  
					
					
					<form id="zip_search" method="post" action=https://medoptika.kiev.ua/ru/?page_id=12927 data-trp-original-action="https://medoptika.kiev.ua/ru/?page_id=12927">
						​<textarea id="zipfield" name="zip" rows="5" cols="70" style="display:none">$product_title</textarea>
		​<textarea id="zipfieldl" name="ziplink" rows="5" cols="70" style="display:none" >$urlp</textarea>
        <input class="single_add_to_cart_button button alt" value="Купить модель →" border="0" type="submit" ><input type="hidden" name="trp-form-language" value="ru"/></form>
					
					
					
					
					
					
					
					</div>
					
					</div> </div> </div> </div><div class="span6">
                    <div class="widget">
                        <div class="widget-header">
                            <i class="icon-star"></i>
                            <h3>Настройки</h3>
                        </div>
                        <div class="widget-content" style="background-color:#F1F5F1">  
                          
                            <h5><i class="icon-tags"></i> Выберите изображение лица</h5>
                            <ul class="tshirts unstyled clearfix tooltip-show">                <li>
                    <a href="#" data-toggle="tooltip" data-placement="bottom" title='Блондинка'>
                                                <img src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/2.png" alt="Блондинка">
                    </a>
                </li>
                                     <li>
                    <a href="#" data-toggle="tooltip" data-placement="bottom" title='Лицо 1'>
                                                <img src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/1.png" alt="Лицо 1">
                    </a>
                </li>
                     <div id="status"></div><br /><div id="varpass"></div><br /><div id="varlink">https://medoptika.kiev.ua/ru/</div><br /></ul>  
	<hr>
	  <div class="span6"> <h5><i class="icon-picture"></i> Загрузить изображение </h5>
                            <input type="file" id="imgInp" class="span10" name="file" /> </div>
	
							
							

      	                                    
											<div class="span5"><center><h5><i class="icon-camera"></i> Сделать фото</h5>	</center>				
                                            
											
										<div class="ip-modal" id="avatarModal">
		<div class="ip-modal-dialog">
			<div class="ip-modal-content">
				
				<div class="ip-modal-body">
					<center><button type="button" class="btn btn-primary ip-webcam">Вебкамера</button>		</center>
										
					<div class="alert ip-alert"></div>
						<div class="ip-preview"></div>
				
					<div class="ip-progress">
						<div class="text">Загружается</div>
			
					</div>
				</div><br>
				<div class="ip-modal-footer">
					<div class="ip-actions">
						<button type="button" class="btn btn-success ip-save">Сохранить изображение</button>
						<button type="button" class="btn btn-primary ip-capture">Сделать другое</button>
						<button type="button" class="btn btn-default ip-cancel">Отмена</button>
					</div>
					
				</div>
			</div>
		</div>
	</div>											
											
											</div>
               
     
	 <div class="span12">	
			<div class="span6">	
							  <h5><i class="icon-zoom-in"></i> Изменить размер очков</h5>
                            <!-- Slider to change font size -->
                            <div class="slidere">
                                <!-- default value -->
                                <div class="sizee">89px</div>
								   
								
                                <!-- slider generated by jQuery UI -->
                                <div id="slidere"></div>
                            </div>
			  </div>
	&nbsp;
			  
	           <div class="span5">	
							  <h5><i class="icon-repeat"></i> Повернуть очки</h5>
                            <!-- Slider to change font size -->
                            <div class="sliderg">
                                <!-- default value -->
                                <div class="sizeg">0°</div>
								   
								
                                <!-- slider generated by jQuery UI -->
                                <div id="sliderg"></div>
                            </div>
			   </div> 
	</div>
		<div class="span12">	<hr> 
<h5><i class="icon-tags"></i> Очки для примерки</h5>
    <ul class="glasses unstyled clearfix tooltip-show">                <li>
                    <a href="#" data-toggle="tooltip" data-placement="bottom" title='Модель 3'>
                                                <img src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/3.png" alt="Модель 3">
                    </a>
                </li>
                                     <li>
                    <a href="#" data-toggle="tooltip" data-placement="bottom" title='Модель 2'>
                                                <img src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/2-1.png" alt="Модель 2">
                    </a>
                </li>
                                     <li>
                    <a href="#" data-toggle="tooltip" data-placement="bottom" title='Модель 1'>
                                                <img src="https://medoptika.kiev.ua/wp-content/uploads/2016/09/1-1.png" alt="Модель 1">
                    </a>
                </li>
                     </ul> 
    </div>
	
	</div>
	
	</div>
		
	</div>

	</div>
	    </div> 
	
	<ul class="dropdown-menu tooltip-show" id="font"></ul>
            <div id="myModal" class="modal hide fade">
              <div class="modal-body">
              </div>
              <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
              </div>
            </div>

            <div id="convascontent" style="display:none"></div>  
<script language="JavaScript" type="text/javascript">
jQuery(document).ready(function ($) {
	 $('#imagesContainer').css({"left": ''}).css({"top": ''});
	  $('.images').css({"width": ''}).css({"height": ''}).css({"transform": 'rotate()'});


	  var prtitle ='';
	  var addedtocart ='';

	  if (prtitle.length > 0){
	
	setTimeout(function() {
        $('.glasses').hide('blind', {}, 50)
    },0);

setTimeout(function() {
        $('.glasses').show('blind', {}, 500)
    },6000);
};

	  if (addedtocart.length > 0){
	
	setTimeout(function() {
		var addprod= '';
		
		   $('.added-to-cart').append("<i class='icon-ok'></i>"+addprod+" was successfully added to your cart.<br><br><br>");
        $('.added-to-cart').show('blind', {}, 500)
    },0);

setTimeout(function() {
        $('.added-to-cart').hide('blind', {}, 1000)
    },6000);
	
	setTimeout(function() {
        $('.proceeed').show('blind', {}, 1000)
    },7000);
};
	 
	 
	var xtitle;
	var xdescription;
	var xprice;
	var xbutton;
		var xaddtocart;
		var xaddsrcg;

	var urlx='https://medoptika.kiev.ua/ru/';

	 ;	
	var urltofile='https://medoptika.kiev.ua/wp-content/plugins/Glasses_Mirror/server/upload_avatar.php';
	
	 ;	
	var urltofile1='https://medoptika.kiev.ua/wp-content/plugins/Glasses_Mirror/assets/img/default-avatar.png';

	 ;	
	var urltofile2='https://medoptika.kiev.ua/wp-content/plugins/Glasses_Mirror/';




   $('.navbar').hide();

        var yep='';
		
		

			 //change glasses template
			   $('.glasses a').click(function(){
				   
			
	if( $('.proceeed').css("display") != 'none' ){		 
     $('.proceeed').hide();
     xa=setTimeout(function() {
        $('.proceeed').show('blind', {}, 200)
    }, 6000);   
}
			
			
	
setTimeout(function() {
       //$('.glasses').hide('blind', {}, 1000)
    },0);

setTimeout(function() {
        //$('.glasses').show('blind', {}, 200)
    },6000);
	
	 clearTimeout(xtitle);
	 	 clearTimeout(xdescription);
		 	 clearTimeout(xprice);
			 	 clearTimeout(xbutton);
				 		 clearTimeout(xaddtocart);
						 			 		 clearTimeout(xaddsrcg);
						 
				 


            //get clicked template src
            var src = $(this).find('img').attr('src');
		
            //apply it on the original image to be edited

			  $('#imagesContainer').find('img').attr('src',src);		  

			 			   
			var tit=$(this).find('img').attr('alt');
			$('.product-title').text(tit);
		    var ok=tit;	
		

				// Create our XMLHttpRequest object
    var hr = new XMLHttpRequest();
	var hr1 = new XMLHttpRequest();
	var hr2 = new XMLHttpRequest();
	var hr3 = new XMLHttpRequest();
    // Create some variables we need to send to our PHP file
	
    var url =urlx+"/Myproduct_links.php";
	var url1 =urlx+"/Myproduct_description.php";
	var url2 =urlx+"/Myproduct_price.php";
	var url3 =urlx+"/Woocommerce_file.php";

    var fn = tit;
    var ln = "";
    var vars = "firstname="+fn+"&lastname="+ln;
	
    hr.open("POST", url, true);
	hr1.open("POST", url1, true);
	hr2.open("POST", url2, true);
	hr3.open("POST", url3, true);
	
    // Set content type header information for sending url encoded variables in the request
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	hr1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	hr2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	hr3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	
    // Access the onreadystatechange event for the XMLHttpRequest object
    hr.onreadystatechange = function() {
   if(hr.readyState == 4 && hr.status == 200) {
   var return_data = hr.responseText;
   document.getElementById("status").innerHTML = return_data;

   }
    }
	 hr1.onreadystatechange = function() {
   if(hr1.readyState == 4 && hr1.status == 200) {
   var return_data = hr1.responseText;
   document.getElementById("product-description").innerHTML = return_data;

   }
    }
		 hr2.onreadystatechange = function() {
   if(hr2.readyState == 4 && hr2.status == 200) {
   var return_data = hr2.responseText;
   document.getElementById("product-price").innerHTML = return_data;

   }
    }
	
	
			 hr3.onreadystatechange = function() {
   if(hr3.readyState == 4 && hr3.status == 200) {
   var return_data = hr3.responseText;
   document.getElementById("productname").innerHTML = return_data;

   }
    }
	
    // Send the data to PHP now... and wait for response to update the dressstatus div
    hr.send(vars); // Actually execute the request
    document.getElementById("status").innerHTML = "";
	   
	   // Send the data to PHP now... and wait for response to update the dressstatus div
    hr1.send(vars); // Actually execute the request
    document.getElementById("product-description").innerHTML = "";
	
	   // Send the data to PHP now... and wait for response to update the dressstatus div
    hr2.send(vars); // Actually execute the request
    document.getElementById("product-price").innerHTML = ""; 
				
	 // Send the data to PHP now... and wait for response to update the dressstatus div
    hr3.send(vars); // Actually execute the request
    document.getElementById("productname").innerHTML = ""; 	
				
				
			$('.product-title').hide();			
			$('#product-description').hide();
			$('#product-price').hide();
			$('.navbar').hide();
			$('#productname').hide();
	
		 xtitle=setTimeout(function() {
        $('.product-title').show('bounce', {}, 800)
    }, 1000);
	
	  xbutton=setTimeout(function() {
        $('.navbar').show('blind', {}, 2000)
    }, 2000);
	
	  xdescription=setTimeout(function() {
     $('#product-description').show('blind', {}, 1000)
    }, 3000);
	
	 xprice=setTimeout(function() {
        $('#product-price').show('blind', {}, 1000)
    }, 4000);
	

	  xaddtocart=setTimeout(function() {

      
        $('#productname').show('blind', {}, 1000)
    }, 5000);
	
						  xaddsrcg=setTimeout(function() {
			var srcg = $('#Tshirtsrc').attr('src'); 
			$('#srcimg').html(srcg);
	}, 6000); 
 
	 setTimeout(function() {
			var offset = $('#imagesContainer').position();
            var xPos = offset.left;
            var yPos = offset.top;
            $('#imgleft').text(xPos+'px');
            $('#imgtop').text(yPos+'px');
			
			var imageswidth=$('.images').width();
			$('#imgwidth').text(imageswidth+'px');
		 $('#rotation').text('');
			
			}, 6000); 
			
			
           return false ;
        });
			
	  xaddsrcg=setTimeout(function() {
			var srcg = $('#Tshirtsrc').attr('src'); 
			$('#srcimg').html(srcg);
	}, 6000); 
			
	
			
				  setTimeout(function() {
			var offset = $('#imagesContainer').position();
            var xPos = offset.left;
            var yPos = offset.top;
            $('#imgleft').text(xPos+'px');
            $('#imgtop').text(yPos+'px');
			
			var imageswidth=$('.images').width();
			$('#imgwidth').text(imageswidth+'px');
			

			    $('#rotation').text('');
			
				
			}, 6000); 
			
			
			
			
			
				
     $('.exp').click(function(){
 yep = $("#status").html();

var myString = yep.substr(yep.indexOf("http") + 0);

$(this).prop('href',myString);
 });	




//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//	//

	
			
;(function($, window, document, undefined) {

	// Detect XMLHttpRequest support
	$.support.xhrUpload =  !!(window.XMLHttpRequest && window.File && window.FileReader
								&& window.FileList && window.Blob && window.FormData);

	// Detect getUserMedia support
	$.support.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia ||
                            	navigator.mozGetUserMedia || navigator.msGetUserMedia);

	// Detect Jcrop support
	$.support.Jcrop = !!$.Jcrop;

	// Detect JPEGCam support
	$.support.Webcam = !!window.Webcam;

	var
	// Plugin name
	pluginName = 'imgPicker',

	// Default plugin options
	defaults = {
		// Upload url (Value Type: string)
		url: 'server/upload.php',

		// DropZone (See Plugin.prototype.init())
		//dropZone: null,

       	// Whether crop is enabled (Value Type: boolean)
       	crop: true,

       	// Aspect ratio of w/h (Value Type: decimal)
        aspectRatio: null,

        // Minimum width/height, use 0 for unbounded dimension (Value Type: array [ w, h ])
        minSize: null,

        // Maximum width/height, use 0 for unbounded dimension (Value Type: array [ w, h ])
        maxSize: null,

        // Set an initial selection area (Value Type: array [ x, y, x2, y2 ])
        setSelect: null,

        // Flash swf url
        swf: 'assets/webcam.swf',

        // Flash swf width/height (Value Type: array [ w, h ])
        swfSize: [470, 350],

		// Custom data to be passed to server (Value Type: object)
		data: {},

		// Messages
		messages: {
			selectimg: 'Please select a image to upload',
			parsererror: 'Invalid response',
			webcamerror: 'Ошибка с веб камерой: ',
			uploading: 'Загрузка...',
            error: 'Unexpected error',
            datauri: 'Cannot locate image format in Data URI',
            webcamjs: 'Флеш веб камера не найдена',
            upgrade: 'This feature is not available in this browser',
            loading: 'Загружаю изображение...',
            saving: 'Сохранение...',
            jcrop: 'jQuery Jcrop not found',
            minCropWidth: 'Crop selection requires a minimum width of ',
            maxCropWidth: 'Crop selection exceeds maximum width of ',
            minCropHeight: 'Crop selection requires a height of ',
            maxCropHeight: 'Crop selection exceeds maximum height of ',
            img404: 'Error 404: No image was found'
		},
	},
	// HTML5 webcam stream
	stream,

	// IframeTransport iframe counter
	counter = 0;

	// Plugin constructor
	function Plugin(container, options) {
		this.options   = $.extend({}, defaults, options);
		this.container = $(container);
		this.init();
	}

	// Plugin functions
	Plugin.prototype = {

		// Initialization function
		init: function() {

			// Add click events for the buttons
			this.elem('.ip-upload').on('change', 'input', $.proxy(this.upload, this));
			this.elem('.ip-webcam').on('click', $.proxy(this.webcam, this));
			this.elem('.ip-edit').on('click', $.proxy(this.edit, this));
			this.elem('.ip-delete').on('click', $.proxy(this._delete, this));
			this.elem('.ip-cancel').on('click', $.proxy(this.reset, this));

			if (this.options.dropZone === undefined)
				this.options.dropZone = this.container;

			var self = this,
			trigger  = $('[data-ip-modal="#'+ this.container.attr('id') +'"]');

			if (trigger.length) {
				// Modal events
				this.container.on({
					'show.ip.modal': function() {
						self.container.fadeIn(150, function() {
							$(this).trigger('shown.ip.modal', self);
						});
					},
					'hide.ip.modal': function() {
						self.container.fadeOut(150, function() {
							self.reset();
							$(this).trigger('hidden.ip.modal', self);
						});
					}
				});

				// Add click event on the button to open modal
				trigger.on('click', function(e) {
					e.preventDefault();
					self.modal('show');
					self.elem('.ip-close').off().on('click', function() {
						self.modal('hide');
					});
				});

				if (this.options.dropZone === undefined)
					this.options.dropZone = this.elem('.ip-modal-content');
			}

			// Drag & drop upload
			if (this.options.dropZone) {
				this.options.dropZone.on('dragenter', function(e) {
					e.stopPropagation();
				    e.preventDefault();
				}).on('dragover', function(e) {
					e.stopPropagation();
	     			e.preventDefault();
				}).on('drop', function(e) {
					e.preventDefault();
		    		if (e.originalEvent.dataTransfer.files && e.originalEvent.dataTransfer.files[0]) {
		    			self.reset();
		    			self.handleFileUpload(e.originalEvent.dataTransfer.files[0]);
		    		}
		    	});
			}

			if (this.options.loadComplete)
				this.load();
		},

		// Modal function, show/hide modal
		modal: function(action) {
			this.container.trigger(action + '.ip.modal');
		},

		// Autoload image from server
		load: function() {
			var self = this;
			$.ajax({
				url: this.options.url,
				dataType: 'json',
				data: {action: 'load', data: this.options.data},
				success: function(response) {
					self.dispatch('loadComplete', response);
				}
			});
		},

		// Upload init
		upload: function(event) {
			this.reset();

			// Iframe Transport fallback
			if (!$.support.xhrUpload)
				return this.iframeTransport(event);

			// XHR Upload
			if (event.target.files && event.target.files[0])
				this.handleFileUpload(event.target.files[0]);

		   	$(event.target).val('');
		},

		// Iframe Transport upload
		iframeTransport: function(event) {
			var iframe, form, self = this,
			fileInput = $(event.target),
	        parent = fileInput.parent(),
	        fileInputClone = fileInput.clone();

	        this.dispatch('uploadProgress', 100);

	        // Create & add iframe to body
	        iframe = $('<iframe name="iframe-transport-'+(counter+1)+'" style="display:none;"></iframe>')
	        .appendTo('body')
			.on('load', function() {
	            self.dispatch('uploadProgressComplete', function() {
	            	try {
		                var response = $.parseJSON( iframe.contents().find('body').html() );
		            } catch(e) {}

		            // Check for response
		            if (response) {
		            	self.alert('', 'hide');
		                self.uploadComplete(response);
		            } else
						self.alert(self.i18n('parsererror'), 'error');

		            // Remove iframe & form
		            setTimeout(function() {
		                iframe.remove(); form.remove();
		                parent.append(fileInputClone);
		            }, 100);
		        });
	        });

	        // Create form
	        form = $('<form style="display:none;"><form/>');
	        form.prop('method', 'POST');
	        form.prop('action', this.options.url);
	        form.prop('target', iframe.prop('name'));
	        form.prop('enctype', 'multipart/form-data');
	        form.prop('encoding', 'multipart/form-data');
	        form.prop({action: this.options.url, target: iframe.prop('name')});
	        form.append(fileInput);
	        form.append('<input type="hidden" name="action" value="upload"/>');

	        // Add custom data to the form
	        if (this.options.data)
	            $.each(this.options.data, function (name, value) {
	                $('<input type="hidden"/>').prop('name', 'data['+name+']').val(value).appendTo(form);
	            });

	        // Append the form to body and submit
	        form.appendTo('body').trigger('submit');
		},

		// Webcam snapshot
		webcam: function() {
			this.reset();

	        // Flash webcam fallback
	        if (!$.support.getUserMedia)
	        	return this.flashWebcam();

	        // HTML5 Webcam with <video>
			var video = $('<video autoplay></video>');
            this.elem('.ip-preview').html(video);

            navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia ||
                                   navigator.mozGetUserMedia || navigator.msGetUserMedia);

            var self = this;
            navigator.getUserMedia({video: true}, function(_stream) {
                video.attr('src', window.URL.createObjectURL(stream = _stream) );

                self.elem('.ip-preview, .ip-cancel').show();
               	self.elem('.ip-capture').on('click', function() {
                    var canvas = document.createElement('canvas'),
                        ctx    = canvas.getContext('2d');

                    canvas.width  = video[0].videoWidth;
                    canvas.height = video[0].videoHeight;
                    ctx.drawImage(video[0], 0, 0);

                    self.reset();
                    self.handleFileUpload( canvas.toDataURL('image/jpeg') );
                }).show();

            }, function(error) {
            	self.alert(self.i18n('webcamerror') + error.name, 'error');
            });
		},

		// Flash webcam fallback
		flashWebcam: function() {
			//if (!$.support.Webcam)
			//	return this.alert(this.i18n('webcamjs'), 'error');

			// Check if browser supports XHR upload
			if (!$.support.xhrUpload)
				return this.alert(this.i18n('upgrade'), 'error');

			this.elem('.ip-preview').html( Webcam.getHtml(this.options.swf, this.options.swfSize) ).show();

			var self = this;
            Webcam.loaded = function() {
            	self.elem('.ip-cancel').show();
                self.elem('.ip-capture').on('click', function() {
                	var imageData = Webcam.snap();
                	self.reset();
                	self.handleFileUpload(imageData);
                }).show();
            };
		},


		// Handle file upload
		handleFileUpload: function(file) {
			// Check for file
			if (!file)
		    	return this.alert(this.i18n('selectimg'), 'error');

		    // Check if file is ImageData string
			if (!file.name) {
				if (!file.match(/^data\:image\/(\w+)/))
					return this.alert(this.i18n('datauri'), 'error');

				var rawImageData = file.replace(/^data\:image\/\w+\;base64\,/, '');
				file = new Blob([this.base64DecToArr(rawImageData)], {type: 'image/jpeg'});
			}

			var self = this;

			this.elem('.ip-upload input, .ip-webcam').prop('disabled', true),

			// Init XHR upload
			xhr = $.ajaxSettings.xhr();
			xhr.open('POST', this.options.url, true);

			// XHR upload progress
			xhr.upload.onprogress = function(e) {
				if (e.lengthComputable) {
			      	var percentage = Math.floor((e.loaded / e.total) * 100);
			      	self.dispatch('uploadProgress', percentage);
			 	}
			};

			// XHR upload complete
			xhr.onload = function() { setTimeout(function() {
				self.elem('.ip-upload input, .ip-webcam').prop('disabled', false);
				self.dispatch('uploadProgressComplete', function() {
					if (xhr.status == 200) {
						try {
			                var response = $.parseJSON(xhr.responseText);
			            } catch(e) {}

			            // Check for response
			            if (response) {
			            	self.alert('', 'hide');
			                return self.uploadComplete(response);
			            }
					}
					self.alert(self.i18n('parsererror'), 'error');
				});
			}, 500)};

			// Create form, append file input and custom inputs
			var form = new FormData();
			form.append('action', 'upload');
			form.append('file', file);
			$.each(this.options.data, function(name, val) {
				form.append('data['+name+']', val);
			});

			// Send request
			xhr.send(form);
		},

		// Upload progress
		uploadProgress: function(percentage) {
			this.elem('.ip-progress').fadeIn().find('.progress-bar').css('width', percentage+'%');
    	},

    	// Upload progress complete
    	uploadProgressComplete: function(callback) {
    		this.elem('.ip-progress').fadeOut(function() {
    			$(this).find('.progress-bar').css('width', '0%');
    			callback();
    		});
    	},

    	// Upload complete
    	uploadComplete: function(image) {
    		// Check for image erro
			if (image.error)
				return this.alert(this.i18n(image.error||'error'), 'error');

			// Dispatch uploadSuccess callback
	        this.dispatch('uploadSuccess', image);

	        if (this.options.crop)
	        	this.crop(image);
		},

		// Crop function
		crop: function(image) {
			this.reset();

			// Check if Jcrop exists
			if (!$.support.Jcrop)
				return this.dispatch('alert', this.i18n('jcrop'), 'error');

			var self = this,
			imagePreview = this.options.url + '?action=preview&file=' + image.name + '&width=800',
			rotation = 0,
	        coords,
	        updateCoords = function(_coords) { coords = _coords },
	        options = {onChange: updateCoords, onRelease: updateCoords, bgColor: 'white'},
	        rotate = function(deg) {
				rotation += deg;
				if (Math.abs(rotation) >= 360) rotation = 0;
				loadjcrop(imagePreview+'&rotate='+rotation);
			};

	        if (this.options.aspectRatio) options.aspectRatio = this.options.aspectRatio;
	        if (this.options.setSelect) options.setSelect = this.options.setSelect;
	        if (this.options.minSize) options.minSize = this.options.minSize;
	        if (this.options.maxSize) options.maxSize = this.options.maxSize;

	        var loadjcrop = function(imagePreview) {
	        	imagePreview += '&rand=' + new Date().getTime();
	        	self.alert(self.i18n('loading'), 'loading');

	        	var tmpImage = new Image();
	        	tmpImage.onload = function() {
	        		self.alert('', 'hide');
		            self.elem('.ip-cancel').show();

		            var img = $('<img src="'+imagePreview+'" style="visibility:hidden;">');
		            self.elem('.ip-preview').html(img);

		            if (Math.abs(rotation) == 90 || Math.abs(rotation) == 270)
		            	options.trueSize = [image.height, image.width];
		            else
		            	options.trueSize = [image.width, image.height];

		            self.elem('.ip-preview, .ip-rotate, .ip-info, .ip-save').show();

		            img.Jcrop(options);
		        };

		        tmpImage.onerror = function() { self.alert(self.i18n('img404'), 'error') };
		        tmpImage.src = imagePreview;
	        };

	        loadjcrop(imagePreview);

	        // Rotate events
	       	this.elem('.ip-rotate-ccw').on('click', function() { rotate(-90) }).show();
			this.elem('.ip-rotate-cw').on('click', function() { rotate(90) }).show();

			// Save event
			this.elem('.ip-save').on('click', function() {
                $.ajax({
                    url: self.options.url,
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        action: 'crop',
                        image: image.name,
                        coords: coords,
                        rotate: rotation,
                        data: self.options.data
                    },
                    beforeSend: function() {
                    	if (!self.validateCrop(coords||{})) return;

                    	self.elem('.ip-save').prop('disabled', true);
                		self.alert(self.i18n('saving'), 'loading');
                    },
                    success: function(image) {
                    	if (image.error)
                    		return self.alert(self.i18n(image.error||'error'), 'error');
                    	self.reset();
                    	self.setImage(image);
						self.dispatch('cropSuccess', image);
                    },
                    error: function() { self.alert(self.i18n('parsererror'), 'error') },
                    complete: function() { self.elem('.ip-save').prop('disabled', false) }
                });
            });
		},

		// Crop validation
	    validateCrop: function(coords) {
	        var  options = this.options;
	        if (options.minSize) {
	            if (options.minSize[0] && (coords.w||0) < options.minSize[0])
	               return this.alert(this.i18n('minCropWidth')+options.minSize[0]+'px', 'error');

	            if (options.maxSize && options.maxSize[0] && (coords.w||0) > options.maxSize[0])
	                return this.alert(this.i18n('maxCropWidth')+options.maxSize[0]+'px', 'error');

	            if (options.minSize[1] && (coords.h||0) < options.minSize[1])
	                return this.alert(this.i18n('minCropHeight')+options.minSize[1]+'px', 'error');

	            if (options.maxSize && options.maxSize[1] && (coords.h||0) > options.maxSize[1])
	               return this.alert(this.i18n('maxCropHeight')+options.maxSize[1]+'px', 'error');
	        }
	        return true;
	    },

	    // Delete action
	    _delete: function() {
	    	if (this.image && this.image.name)
	    		$.post(this.options.url, {action: 'delete', data: this.options.data, file: this.image.name});

	    	this.elem('.ip-delete, .ip-edit').hide();
	    	this.dispatch('deleteComplete');
	    },

	    // Edit action
	    edit: function() {
	    	if (this.image)
	    		this.crop(this.image);
	    },

	    // Set image object
	    setImage: function(image) {
	    	this.image = image;
	    	this.elem('.ip-delete, .ip-edit').show();
	    },

		// Reset everything
		reset: function() {
			this.alert('', 'hide');

			this.elem('.ip-preview').html('').fadeOut();
	        this.elem('.ip-save, .ip-capture, .ip-rotate-cw, .ip-rotate-ccw').off().hide();
	        this.elem('.ip-cancel, .ip-rotate, .ip-info').hide();

	        if (stream) stream.stop();
		},

		// Alert function
		alert: function(message, messageType) {
			if (this.options.alert)
				return this.options.alert(message, messageType);

	        var alert = this.container.find('.ip-alert');

	        if (messageType == 'hide')
	        	return alert.hide();

	        alert.html(message)
	            .removeClass(
	            	(messageType == 'success' ? 'alert-danger alert-warning' :
	            		messageType =='warning' || messageType == 'loading' ?
	            			'alert-danger alert-success' :
	            				'alert-warning alert-danger')
	            )
	            .addClass('alert-'+ ( messageType == 'success' ? 'success' :
	            			messageType =='warning' || messageType == 'loading' ?
	            				'warning' : 'danger')
	            ).append( $('<a class="dismiss">&times;</a>').on('click', function() { alert.hide(); }) )
	            .show();
		},

		// Translation function
	 	i18n: function(message) {
            return (this.options.messages[message] || message.toString());
        },

		// Get element from container
		elem: function(selector) {
			return this.container.find(selector);
		},

		// Dispatch callbacks
		dispatch: function() {
			var name = arguments[0].replace(/^on/i, ''),
				args = Array.prototype.slice.call(arguments, 1),
				callback = this.options[name] || this[name];

			if (callback) {
				if (typeof(callback) == 'function') {
					callback.apply(this, args);
					return true;
				}
			}
			return false;
		},

		// Convert base64 encoded character to 6-bit integer
		b64ToUint6: function(nChr) {
			// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
			return nChr > 64 && nChr < 91 ? nChr - 65
				: nChr > 96 && nChr < 123 ? nChr - 71
				: nChr > 47 && nChr < 58 ? nChr + 4
				: nChr === 43 ? 62 : nChr === 47 ? 63 : 0;
		},

		// Convert base64 encoded string to Uintarray
		base64DecToArr: function(sBase64, nBlocksSize) {
			// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
			var sB64Enc = sBase64.replace(/[^A-Za-z0-9\+\/]/g, ""), nInLen = sB64Enc.length,
				nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2,
				taBytes = new Uint8Array(nOutLen);

			for (var nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {
				nMod4 = nInIdx & 3;
				nUint24 |= this.b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4;
				if (nMod4 === 3 || nInLen - nInIdx === 1) {
					for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {
						taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;
					}
					nUint24 = 0;
				}
			}
			return taBytes;
		}
	};

	// Plugin wrapper, prevents multiple instantiations
	$.fn[pluginName] = function(options) {
		this.each(function() {
			if (!$.data(this, 'plugin_' + pluginName)) {
				$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
			}
		});

		// chain jQuery functions
		return this;
	};

})(jQuery, window, document);


/**
 * JPEGCam (custom)
 * Joseph Huckaby
 * https://code.google.com/p/jpegcam/
 */
window.Webcam = {
    isLoaded: false,
    loaded: null,
    complete: null,
    error: null,

    // Return html to embed webcam.swf flash
    getHtml: function(swf, swfSize) {
        return '<object id="webcam_movie_obj" type="application/x-shockwave-flash" width="'+swfSize[0]+'" height="'+swfSize[1]+'"><param name="allowScriptAccess" value="always"/><param name="allowFullScreen" value="false"/><param name="movie" value="'+swf+'"/><param name="wmode" value="transparent"/><param name="flashvars" value="width='+swfSize[0]+'&height='+swfSize[1]+'&dest_width='+(swfSize[0]*1.5)+'&dest_height='+(swfSize[1]*1.5)+'&image_format=jpeg&jpeg_quality=100&force_flash=false">'+
                '</object>';
    },

    // Send request to webcam.swf
    snap: function() {
        if (!this.isLoaded)
            return alert('JPEGCam ERROR: Movie is not loaded yet');

        var movie = document.getElementById('webcam_movie_obj'),
        	rawData = '';

        if (!movie)
            alert('JPEGCam ERROR: Cannot locate movie #webcam_movie_obj in DOM');

        try {
            rawData = 'data:image/jpeg;base64,' + movie._snap();
        } catch (e) {}

        return rawData;
    },

    // webcam.swf will call this function
    flashNotify: function(type, msg) {
        switch (type) {
			case 'flashLoadComplete':
				this.isLoaded = true;
			break;

			case 'cameraLive':
				this.loaded();
			break;

			case 'error':
				 this.error(msg);
			break;
		}
    }
};
			
		
					$(function() {
			var time = function(){return'?'+new Date().getTime()};
			
			// Avatar setup
			$('#avatarModal').imgPicker({
				url:urltofile,
				aspectRatio: 1, // Crop aspect ratio
				// Delete callback
				deleteComplete: function() {
					$('#Tshirtsrc').attr('src',urltofile1);
					this.modal('hide');
				},
				// Crop success callback
				cropSuccess: function(image) {
					console.log(image);
					$('#Tshirtsrc').attr('src',urltofile2+image.versions.avatar.url + time());
					this.modal('hide');
				},
				// Send some custom data to server
				data: {
					key: 'value',
				}
			});		
		}); 
			
			
			
});
 
				

</script>	


    {"id":31,"date":"2014-09-25T01:16:10","date_gmt":"2014-09-24T21:16:10","guid":{"rendered":"https:\/\/www.medoptika.kiev.ua\/?page_id=31"},"modified":"2016-09-29T13:41:03","modified_gmt":"2016-09-29T09:41:03","slug":"pick-up-points","status":"publish","type":"page","link":"https:\/\/medoptika.kiev.ua\/ru\/pick-up-points\/","title":{"rendered":"\u041f\u043e\u0434\u0431\u043e\u0440 \u043e\u0447\u043a\u043e\u0432"},"content":{"rendered":"\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u041f\u043e\u0434\u0431\u043e\u0440 \u043e\u0447\u043a\u043e\u0432 - \u041c\u0435\u0434\u043e\u043f\u0442\u0438\u043a\u0430<\/title>\n<link rel=\"canonical\" href=\"https:\/\/medoptika.kiev.ua\/ru\/pick-up-points\/\" \>\n<meta property=\"og:locale\" content=\"ru_RU\" \>\n<meta property=\"og:type\" content=\"article\" \>\n<meta property=\"og:title\" content=\"\u041f\u043e\u0434\u0431\u043e\u0440 \u043e\u0447\u043a\u043e\u0432 - \u041c\u0435\u0434\u043e\u043f\u0442\u0438\u043a\u0430\" \>\n<meta property=\"og:url\" content=\"https:\/\/medoptika.kiev.ua\/ru\/pick-up-points\/\" \>\n<meta property=\"og:site_name\" content=\"\u041c\u0435\u0434\u043e\u043f\u0442\u0438\u043a\u0430\" \>\n<meta property=\"article:modified_time\" content=\"2016-09-29T09:41:03+00:00\" \>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/medoptika.kiev.ua\/#website\",\"url\":\"https:\/\/medoptika.kiev.ua\/\",\"name\":\"\\u041c\\u0435\\u0434\\u043e\\u043f\\u0442\\u0438\\u043a\\u0430\",\"description\":\"\\u0417\\u0434\\u043e\\u0440\\u043e\\u0432\\u044c\\u0435 \\u0412\\u0430\\u0448\\u0438\\u0445 \\u0433\\u043b\\u0430\\u0437\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/medoptika.kiev.ua\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"ru-RU\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/#webpage\",\"url\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/\",\"name\":\"\\u041f\\u043e\\u0434\\u0431\\u043e\\u0440 \\u043e\\u0447\\u043a\\u043e\\u0432 - \\u041c\\u0435\\u0434\\u043e\\u043f\\u0442\\u0438\\u043a\\u0430\",\"isPartOf\":{\"@id\":\"https:\/\/medoptika.kiev.ua\/#website\"},\"datePublished\":\"2014-09-24T21:16:10+00:00\",\"dateModified\":\"2016-09-29T09:41:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/#breadcrumb\"},\"inLanguage\":\"ru-RU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/medoptika.kiev.ua\/pick-up-points\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/medoptika.kiev.ua\/uk\/\",\"url\":\"https:\/\/medoptika.kiev.ua\/uk\/\",\"name\":\"\\u0413\\u043b\\u0430\\u0432\\u043d\\u043e\\u0435 \\u043c\\u0435\\u043d\\u044e\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/\",\"url\":\"https:\/\/medoptika.kiev.ua\/pick-up-points\/\",\"name\":\"\\u041f\\u043e\\u0434\\u0431\\u043e\\u0440 \\u043e\\u0447\\u043a\\u043e\\u0432\"}}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/pages\/31"}],"collection":[{"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":0,"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/pages\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/medoptika.kiev.ua\/ru\/wp-json\/wp\/v2\/media?parent=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}