$(document).ready(function() {
    
	
	
    var currentPos = 0;
    
    $('.dealScrollContent').each(function(index) {
        $(this).prepend("<span style='display:none;' id='span-id-" + index + "'>" + currentPos + "</span>");
    });

    
    $(".scrollbuttonBottom").bind('click', function() {
        
        var currentH = $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").height();
        currentPos = Number($(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html());
        
        if(("-" + (currentH - 264)) <= (-264 * currentPos) ){
            currentPos += 1;
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").animate({"marginTop": ( -264 * currentPos) + "px"}, 'slow');
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html("");
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html(Number(currentPos));
        }else{
        
        }
        
        
    });
    
    $(".scrollbuttonTop").bind('click', function() {
        currentPos = Number($(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html());
        
        if(currentPos >= 1 ){
            currentPos -= 1;
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").animate({"marginTop": ( -264 * currentPos) + "px"}, 'slow');
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html("");
            $(this).parent(".dealScrollPanel").children(".dealScrollBG").children("div").children("div").children("span").html(currentPos);
        }else{
            
        }
    });
    
    
    /***************** Registration Lighbox ****************/


    $('a.popup').each(function(){
		if ($(this).attr('process_popup')==undefined)
		$(this).click(function(e){
			$(".popupWrapperBGVm").remove();
			$(".popupWrapperVm").remove();
			$("#mypopup").remove();
			$("#mypopup input[type=image]").remove();
			var idobj = "id"+String(Math.random()).substr(2,7);
			$("body").prepend('<div class="popupWrapperVm '+idobj+'" id="mypopup" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
			var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){
				   if($(e).css('position')=='absolute')
						return parseInt($(e).css('z-index'))||1 ;
				   })
			);
			var cssObj = {
			  'background' : '#000000',
			  'display' : 'block',
			  'height' : '100%',
			  'opacity' : ' 0.8',
			  'position' : 'fixed',
			  'width' : '100%',
			  'z-index' : (maxZ+1)
			}
			$(".popupWrapperVm").css('z-index',(maxZ+2));
			$(".popupWrapperBGVm").css(cssObj);
			$(".popupWrapperBGVm").fadeTo(10,.8);
			var url = $(this).attr("href");
			$.ajax({
				  url: url,
				  global: false,
				  async:false,
				  success: function(response){
						$('.'+idobj).html(response);
						var val = $('.'+idobj).width()/2;
						$('.'+idobj).css("margin-left","-"+val+"px");
						$('.'+idobj+' input[type=image]').attr("id","");
						addaction($('.'+idobj+' input[type=image]'),url,idobj);
						$(".popupWrapperVm").animate({
						  "opacity": "show"
						}, 500);     
						add_select();					
				  }
			});
			   
			   
			$('#mypopup').show();
			e.preventDefault();
		});
    });
    $('a.simply_popup').each(function(){
		if ($(this).attr('process_popup')==undefined)
		$(this).click(function(e){
			$(this).attr('process_popup','true');
			$(".popupWrapperBGVm").remove();
			$(".popupWrapperVm").remove();
			$("#mypopup").remove();
			$("body").prepend('<div class="popupWrapperVm" id="mypopup" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
			var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){
				   if($(e).css('position')=='absolute')
						return parseInt($(e).css('z-index'))||1 ;
				   })
			);
			var cssObj = {
			  'background' : '#000000',
			  'display' : 'block',
			  'height' : '100%',
			  'opacity' : ' 0.8',
			  'position' : 'fixed',
			  'width' : '100%',
			  'z-index' : (maxZ+1)
			}
			$(".popupWrapperVm").css('z-index',(maxZ+2));
			$(".popupWrapperBGVm").css(cssObj);
			$(".popupWrapperBGVm").fadeTo(10,.8);
			var url = $(this).attr("href");
			$.ajax({
				  url: url,
				  global: false,
				  async:false,
				  success: function(response){
						$('#mypopup').html(response);
						var val = $('#mypopup').width()/2;
						$('#mypopup').css("margin-left","-"+val+"px");
						$(".popupWrapperVm").animate({
						  "opacity": "show"
						}, 500);     
				  }
			});
			$('#mypopup').show();
			e.preventDefault();
		});
    });

    $('a.popup2').each(function(){
		if ($(this).attr('process_popup')==undefined)
		$(this).click(function(e){
			$(".popupWrapperBGVm").remove();
			$(".popupWrapperVm").remove();
			$("#mypopup").remove();
			$("#mypopup input[type=image]").remove();
			var idobj = "id"+String(Math.random()).substr(2,7);
			$("body").prepend('<div class="popupWrapperVm '+idobj+'" id="mypopup" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
			var cssObj = {
			  'background' : '#000000',
			  'display' : 'block',
			  'height' : '100%',
			  'opacity' : ' 0.8',
			  'position' : 'fixed',
			  'width' : '100%',
			  'z-index' : '1'
			}
			$(".popupWrapperBGVm").css(cssObj);
			$(".popupWrapperBGVm").fadeTo(10,.8);
			var url = $(this).attr("href");
			$.ajax({
				  url: url,
				  global: false,
				  async:false,
				  success: function(response){
						$('.'+idobj).html(response);
						var val = $('.'+idobj).width()/2;
						$('.'+idobj).css("margin-left","-"+val+"px");
						$('.'+idobj+' input[type=image]').attr("id","");
						$(".popupWrapperVm").animate({
						  "opacity": "show"
						}, 500);     
						add_select();
				  }
			});
			   
			   
			$('#mypopup').show();
			e.preventDefault();
		});
    });
	
    
    $('a#regConsumer').live('click', function(e){
        
		$.ajax({
			  url: "/users/register_consumer",
			  global: false,
			  async:false,
			  success: function(response){
					$('.popupWrapperVm').html(response);
					var val = $('.popupWrapperVm').width()/2;
					$('.popupWrapperVm').css("margin-left","-"+val+"px");
					$(".popupWrapperVm").animate({
					  "opacity": "show"
					}, 500); 
					
			  }
        });
           
           
        $('.popupWrapperBGVm').show();
        $('#signin_menuCreate').hide();
        e.preventDefault();
    });
    
    
    $('a#regProvider').live('click', function(e){
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("body").prepend('<div class="popupWrapperVm" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
        
		$.ajax({
			  url: "/users/register_provider",
			  global: false,
			  async:false,
			  success: function(response){
					$('.popupWrapperVm').html(response);
					var val = $('.popupWrapperVm').width()/2;
					$('.popupWrapperVm').css("margin-left","-"+val+"px");
					$(".popupWrapperVm").animate({
					  "opacity": "show"
					}, 500); 
					add_select();
			  }
        });
           
           
        $('.popupWrapperBGVm').show();
        $('#signin_menuCreate').hide();
        e.preventDefault();
    });
    $('a#regProvider2').live('click', function(e){
        
		$.ajax({
			  url: "/users/register_provider",
			  global: false,
			  async:false,
			  success: function(response){
					$('.popupWrapperVm').html(response);
					var val = $('.popupWrapperVm').width()/2;
					$('.popupWrapperVm').css("margin-left","-"+val+"px");
					$(".popupWrapperVm").animate({
					  "opacity": "show"
					}, 500); 
					add_select();
			  }
        });
           
           
        $('.popupWrapperBGVm').show();
        $('#signin_menuCreate').hide();
        e.preventDefault();
    });
    
	$('.search_text').each(function(){
		if ( $(this).attr("traced")==undefined){
			var name = $(this).attr("name");
			var value = $(this).attr("value");
			var sql_url = $(this).attr("sql");
			var myobj = $(this);
			var width = ($(this).attr("width")==undefined?"200px":$(this).attr("width"));
			var req = ($(this).attr("requerid")==undefined?false:$(this).attr("requerid"));
			var populate = ($(this).attr("populate")==undefined?'':$(this).attr("populate"));
			myobj.attr("traced",1);
			$(this).css('position','relative');
			$(this).append("<input type='hidden' name='"+name+"' value='"+value+"' class='search_text_input_value' />");
			$(this).append("<input type='text' value='' class='search_text_input_text"+(req?" required":"")+"' />");
			
			$(this).children(".search_text_input_text").css("width",width);
			$(this).append("<select class='search_text_select_all' style='position:absolute;top:18px;left:0;width:"+width+";display:none'></select>");
			$(this).append("<select class='search_text_select_filter' style='position:absolute;top:18px;left:0;display:none;width:"+width+"' size='10'></select>");

			$.ajax({url: sql_url,global: false,async:false, type: "POST",data: ({filter : ''}),success: function(response){			
				myobj.children("select").html(response);
				myobj.children("select").val(value);
				if (value!=""){
					var dat = myobj.children(".search_text_select_all").val();
					var tex = myobj.children(".search_text_select_all").children("option:selected").text();
					myobj.children(".search_text_input_text").val(tex);
					myobj.children(".search_text_input_value").val(dat);
					
					var html="";
					myobj.children(".search_text_select_all").children("option").each(function(){
						var tosearch = $(this).html();
						var valx = $(this).html();
						if (tosearch.search(new RegExp(tex, 'gi'))!=-1){
							html+="<option value='"+valx+"'>"+tosearch+"</option>";
						}
					});
					myobj.children(".search_text_select_filter").html(html);
				}else{
					myobj.children(".search_text_input_text").val(populate);
				}
			}});
			$(this).children(".search_text_select_all").change(function(){
				var dat = $(this).val();
				var tex = $(this).children("option:selected").text();
				$(this).parent("div").children(".search_text_input_text").val(tex);
				$(this).parent("div").children(".search_text_input_value").val(dat);			
			});
			$(this).children(".search_text_select_filter").click(function(){
				var dat = $(this).val();
				var tex = $(this).children("option:selected").text();
				$(this).parent("div").children(".search_text_input_text").val(tex);
				$(this).parent("div").children(".search_text_input_value").val(dat);
				$(this).parent("div").attr("value",dat);
				$(this).hide();
			});
			if (populate!=""){
				$(this).children(".search_text_input_text").bind('blur', function() { 
					if ($(this).val()=="") $(this).val($(this).parent("div").attr("populate"));
				});
			}
			$(this).children(".search_text_input_text").click(function() { 
				var sel = $(this).parent("div").children(".search_text_select_filter");
				if (sel.css("display")=="none")	sel.show();else	sel.hide();
				if ($(this).parent("div").attr("populate")!=undefined){
					if ($(this).val()==$(this).parent("div").attr("populate")) $(this).val("");
				}
			});
			$(this).children(".search_text_input_text").bind('keyup', function() { 
				var sel = $(this).parent("div").children(".search_text_select_filter");
				var sel_all = $(this).parent("div").children(".search_text_select_all");
				var sql_url = $(this).parent("div").attr("sql");
				var val = $(this).val();
				var html = "";
				sel.html("");
				sel_all.children("option").each(function(){
					var tosearch = $(this).html();
					var valx = $(this).val();
					if (tosearch.search(new RegExp(val, 'gi'))!=-1){
						html+="<option value='"+valx+"'>"+tosearch+"</option>";
					}
				});
				sel.html(html);
			});
		}
	});
	$.maxZIndex = $.fn.maxZIndex = function(opt) {
		var def = { inc: 10, group: "*" };
		$.extend(def, opt);    
		var zmax = 0;
		$(def.group).each(function() {
			var cur = parseInt($(this).css('z-index'));
			zmax = cur > zmax ? cur : zmax;
		});
		if (!this.jquery)
			return zmax;

		return this.each(function() {
			zmax += def.inc;
			$(this).css("z-index", zmax);
		});
	}
	$('.search_text2').each(function(){
		if ( $(this).attr("traced")==undefined){
			var name = $(this).attr("name");
			var value = $(this).attr("value");
			var sql_url = $(this).attr("sql");
			var myobj = $(this);
			var width = ($(this).attr("width")==undefined?"200px":$(this).attr("width"));
			var height = ($(this).attr("height")==undefined?"20px":$(this).attr("height"));
			var req = ($(this).attr("requerid")==undefined?false:$(this).attr("requerid"));
			var populate = ($(this).attr("populate")==undefined?'':$(this).attr("populate"));
			myobj.attr("traced",1);
			$(this).css('position','relative');
			$(this).append("<input type='hidden' name='"+name+"' value='"+value+"' class='search_text_input_value' />");
			$(this).append("<input type='text' value='' class='search_text_input_text"+(req?" required":"")+"' />");
			
			$(this).children(".search_text_input_text").css("width",width);
			$(this).children(".search_text_input_text").css("height",height);
			$(this).children(".search_text_input_text").css("color","#666681");
			$(this).children(".search_text_input_text").css("font-family","Arial");
			$(this).append("<select class='search_text_select_filter' size='10' style='z-index:2;position:absolute;top:"+height+";left:0;height:100px;width:"+width+";display:none'></select>");
			if (value!=""){					
				$.ajax({url: sql_url,global: false,async:false, type: "POST",data: ({filter : value}),success: function(response){			
					myobj.children("select").html(response);
					myobj.children("select").val(value);
				}});
				var dat = myobj.children(".search_text_select_filter").val(value);
				var tex = myobj.children(".search_text_select_filter").children("option:selected").text();
				myobj.children(".search_text_input_text").val(tex);
				myobj.children(".search_text_input_value").val(dat);

				var html="";
				myobj.children(".search_text_select_all").children("option").each(function(){
					var tosearch = $(this).html();
					var valx = $(this).html();
					if (tosearch.search(new RegExp(tex, 'gi'))!=-1){
						html+="<option value='"+valx+"'>"+tosearch+"</option>";
					}
				});
				myobj.children(".search_text_select_filter").html(html);
			}else{
				myobj.children(".search_text_input_text").val(populate);
			}
			$(this).children(".search_text_select_filter").change(function(){
				var dat = $(this).val();
				var tex = $(this).children("option:selected").text();
				$(this).parent("div").children(".search_text_input_text").val(tex);
				$(this).parent("div").children(".search_text_input_value").val(dat);
				$(this).hide();
			});
			if (populate!=""){
				$(this).children(".search_text_input_text").val(populate);
				$(this).children(".search_text_input_text").bind('blur', function() { 
					if ($(this).val()=="") $(this).val($(this).parent("div").attr("populate"));
				});
			}
			$(this).children(".search_text_input_text").click(function() { 
				var sel = $(this).parent("div").children(".search_text_select_filter");
				if (sel.css("display")=="none")	sel.show();else	sel.hide();
				if ($(this).parent("div").attr("populate")!=undefined){
					if ($(this).val()==$(this).parent("div").attr("populate")) $(this).val("");
				}
			});
			$(this).children(".search_text_input_text").bind('keyup', function() { 
				var sel_all = $(this).parent("div").children(".search_text_select_filter");
				var sql_url = $(this).parent("div").attr("sql");
				var filter_text = $(this).val();
				$.ajax({url: sql_url,global: false,async:false, type: "POST",data: ({filter : filter_text}),success: function(response){sel_all.html(response);}});
			});
		}
	});
	
    $('#contactme').live('click',function(e){
        var first_name1 = $('input[name=first_name]').val();
        var last_name1 = $('input[name=last_name]').val();
        var email1 = $('#emaic').val();
        var Phone1 = $('#Phone').val();
        var comment1 = $('#comecon').val();
		$(".popupWrapperBGVm").fadeTo(10,.8);        
        $.ajax({
            url: "/contactme/form",
            global: false,
            async:false,
            type: "POST",
            data: ({first_name : first_name1, last_name: last_name1, email:email1, Phone:Phone1, comment:comment1, isWp: 'wp'}),
            success: function(response){
                $('.contactme_form').html(response);
				var cssObj = {
				  'background' : '#000000',
				  'display' : 'block',
				  'height' : '100%',
				  'opacity' : ' 0.8',
				  'position' : 'fixed',
				  'width' : '100%',
				  'z-index' : '1'
				}
				$(".popupWrapperBGVm").css(cssObj);				
				var val = $('#xl').width()/2;
				$('#xl').css("margin-left","-"+val+"px");
            }
        });
        
        e.preventDefault();
    });
    
    $('#btnRegPro2').live('click',function(e){
        var first_name1 = $('input[name=first_name]').val();
        var last_name1 = $('input[name=last_name]').val();
        var email1 = $('#emaillearn').val();
        var password1 = $('#passlearn').val();
        var repassword1 = $('#pass2learn').val();
        var findUsx = $('select[name=findUs]').val();
		$(".popupWrapperBGVm").fadeTo(10,.8);        
        $.ajax({
            url: "/users/register2",
            global: false,
            async:false,
            type: "POST",
            data: ({findUs: findUsx, first_name : first_name1, last_name: last_name1, email:email1, password:password1, repassword:repassword1, isWp: 'wp'}),
            success: function(response){
                $('.result_learn').html(response);
				var val = $('#xl').width()/2;
				$('#xl').css("margin-left","-"+val+"px");
            }
        });
        
        e.preventDefault();
    });
    $('#btnRegPro').live('click',function(e){
        var first_name1 = $('input[name=first_name]').val();
        var last_name1 = $('input[name=last_name]').val();
        var email1 = $('input[name=email]').val();
        var password1 = $('input[name=password]').val();
        var repassword1 = $('input[name=repassword]').val();
         var findUsx = $('select[name=findUs]').val();

		 $.ajax({
            url: "/users/register",
            global: false,
            async:false,
            type: "POST",
            data: ({findUs: findUsx, first_name : first_name1, last_name: last_name1, email:email1, password:password1, repassword:repassword1, isWp: 'wp'}),
            success: function(response){
                $('.popupWrapperVm').html(response);
				var val = $('.popupWrapperVm').width()/2;
				$('.popupWrapperVm').css("margin-left","-"+val+"px");
            }
        });
        
        e.preventDefault();
    });
    
	$('.closeButtonVm').live('click',function(e){
		$('.popupWrapperVm').hide();
		$('.popupWrapperBGVm').hide();
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();		
		e.preventDefault();		
	});
	$('.closeButtonVm2').live('click',function(e){
		$('.popupWrapperVm').hide();
		$('.popupWrapperBGVm').hide();
		document.location=$(this).attr("href");
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();		
		e.preventDefault();		
	});
	$('.closeButtonVmFromAjax').live('click',function(e){
		$('.popupWrapperVm').hide();
		$('.popupWrapperBGVm').hide();
		document.location=$(this).attr("href");
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();		
		e.preventDefault();		
	});
    /************************IMAGES PROFILE***************************/
 
	$(".thumb_change").each(function(){
		$(this).mouseover(function() {
			if ($(this).attr("sel")!=1)
				$(this).fadeTo(100,.5);
		});
		$(this).mouseout(function() {
			if ($(this).attr("sel")!=1)
				$(this).fadeTo(100,1);
		});
		$(this).click(function(){
			var to = $($(this).attr("to"));
			var img = $(this).attr("alt");
			if ($.trim(img)=="") img = $(this).attr("size2");
			if ($.trim(to.attr("src"))!=$.trim(img)){
				to.fadeTo(1,0);
				to.attr("src",img)
				$(".thumb_change").fadeTo(1,1);
				$(".thumb_change").attr("sel",0);
				$(this).fadeTo(1,.3);
				$(this).attr("sel",1);			
				to.load(function(){
					
					add_move_images_profile();
					$(this).fadeTo(400,1);
				});
			}
		});
	});
	$("#bioPhotos div img").load(function(){
		add_move_images_profile();
	});
	add_move_images_profile();
	add_select();	
});		
	function add_select(){
		$(".add_other").each(function(){
			$(this).append("<option value='other' class='other'>Other</option>");
			if ($(this).attr("id")==""){
				$(this).attr("id",String(Math.random()).substr(2,7));
			}
			$(this).before("<input type='text' id='"+$(this).attr("id")+"_other' value='' style='display:none' />");
			$(this).change(function(){
				if ($(this).val()=="other"){
					$("#"+$(this).attr("id")+"_other").show();
					$("#"+$(this).attr("id")+"_other").keyup(function(){
						var obj = $(this).attr("id").substr(0,$(this).attr("id").search("_other"));
						var str = $(this).val();
						$("#"+obj+" .other").attr("value",str);
					});
				}else{
					$("#"+$(this).attr("id")+"_other").hide();
				}
			});

		});	
	}
	function add_move_images_profile(){
		$("#bioPhotos div img").each(function(){
			var height = $(this).parent("div").height();
			var width = $(this).parent("div").width();
			var movearea = 60;
			var extra_height = (($(this).height()-height)<=0?0:($(this).height()-height));
			var extra_width = (($(this).width()-width)<=0?0:($(this).width()-width));
			
			var centerx = ((width/2)-($(this).width()/2));
			var centery = ((height/2)-($(this).height()/2));
			$(this).css("left",centerx+"px");
			$(this).css("top",centery+"px");
			$(this).mousemove(function(event) {
				var p = $(this);
				var position = p.position();

				var p2 = $(this).parent("div");
				var offset = p2.offset();
				
				if (extra_width>0){
					var posx = event.clientX-offset.left;
					if (posx>(width-movearea)){
						if (($(this).width()+position.left)>width){
							$(this).css("left",(position.left-1)+"px");
						}
					}
					if (posx<(movearea)){
						if (position.left<0){
							$(this).css("left",(position.left+1)+"px");
						}
					}
				
				}
				if (extra_height>0){
					var posy = event.clientY-offset.top;
					if (posy>(height-movearea)){
						if (($(this).height()+position.top)>height){
							$(this).css("top",(position.top-2)+"px");
						}
					}
					if (posy<(movearea)){
						if (position.top<0){
							$(this).css("top",(position.top+2)+"px");
						}
					}
				}
			});
		});
	
	}
	function addaction(obj,myurl,id){
		obj.live('click',function(e){
			var dats = '';
			$("#mypopup form input, #mypopup form textarea, #mypopup form select").each(function(i){
				if ($(this).attr("name")!="" && $(this).attr("name")!=undefined){
					dats+=(dats!=''?'&':'')+$(this).attr("name")+'='+$(this).attr("value");
				}
			});
			$.ajax({
				url: myurl,
				global: false,
				async:false,
				type: "POST",
				data: dats,
				success: function(response){
					$('.'+id).html(response);
					$('.'+id).attr("id","");
				}
			});
			
			e.preventDefault();
		});
	}	
	function showpopup(url){
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();
		$("#mypopup input[type=image]").remove();
		var idobj = "id"+String(Math.random()).substr(2,7);
		$("body").prepend('<div class="popupWrapperVm '+idobj+'" id="mypopup" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
		var cssObj = {
		  'background' : '#000000',
		  'display' : 'block',
		  'height' : '100%',
		  'opacity' : ' 0.8',
		  'position' : 'fixed',
		  'width' : '100%',
		  'z-index' : '1'
		}
		$(".popupWrapperBGVm").css(cssObj);
		$(".popupWrapperBGVm").fadeTo(10,.8);
		$.ajax({
			  url: url,
			  global: false,
			  async:false,
			  success: function(response){
					$('.'+idobj).html(response);
					var val = $('.'+idobj).width()/2;
					$('.'+idobj).css("margin-left","-"+val+"px");
					$('.'+idobj+' input[type=image]').attr("id","");
					addaction($('.'+idobj+' input[type=image]'),url,idobj);
					$(".popupWrapperVm").animate({
					  "opacity": "show"
					}, 500);         
			  }
        });
           
           
        $('#mypopup').show();
    
		
	}
	function showpopup_transparent(url){
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();
		$("#mypopup input[type=image]").remove();

		var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){
			   if($(e).css('position')=='absolute')
					return parseInt($(e).css('z-index'))||1 ;
			   })
		);

		var idobj = "id"+String(Math.random()).substr(2,7);
		$("body").prepend('<div class="popupWrapperVm '+idobj+'" id="mypopup" style="display:none;background:none;border:none;top:150px"></div><div class="popupWrapperBGVm"></div>');
		var cssObj = {
		  'background' : '#000000',
		  'display' : 'block',
		  'height' : '100%',
		  'opacity' : ' 0.8',
		  'position' : 'fixed',
		  'width' : '100%',
		  'z-index' : (maxZ+1)
		}
		$(".popupWrapperVm").css("z-index",(maxZ+2));
		$(".popupWrapperBGVm").css(cssObj);
		$(".popupWrapperBGVm").fadeTo(10,.8);
		$.ajax({
			  url: url,
			  global: false,
			  async:false,
			  success: function(response){
					$('.'+idobj).html(response);
					var val = $('.'+idobj).width()/2;
					$('.'+idobj).css("margin-left","-"+val+"px");
					$('.'+idobj+' input[type=image]').attr("id","");
					addaction($('.'+idobj+' input[type=image]'),url,idobj);
					$(".popupWrapperVm").animate({
					  "opacity": "show"
					}, 500);         
			  }
        });
           
           
        $('#mypopup').show();
    
		
	}
	function messagepopu(mess){
        $(".popupWrapperBGVm").remove();
		$(".popupWrapperVm").remove();
		$("#mypopup").remove();
		$("#mypopup input[type=image]").remove();
		var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){
			   if($(e).css('position')=='absolute')
					return parseInt($(e).css('z-index'))||1 ;
			   })
		);
		var idobj = "id"+String(Math.random()).substr(2,7);
		$("body").prepend('<div class="popupWrapperVm '+idobj+'" id="mypopup" style="display:none;"></div><div class="popupWrapperBGVm"></div>');
		var cssObj = {
		  'background' : '#000000',
		  'display' : 'block',
		  'height' : '100%',
		  'opacity' : ' 0.8',
		  'position' : 'fixed',
		  'width' : '100%',
		  'z-index' : (maxZ+1)
		}
		$(".popupWrapperVm").css("z-index",(maxZ+2));
		$(".popupWrapperBGVm").css(cssObj);
		$(".popupWrapperBGVm").fadeTo(10,.8);
		$('.'+idobj).html(mess);
        $('#mypopup').show();	
	}
	function search_change(obj,value){
		var myobj = $(obj);
		myobj.children(".search_text_select_all").val(value);
		var dat = myobj.children(".search_text_select_all").val();
		var tex = myobj.children(".search_text_select_all").children("option:selected").text();
		myobj.children(".search_text_input_text").val(tex);
		myobj.children(".search_text_input_value").val(dat);
		myobj.attr("value",dat);
		var html="";
		myobj.children(".search_text_select_all").children("option").each(function(){
			var tosearch = $(this).html();
			var valx = $(this).val();
			if (tosearch.search(new RegExp(tex, 'gi'))!=-1){
				html+="<option value='"+valx+"'>"+tosearch+"</option>";
			}
		});
		myobj.children(".search_text_select_filter").html(html);
	}

