// JavaScript Document
function trim(str, chars){
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars){
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars){
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function onlyShow(divId)
{
	document.getElementById(divId).style.display='';
}

function onlyHide(divId)
{
	document.getElementById(divId).style.display='none';
}
function slideDown(divID)
{
	$('#'+divID).slideDown();
}
function slideUp(divID)
{
	$('#'+divID).slideUp();
}

function toggleDivImg(sender,divID)
{
	if(document.getElementById(divID).style.display=='none')
	{
		$('#'+divID).slideDown();
		$(sender).children('h6').children('img').attr('src','images/circ-ar-down.png');
	}
	else
	{
		$('#'+divID).slideUp();
		$(sender).children('h6').children('img').attr('src','images/circ-ar-up.png');
	}
	
}

function initCheck()
{
	
	$('div.cbox').unbind('click');
			$('div.cbox').bind("click", function () {

			
			if ($(this).attr('class') == 'cbox') {
				//This id is used on item rent confimation Page and this condition is used for tems and condition checkbox 
				if($(this).attr('id')=='cbox_rent_id')
				{
					document.getElementById('cbox_rent_checkbox').value = 1;	
				}
				if($(this).attr('id')=='cbox_rent_acc')
				{
					document.getElementById('cbox_rent_stuff').value = 1;	
				}
			$(this).children('input').attr('checked', true);
			$(this).removeClass().addClass('cbox-selected');
			$(this).children('input').trigger('change');
			//
		}
		else { 
			if($(this).children('input').attr('id')!='contactEsymbeeMsg')
			{
				//This id is used on item rent confimation Page and this condition is used for tems and condition checkbox 
				if($(this).attr('id')=='cbox_rent_id')
				{
					document.getElementById('cbox_rent_checkbox').value = 0;
				}
				if($(this).attr('id')=='cbox_rent_acc')
				{
					document.getElementById('cbox_rent_stuff').value = 0;	
				}

				$(this).children('input').attr('checked', false);
				$(this).removeClass().addClass('cbox');
				$(this).children('input').trigger('change');
			}
		}
				

	});	
}
		
		$('.c-mid ul li a').bind("mouseenter",function()
		{
			$(this).parent().stop().animate({marginLeft:5});
		});
		$('.c-mid ul li a').bind("mouseleave",function()
		{
			$(this).parent().stop().animate({marginLeft:0});
		});
		
		$('a.tooltipLink').bind("mouseenter",function()
		{
			 
			$('#toolContent').html($(this).attr('rel'));
			$('.grayTip').css({top:$(this).offset().top+$(this).height(),left:$(this).offset().left-10});
			$('.grayTip').show();
		});
		
		$('a.tooltipLink').bind("mouseleave",function()
		{
			$('.grayTip').hide();
		});
		
		$('a.showRating').bind("mouseenter",function()
		{
			$('.rating').css({top:$(this).offset().top+$(this).height()+8,left:$(this).offset().left-15});
			$('.rating').show();
		});
		$('a.showRating').bind("mouseleave",function()
		{
			$('.rating').hide();
		});
		var cUserTimer;
		$('a.contact-Link').bind("mouseenter",function()
		{
			if(cUserTimer)
			clearTimeout(cUserTimer);
			$('.contactTooltip').css({top:$(this).offset().top+$(this).height()-$('.contactTooltip').height()-12,left:$(this).offset().left-$('.contactTooltip').width()-35});
			$('.contactTooltip').show();
		});
		$('a.contact-Link').bind("mouseleave",function()
		{
			cUserTimer=setTimeout(function(){$('.contactTooltip').hide()},1000);
		});
		$('.contactTooltip').bind("mouseenter",function()
		{
			if(cUserTimer)
			clearTimeout(cUserTimer);
		});
		$('.contactTooltip').bind("mouseleave",function()
		{
			$(this).hide();
		});
		
		
		
		//Added by ghanshyam on 10 feb 11
		
			$(function(){
					   
				 
					   
		 // RESET THE VALUES INSIDE THE PAGE ON LOADING
		 //$('.overlayField').val('');
		 // FADEOUT LABEL ON CLICK ON THE TEXT FIELD or THE OVERLAY LABEL fo rpassword field
		 $('.overlayField, .overlayLabelp').focusin(function(){
		  $(this).parent().find('.overlayLabelp').fadeOut();
		  $(this).parent().find('.overlayField').focus();
		 });
		 
		 $('.overlayField, .overlayLabellgbx').focusin(function(){
																
		  $(this).parent().find('.overlayLabellgbx').fadeOut();
		  $(this).parent().find('.overlayField').focus();
		 });
		 
		 $('.overlayField, .overlayLabelps').focusin(function(){
		  $(this).parent().find('.overlayLabelps').fadeOut();
		  $(this).parent().find('.overlayField').focus();
		 });
		 
		  $('.overlayField, .overlayLabellg').focusin(function(){
															//   alert(777777);
		  $(this).parent().find('.overlayLabellg').fadeOut();
		  $(this).parent().find('.overlayField').focus();
		 });
		  
		   $('.overlayField, .overlayLabellhg').focusin(function(){
		  $(this).parent().find('.overlayLabellhg').fadeOut();
		  $(this).parent().find('.overlayField').focus();
		 });

		 // ON FOCUS OUT FROM THE LABELS BRING THE TEXT BACK retype password
		 $('.overlayField').focusout(function(){
		 
		 // if( $('.overlayField').val() == '') { //alert($('#password').val());
		  	if($('#password').val()=="") 
			{	
				$(this).parent().find('.overlayLabelp').fadeIn();
		   }
		   
		   if($('#password_confirmation').val()=='')
		   {
		     $(this).parent().find('.overlayLabelps').fadeIn();
		   }
		
		    if($('#loginPassword').val()=='')
		   {
			  
				$(this).parent().find('.overlayLabellhg').fadeIn();
		   }
		   
		   //for popup page login
		     if($('#loginpwd').val()=='')
		   {
			 
			  	$(this).parent().find('.overlayLabellg').fadeIn();
				
		   }
		     if($('#password_box').val()=='')
		   {
			 
			  	$(this).parent().find('.overlayLabellgbx').fadeIn();
				
		   }
			
		 }); 
		});   
		
			
			//watermark function
			$(function(){
			 // RESET THE VALUES INSIDE THE PAGE ON LOADING
			 //$('.overlayField').val('');
			 // FADEOUT LABEL ON CLICK ON THE TEXT FIELD or THE OVERLAY LABEL
			 $('.overlayField, .overlayLabel').bind('focus', function(){

					$(this).parent().find('.overlayLabel').fadeOut();

			  //	$(this).parent().find('.overlayField').focus();
			 });
			 // ON FOCUS OUT FROM THE LABELS BRING THE TEXT BACK
			/* $('.overlayField').focusout(function(){
				if( $(this).val() == '') {
				$(this).parent().find('.overlayLabel').fadeIn();
			  }
			 });*/ 
			});

 //01 search result page drop down select menu -
 $('.select-menu-01').bind("click",function()
	{
		if(!$('.miles-dropdown').is(':visible'))
		{
			$('.miles-dropdown').css({top:$(this).offset().top+$(this).height()+2,left:$(this).offset().left-6});
			$('.miles-dropdown').show();
		}
		else 
		{
			$('.miles-dropdown').hide();
		}
	});
 //dollar 5 tooltip code -
/* $('.drop-circle').bind("click",function()
	{
		if(!$('.dollar5-main').is(':visible'))
		{
			$('.dollar5-main').css({top:$(this).offset().top+$(this).height()+4,left:$(this).offset().left-33});
			$('.dollar5-main').show();
		}
		else 
		{
			$('.dollar5-main').hide();
		}
		$('.dollar5-main').bind("mouseleave",function()
		{
			$('.dollar5-main').hide();
		});
	});*/



// accordion script 
$(document).ready(function()
{
	
		
					$('.tab-log-ul li a').bind("click",function()
 {
  $(this).parent().parent().children().children('a').removeClass('active');
  $(this).addClass('active');
  $('#communication-tab, #dispute-log-tab').hide();
  $('#'+$(this).attr('rel')).fadeIn();
 });	


			/*if($('#loginpwd').val()!='')
		   {   alert(3333333333333);
			  $(this).parent().find('.overlayLabellg').fadeOut();
		      $(this).parent().find('.overlayField').focus();
				
		   }*/
	/*Code added by ghanshyam sharma on 10 feb 11 for new dropdown*/
	/*For Custom Dropdown Link */
	/*$('.dropright').bind("click",function()
	{
		var ddID=$(this).attr('title');
		$('#'+ddID).css({top:$(this).offset().top+37,left:$(this).offset().left-5});
		if($('#'+ddID).is(':visible'))
		$('#'+ddID).slideUp();
		else
		$('#'+ddID).slideDown("fast");
	});
	$('#radiusDD').bind("mouseleave",function()
	{
		$(this).slideUp();
	});
	
	$('.dropdown-blue ul li a').bind("click",function()
	{
		$('#'+$(this).attr('title')).html($(this).html());
		$(this).parent().parent().parent().hide();
	});*/
	/*Code ended here*/
	
	
	
	$('.accor-head').bind("click",function()
	{
		if($(this).next().is(':visible'))
		{
			$(this).next().slideUp();
			//$(this).children('a.accordion-close').children('img').attr('src','../admin/images/accordion-close.png');
			$(this).children('div.accor-mid').children('img').attr('src','images/grey-triangle.png');
		}
		else
		{
			$(this).next().slideDown();
			$(this).children('a.accordion-close').children('img').attr('src','../admin/images/accordion-open.png');
			$(this).children('div.accor-mid').children('img').attr('src','images/grey-triangle-up.png');
		}
	});
	$('a.tab').bind("click",function()
	{
		$(this).parent().children('a').removeClass('active');
		$(this).addClass('active');
		$('#photo,#video').hide();
		$('#'+$(this).attr('rel')).fadeIn();
	});
	
	
	
	
});

function resetCheckBox()
{
	
	$('div.cbox').unbind('click');
			$('div.cbox').bind("click", function () {

		
			if ($(this).attr('class') == 'cbox') {
			$(this).children('input').attr('checked', true);
			$(this).removeClass().addClass('cbox-selected');
			$(this).children('input').trigger('change');
		}
		else {
			if($(this).children('input').attr('id')!='contactEsymbeeMsg')
			{
				$(this).children('input').attr('checked', false);
				$(this).removeClass().addClass('cbox');
				$(this).children('input').trigger('change');
			}
		}
				

	});
}

var subClear;
$(document).ready(function()
{
	initSubCat();
	disptip();
});

function initSubCat()
{

	$('.subCat').bind("mouseenter",function()
	{
		//alert('a');
		if(subClear)
			clearTimeout(subClear);
		$('.subCatContent').fadeIn();
		$('.subCatContent').offset({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('.subCat').bind("mouseleave",function()
	{
		subClear=setTimeout(function(){$('.subCatContent').fadeOut();},100);
	});
	$('.subCatContent').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.subCatContent').bind("mouseleave",function()
	{
		$('.subCatContent').fadeOut();
	});
	
	//code for tooltip gtalk
	$('a.gtalk').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolgtalk').fadeIn();
		$('.toolgtalk').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.gtalk').bind("mouseleave",function()
	{
		$('.toolgtalk').hide();
		//subClear=setTimeout(function(){$('.toolgtalk').fadeOut();},100);
	});
	$('.toolgtalk').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolgtalk').bind("mouseleave",function()
	{
		//$('.toolgtalk').fadeOut();
		$('.toolgtalk').hide();
	});
	
	//code for tooltip aim
	$('a.aim').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolaim').fadeIn();
		$('.toolaim').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.aim').bind("mouseleave",function()
	{
		$('.toolaim').hide();
		//subClear=setTimeout(function(){$('.toolaim').fadeOut();},100);
	});
	$('.toolaim').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolaim').bind("mouseleave",function()
	{
		//$('.toolaim').fadeOut();
		$('.toolaim').hide();
	});
	//code for tooltip skype
	$('a.skype').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolskype').fadeIn();
		$('.toolskype').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.skype').bind("mouseleave",function()
	{
		$('.toolskype').hide();
		//subClear=setTimeout(function(){$('.toolskype').fadeOut();},100);
	});
	$('.toolskype').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolskype').bind("mouseleave",function()
	{
		//$('.toolskype').fadeOut();
		$('.toolskype').hide();
	});
	//code for tooltip twitter
	$('a.twitter').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.tooltwitter').fadeIn();
		$('.tooltwitter').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.twitter').bind("mouseleave",function()
	{
		$('.tooltwitter').hide();
		//subClear=setTimeout(function(){$('.tooltwitter').fadeOut();},100);
	});
	$('.tooltwitter').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.tooltwitter').bind("mouseleave",function()
	{
		$('.tooltwitter').hide();
		//$('.tooltwitter').fadeOut();
	});
	//code for tooltip phone
	$('a.phone').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolphone').fadeIn();
		$('.toolphone').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.phone').bind("mouseleave",function()
	{
		$('.toolphone').hide();
		//subClear=setTimeout(function(){$('.toolphone').fadeOut();},100);
	});
	$('.toolphone').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolphone').bind("mouseleave",function()
	{
		$('.toolphone').hide();
		//$('.toolphone').fadeOut();
	});
	//code for tooltip yahoo
	$('a.yahoo').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolyahoo').fadeIn();
		$('.toolyahoo').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.yahoo').bind("mouseleave",function()
	{
		$('.toolyahoo').hide();
		//subClear=setTimeout(function(){$('.toolyahoo').fadeOut();},100);
	});
	$('.toolyahoo').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolyahoo').bind("mouseleave",function()
	{
		$('.toolyahoo').hide();
		//$('.toolyahoo').fadeOut();
	});
	//code for tooltip winllive
	$('a.winlive').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolwinlive').fadeIn();
		$('.toolwinlive').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.winlive').bind("mouseleave",function()
	{
		$('.toolwinlive').hide();
		//subClear=setTimeout(function(){$('.toolwinllive').fadeOut();},100);
	});
	$('.toolwinlive').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolwinlive').bind("mouseleave",function()
	{
		$('.toolwinlive').hide();
		//$('.toolwinllive').fadeOut();
	});
	
	
	//code for tooltip Esymbee mesage
	$('a.esymsg').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolesy').fadeIn();
		$('.toolesy').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.esymsg').bind("mouseleave",function()
	{
		subClear=setTimeout(function(){$('.toolesy').fadeOut();},100);
	});
	$('.toolesy').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolesy').bind("mouseleave",function()
	{
		$('.toolesy').fadeOut();
	});
	
	//code for tooltip Item Description
	$('a.itmcnd').bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('.toolitemdescription').fadeIn();
		$('.toolitemdescription').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('a.itmcnd').bind("mouseleave",function()
	{
		subClear=setTimeout(function(){$('.toolitemdescription').fadeOut();},100);
	});
	$('.toolitemdescription').bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	$('.toolitemdescription').bind("mouseleave",function()
	{
		$('.toolitemdescription').fadeOut();
	});
	
	
}


var subClear1;
$(document).ready(function()
{
	//alert('hell');
	$('.subCat1').bind("mouseenter",function()
	{
		
		if(subClear1)
		clearTimeout(subClear1);
		$('.subCatContent1').fadeIn();
		$('.subCatContent1').css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});
	$('.subCat1').bind("mouseleave",function()
	{
		subClear1=setTimeout(function(){$('.subCatContent1').fadeOut();},100);
	});
	$('.subCatContent1').bind("mouseenter",function()
	{
		if(subClear1)
		clearTimeout(subClear1);
	});
	$('.subCatContent1').bind("mouseleave",function()
	{
		$('.subCatContent1').fadeOut();
	});
	
});

function showVideoSource(obj)
{
	if(obj.checked)
	{   
	
		$("#videoRedioBtnUpload").show();
		$("#videoUploadText").show();
		$("#videoRedioBtnEmbed").show();
		$("#videoEmbedText").show();
		$("#youtubeLogo").show();
		if($('itemVideo').is(':checked'))
		{
	   		//alert('fasle');
			$("#showUploadVideo").fadeOut(1000);
		}
		else
		{
		  	//alert('else');
			$("#showUploadVideo").fadeIn(1000);
		}
		
	}
	else
	{
		$("#showUploadVideo").fadeOut(1000);
		$("#videoRedioBtnUpload").fadeOut(1000);
		$("#videoUploadText").fadeOut(1000);
		$("#videoRedioBtnEmbed").fadeOut(1000);
		$("#videoEmbedText").fadeOut(1000);
		$("#youtubeLogo").fadeOut(1000);
		$("#showEmbedVideo").fadeOut(1000);	
	}
		
}

function showPicker(obj,check)
{
	$obj = $("#" + obj);
	if(check==1){ 
    	if(document.getElementById(obj).disabled==false){
    		$obj.datepicker( "show" );	
    	}
    	else
    		return false;
	}
	else if(!$obj.datepicker("isDisabled"))
	{
		$obj.datepicker( "show" );
	}
}


// Network page : User Degree show 
$(document).ready(function()
{
	$('.user-floating').bind("mouseenter",function()
	{
		$(this).children().find('.userOneD').css({"visibility":"visible"});
	});
	$('.user-floating').bind("mouseleave",function()
	{
		$(this).children().find('.userOneD').css({"visibility":"hidden"});
	});
});
// Network page user 
$(document).ready(function()
{
	$('.user-floating').bind("mouseenter",function()
	{
		$(this).children().find('.hidden').css({"visibility":"visible"});
	});
	$('.user-floating').bind("mouseleave",function()
	{
		$(this).children().find('.hidden').css({"visibility":"hidden"});
	});
});


$(document).ready(function()
{
	$('#fade').bind("click",function()
	{
		$('#network-popup-main').hide();
	});
	
	
});


/*New drop down code*/
//select type dropdown menu start he
$(document).ready(function()
 {
	/*For Custom Dropdown Link */
	$('.dropright').bind("click",function()
	{
		var ddID=$(this).attr('title');
		$('#'+ddID).css({top:$(this).offset().top+37,left:$(this).offset().left-5});
		if($('#'+ddID).is(':visible'))
		$('#'+ddID).slideUp();
		else
		$('#'+ddID).slideDown("fast");
	});
	$('#radiusDD').bind("mouseleave",function()
	{
		$(this).slideUp();
	});
	
	$('.dropdown-blue ul li a').bind("click",function()
	{
		$('#'+$(this).attr('title')).html($(this).html());
		$(this).parent().parent().parent().hide();
	});
});
/*------------------------------*/

//select type dropdown menu end here
var borrowTimer;
var offerTimer;
$(document).ready(function()
{
	$('#borrowCar').bind("mouseenter",function()
	{
		if(borrowTimer)
		clearTimeout(borrowTimer);
		$('#borrowhover').css({left:$(this).offset().left-100,top:$(this).offset().top+55});
		$('#borrowhover').show();
	});
	$('#borrowCar').bind("mouseleave",function()
	{
		borrowTimer=setTimeout(function(){$('#borrowhover').hide();});
	});
	$('#borrowhover').bind("mouseenter",function()
	{
		$('#borrowCar').addClass('active');
		if(borrowTimer)
		clearTimeout(borrowTimer);
	});
	$('#borrowhover').bind("mouseleave",function()
	{
		$(this).hide();
		$('#borrowCar').removeClass('active');
	});
	
	/*----------------------------*/
	
	$('#offerCar').bind("mouseenter",function()
	{
		if(offerTimer)
		clearTimeout(offerTimer);
		$('#offerhover').css({left:$(this).offset().left-585,top:$(this).offset().top+55});
		$('#offerhover').show();
	});
	$('#offerCar').bind("mouseleave",function()
	{
		offerTimer=setTimeout(function(){$('#offerhover').hide();});
	});
	$('#offerhover').bind("mouseenter",function()
	{
		$('#offerCar').addClass('active');
		if(offerTimer)
		clearTimeout(offerTimer);
	});
	$('#offerhover').bind("mouseleave",function()
	{
		$(this).hide();
		$('#offerCar').removeClass('active');
	});
});
/*--------------------------------*/
$(document).ready(function()
{
	$('#advanceBtn').bind("click",function()
	{
		if(!$('div#hiddenAdvance').is(':visible'))
		{
			$('#hiddenAdvance').slideDown("fast");
			$(this).addClass('advanceup');
		}
		else
		{
			$('#hiddenAdvance').slideUp();
			$(this).removeClass('advanceup');
		}
	});
});
//onclick="$('#divId').slideToggle();"
/*equal column js starts here */
function fixH(one,two) {
 if (document.getElementById(one)) {
 var lh=document.getElementById(one).offsetHeight;
 var rh=document.getElementById(two).offsetHeight;
 var nh = Math.max(lh, rh);
 document.getElementById(one).style.height=nh+"px";
 document.getElementById(two).style.height=nh+"px";
 }
}
/*--------------------*/
function fixmH(one,two) {
 if (document.getElementById(one)) {
 var lhm=document.getElementById(one).offsetHeight;
 var rhm=document.getElementById(two).offsetHeight;
 var nhm= Math.max(lhm, rhm);
 document.getElementById(one).style.height=nhm+"px";
 document.getElementById(two).style.height=nhm+"px";
 }
}
window.onload=function(){
fixmH('lrleft','lrright');
fixH('leftpanel','rightpanel');
} 
/*equal column js end here */
/*custom checkbox and radio button js */
jQuery.fn.customInput = function(){
	$(this).each(function(i){	
		if($(this).is('[type=checkbox],[type=radio]')){
			var input = $(this);
			
			// get the associated label using the input's id
			var label = $('label[for='+input.attr('id')+']');
			
			//get type, for classname suffix 
			var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio';
			
			// wrap the input + label in a div 
			$('<div class="custom-'+ inputType +'"></div>').insertBefore(input).append(input, label);
			
			// find all inputs in this set using the shared name attribute
			var allInputs = $('input[name='+input.attr('name')+']');
			
			// necessary for browsers that don't support the :hover pseudo class on labels
			label.hover(
				function(){ 
					$(this).addClass('hover'); 
					if(inputType == 'checkbox' && input.is(':checked')){ 
						$(this).addClass('checkedHover'); 
					} 
				},
				function(){ $(this).removeClass('hover checkedHover'); }
			);
			
			//bind custom event, trigger it, bind click,focus,blur events					
			input.bind('updateState', function(){	
				if (input.is(':checked')) {
					if (input.is(':radio')) {				
						allInputs.each(function(){
							$('label[for='+$(this).attr('id')+']').removeClass('checked');
						});		
					};
					label.addClass('checked');
				}
				else { label.removeClass('checked checkedHover checkedFocus'); }
										
			})
			.trigger('updateState')
			.click(function(){ 
				$(this).trigger('updateState'); 
			})
			.focus(function(){ 
				label.addClass('focus'); 
				if(inputType == 'checkbox' && input.is(':checked')){ 
					$(this).addClass('checkedFocus'); 
				} 
			})
			.blur(function(){ label.removeClass('focus checkedFocus'); });
		}
	});
};
/*--------------*/
/*input tooltip jquery*/
$(document).ready(function()
{
	$('#nameCar').bind("mouseenter",function()
	{
		$('#inputTip').css({left:$(this).offset().left+$(this).width()+30,top:$(this).offset().top+$(this).height()-20}).show();
	});
	$('#nameCar').bind("mouseleave",function()
	{
		$('#inputTip').hide();
	});
});
/*-------------Generic Page Image Gallery ------------*/
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 200;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl"></span>')
    .append('<span class="control" id="rightControl"></span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
});
/*-------------Generic Page Image Gallery ------------*/
/*my neighborhood tooltip igreen*/
$(document).ready(function()
{
	$('.igreen').bind("mouseenter",function()
	{
		$('#inputTip').css({left:$(this).offset().left+$(this).width()+10,top:$(this).offset().top+$(this).height()-32}).show();
	});
	$('.igreen').bind("mouseleave",function()
	{
		$('#inputTip').css({left:$(this).offset().left+$(this).width()+10,top:$(this).offset().top+$(this).height()-32}).hide();
	});
});
/*Set Tab for Left Menu */
function setLnb(index)
{
 var allLinks=$('#leftmenubar').children('li').children('a');
 allLinks.removeClass('active');
 $(allLinks[index-1]).addClass('active');
}
function setTnb(index)
{
 var allLinks=$('#menubar').children('li').children('a');
 allLinks.removeClass('active');
 $(allLinks[index-1]).addClass('active');
}
//faq jquery --
$(document).ready(function()
	{
		$('.question').bind("click",function()
		{
			if (!$(this).next().is(":visible"))
			{
				$(this).next().slideDown();
				$(this).css({"border-bottom":"none"});
			}
			else {
				$(this).next().slideUp();
				$(this).css({"border-bottom":"dotted 1px #ccc"});
			}
		});
		
	});

/*select type dropdown menu jquery */


function isValidCityZip()
{
	var url=site_url+"search/isValidCityZip/";

	var data="cityOrZip="+$("#city_zip_change_input").val();
	$.ajax({
				type: "POST",
				url: url ,
				data: data,
				success: function(msg){
				
				if (msg==1)
				{
					$("#city_zip_change_error").show();
				}
				else
				{
						$("#zipCode").val(msg);
						$("#city_zip_change_form").submit();
				}
				//document.getElementById("span_states").innerHTML=msg;
				
			}
		});
}


function searchwithfiltersort()//filter
{
	var_count=0;
	$("#current_item_count").val(10);
	var filterform=$('form').serialize()+'&page_type='+$('#page_type').val();
	
	
	var ord=document.getElementById("orderby").value;
	//alert(filterform);
	var sortorder;
	if(ord=='is_pirce_negotiable')
	{
		sortorder='Negotiable';

	}
	if(ord=='is_purchaseable')
	{
		sortorder='Purchased';

	}
	if(ord=='is_collateral')
	{
		sortorder='Collateral';

	}
	if(ord=='is_shippable')
	{
		sortorder='Shippable';

	}
	if(ord=='rental_agreement')
	{
		sortorder='Rental Agreement';

	}

	if(ord=='distance')
	{
		sortorder='Distance';

	}

	if(ord=='None')
	{
		sortorder='Recently Posted';

	}
	
	if(ord=='is_high_light')
	{
		sortorder='Default';

	}
	if(ord=='item_price_dailyl')
	{
		sortorder='Price (Low-High)';

	}
	if(ord=='item_price_dailyh')
	{
		sortorder='Price (High-Low)';

	}
	//alert(sortorder);


	 var n = $("input:checked").length;

	 //alert(n);
	//Condition for checkboxes fo subcategory
	var check;
	var flag=false;
	for (var counter = 1; counter<=all_cat_count; counter++)
	{
		 check = $("#ul_"+counter+" .checkeOrUnchecked:checked").length;
		 if (check==0)
		 {
			 $("#ul_"+counter+" input[type='checkbox']:first").attr('checked', false);
			 $("#ul_"+counter+" input[type='checkbox']:first").parent().removeClass();
			  $("#ul_"+counter+" input[type='checkbox']:first").parent().addClass('cbox');	
		 }
		 else
		{
			 flag=true;
			 $("#ul_"+counter+" input[type='checkbox']:first").attr('checked', true);
			 $("#ul_"+counter+" input[type='checkbox']:first").parent().removeClass();			 
			 $("#ul_"+counter+" input[type='checkbox']:first").parent().addClass('cbox cbox-selected');	
				 
		}
	}
	if (flag)
	{
		$("#left_panel_filter_span").show();
	}
	else
	{
		$("#left_panel_filter_span").hide();
	}

	var cond_check = $("input[name=itemCondition[]]:checked").length;
	if($('#page_type').val()==1)
			{
				var cond_check=1;
			}
	if(n>0 && cond_check>0)
	{

			$("#right-pan").mask("Loading...",0,150,25);
			$("#unsortvalues").mask("Loading...",0,150,25);
			var url=site_url+"search/searchWithin/";

				$.ajax({
			   type: "post",
			   url: url,
			   data: filterform,
			   success: function(data){
				   
			   //alert(data);
			 // document.getElementById("unsortvalues").style.display='none';commented on 6/6/2011 By Rishi
				$('#unsortvalues').hide();
				//$(this).children('div.unsortvalues').attr({'visibility':'hidden'});

				$('#right-pan').html(data);
				$('#srt').html(sortorder);
				
				$("#right-pan").unmask();
				}
			});
	}
	else
	{
				
				$("#distanceOnNoResult").val($("#distance").val());
				$('#right-pan').hide();
				$('#unsortvalues').show();
				$("#unsortvalues").unmask();
				$("#right-pan").unmask();
				
	}
}


//This functuion is used to update Rating of Object
function rateItem(vote,id_num,divid)
{
	var url = 'items/updateVote'; 
	var data = 'vote='+vote+'&id_num='+id_num;
	var theUL = document.getElementById('unit_ul'+id_num); // the UL
//	alert(site_url+''+url);
	
	
	$.ajax({
			url : site_url+''+url, // your ajax file
			type : 'post',
			data : data,
			asynchronous: false,
			success : function(resp)
			{
				$("#"+divid).html(resp);
				
			}
		
		});


}


//This function add reviews wohile clicking on Submit button button
 function addReview(item_id)
 {    
	 
	 
	 var val = document.getElementById('review').value;
	 if(val=='Comments: Describe the transaction experience. example: Great lender.  On time and very easy to rent from.  Great overall experience.')
	 {
		val='';
	 }
	
	 var pros = document.getElementById('pros').value;
	 if(pros=='Pros: What was good about the item? example: Item condition was better than expected.  Item was clean and ready to go.')
	 {
		pros='';
	 }
	 
	 var cons = document.getElementById('cons').value;
	 if(cons=='Cons: What was bad about the item? example: Item condition was worse than expected.  Item was dirty and broke down.')
	 {
		cons='';
	 }
	 
	 var ratevote = document.getElementById('ratevote').value;
	 var rent_id = document.getElementById('rent_id').value;
	 if(ratevote=='0')
	 {
		alert('Please rate the Item by clicking stars');
		return false;
	 }
		

	/* alert(val);
	 return false;*/

	$('#add-review-div').hide();

	 url = 'items/addReview';
	 var data = 'review='+encodeURIComponent(val)+'&pros='+encodeURIComponent(pros)+'&cons='+encodeURIComponent(cons)+'&item_id='+item_id+'&ratevote='+ratevote+'&rent_id='+rent_id;

	 var divid = 'comment-div';
	 common_submit_form(url,data,divid);
	
	 document.getElementById('review').value = '';
	 document.getElementById('cons').value = '';
	 document.getElementById('pros').value = '';

	var data = 'item_id='+item_id;
	var divid = 'itemstars';
	setTimeout("common_submit_form('items/itemRating','"+data+"','"+divid+"')",1000);

 }





function common_submit_form(url,data,divid)
{
	$.ajax({
		url : site_url+''+url, // your ajax file
		type : 'post',
		data : data,
		asynchronous: false,
		success : function(resp)
		{
			/*FB.init({appId: APP_ID, status: true, cookie: true,
		 xfbml: true});*/
			
			if(divid == '')
			{
				return false;
			}
			else
			{ 
				document.getElementById(divid).style.display='none';
				document.getElementById(divid).innerHTML = resp;
				$('#'+divid).fadeIn('slow');
			}
			disptip();
		
		}
	
	});
	
}



function reviewHelpful(yes,no,id)
{
	url = 'items/reviewHelpful';
	var data = 'yes='+yes+'&no='+no+'&id='+id;

	var divid = 'review-helpful-message-'+id;
	common_submit_form(url,data,divid);
	
	var data = 'id='+id;
	var divid = 'review-helpful-'+id;
	setTimeout("common_submit_form('items/findHelpfulFormReview','"+data+"','"+divid+"')",1000);
	
	setTimeout("hide('review-helpful-message-"+id+"')",3000);
	
}

function hide(id)
{
	$('#'+id).hide();
}


function replyOnComment(divid)
{
	$('#'+divid).fadeIn('slow');
	$('#'+divid+' textarea').focus();

}


function addComment(item_id)
{    
	 var comment = document.getElementById('comment-'+item_id).value;
	 //alert(comment);
	 url = 'items/addComment';
	 var data = 'comment='+encodeURIComponent(comment)+'&review_id='+item_id;

	 var divid = 'review-comment-div-'+item_id;

	// alert(divid);
	 common_submit_form(url,data,divid);
	 document.getElementById('comment-'+item_id).value = '';

	 document.getElementById('add-comment-box-'+item_id).style.display = 'none'; 
	 document.getElementById('addcommentbtn-'+item_id).style.display = 'none'; 
	
}


function moreRecords(divid,url)
{
	var count = document.getElementById('count').value;
	var filter_id = document.getElementById('filter_id').value;
	var item_id = document.getElementById('item_id').value;
	var order_by = document.getElementById('order_by').value;
	var data = 'count='+count+'&filter_id='+filter_id+'&item_id='+item_id+'&order_by='+order_by;
	//loader(divid);//loader
	
	common_submit_form(url,data,divid);
	
}

function sortReview(order_by,text)
{
	
	$("#sortname").html(text);

	var item_id = document.getElementById('item_id').value;
	var url = 'items/sortReview';
	var data = 'order_by='+order_by+'&item_id='+item_id;
	var divid = 'comment-div';
	common_submit_form(url,data,divid);
	$('#sorting').hide();
	
}




function disptip(){
//MM_preloadImages(site_url+'/images/tt-searchsm-top.png',site_url+'/images/tt-searchsm-mid.png',site_url+'/images/tt-searchsm-bottom.png');
var val='';
var prTimer;
$('.a9').unbind("mouseenter");
$('.a9').bind("mouseenter",function()
{
	val= $(this).attr('id');

if(prTimer)
clearTimeout(prTimer);


$('#contact-user-link-Content-'+val).css({top:$(this).position().top+15,left:$(this).position().left+2});

moupopitem=setTimeout(function() { $('#contact-user-link-Content-'+val).show(); }, 400);
});
$('.a9').unbind("mouseleave");
$('.a9').bind("mouseleave",function()
{
	clearTimeout(moupopitem);
	//prTimer=setTimeout(function(){$('#tt-search-inv'+val).hide();});
	$('#contact-user-link-Content-'+val).hide();
});

$('.tooltip-a9').bind("mouseenter",function()
{
	val= $(this).attr('id');
/*if(prTimer)
clearTimeout(prTimer);*/
 $('#'+val).show(); 
});
$('.tooltip-a9').bind("mouseleave",function()
{
val= $(this).attr('id');
clearTimeout(moupopitem);
clearTimeout(prTimer);
$('#'+val).hide();
});



}



/*
function distip(id)
{
	$('#contact-user-link-Content-'+id).hide();
	
	$('#contact-user-link-'+id).bind("mouseenter",function()
	{
		if(subClear)
			clearTimeout(subClear);
		$('#contact-user-link-Content-'+id).fadeIn();
		$('#contact-user-link-Content-'+id).css({top:$(this).offset().top+15,left:$(this).offset().left+2});
	});

	$('#contact-user-link-'+id).bind("mouseleave",function()
	{
		subClear=setTimeout(function(){$('#contact-user-link-Content-'+id).fadeOut();},100);
	});
	
	$('#contact-user-link-Content-'+id).bind("mouseenter",function()
	{
		if(subClear)
		clearTimeout(subClear);
	});
	
	$('#contact-user-link-Content-'+id).bind("mouseleave",function()
	{
		$('#contact-user-link-Content-'+id).fadeOut();
	});
	

}*/

function hideBlurTxt(id)
{
	var val = document.getElementById(id).value;
	if(trim(val) == '')
	{
		document.getElementById('submitButton').style.display="none";
		document.getElementById(id).innerHTML = "";
	}
	else
	{
		if(id=='review'){
		document.getElementById('submitButton').style.display="block";
		}
	}

}

function displayButton(id)
{
	var val = document.getElementById(id).value;
	if(trim(val)=='Comment content of around 150-200 characters will fill in this space. Name will be optional while posting comments.')
	{
	     document.getElementById(id).innerHTML='';
	}
	else
	{
	     document.getElementById(id).innerHTML = val;
	}
	if(id=='review'){
	document.getElementById('submitButton').style.display="block";
	}
}


function displayAddCOmmentbtn(id,id2)
{
	var val = document.getElementById(id).value;
	if(trim(val)=='Comment content of around 150-200 characters will fill in this space. Name will be optional while posting comments.')
	{
	     document.getElementById(id).innerHTML='';
	}
	else
	{
	     document.getElementById(id).innerHTML = val;
	}
	document.getElementById('addcommentbtn-'+id2).style.display="block";
	$('#addcommentbtn-'+id2).focus();
	
}

function hideBlurTxtComment(id,id2)
{
	var val = document.getElementById(id).value;
	if(trim(val) == '')
	{
		document.getElementById('addcommentbtn-'+id2).style.display="none";
		document.getElementById(id).innerHTML = "";
	}
	else
	{
		document.getElementById('addcommentbtn-'+id2).style.display="block";
	}

}

function deleteReview(row_id)
{
	order_by='id';
	var item_id = document.getElementById('item_id').value;
	var url = 'items/deleteReview';
	// url = 'items/addReview';
	var data = 'order_by='+order_by+'&item_id='+item_id+'&row_id='+row_id;
	var divid = 'comment-div';
	common_submit_form(url,data,divid);


	var data = 'item_id='+item_id;
	var divid = 'itemstars';
	setTimeout("common_submit_form('items/itemRating','"+data+"','"+divid+"')",2000);
	
}

function deleteComment(row_id,review_id)
{
	order_by='id';
	var url = 'items/deleteComment';
	var data = 'order_by='+order_by+'&review_id='+review_id+'&row_id='+row_id;
	var divid = 'review-comment-div-'+review_id;
	common_submit_form(url,data,divid);
	
}
///for the Search Page
function addItemToWishList(id)
{
	var url = 'wishlist/addItemToWishList';
	var data = 'id='+id;
	var divid = '';
	common_submit_form(url,data,divid);
	//setTimeout("hide('wishlist-div-"+id+"')",1000);
	$("#wishlist-div-"+id).html('<span class="remove"><a href="javascript:void(0);" onclick="removeItemFromWishList(\''+id+'\');">Remove from Wishlist</a>');
	setTimeout("hide('success-msg')",3000);
}

function removeItemFromWishList(id)
{
	var url = 'wishlist/removeItemFromWishList';
	var data = 'id='+id;
	var divid = 'success-msg';
	common_submit_form(url,data,divid);
	$("#wishlist-div-"+id).html('<span class="save"><a href="javascript:void(0);" onclick="addItemToWishList(\''+id+'\');">Save to Wishlist</a>');
	setTimeout("hide('success-msg')",3000);

}


///for the detail Page
function addItemToWishListDetail(id)
{
	var url = 'wishlist/addItemToWishList';
	var data = 'id='+id;
	divid='';
	common_submit_form(url,data,divid);
	
	$("#wishlistbtn").html('<a href="javascript:void(0);" onclick="removeItemFromWishListDetail(\''+id+'\');">Remove from Wishlist</a>');
	
}


function removeItemFromWishListDetail(id)
{
	var url = 'wishlist/removeItemFromWishList';
	var data = 'id='+id;
	divid='';
	common_submit_form(url,data,divid);
	$("#wishlistbtn").html('<label class="white-input1"></label><input value="+ Wish List" type="reset" onclick="addItemToWishListDetail(\''+id+'\');" />');
	
}

function removeItemFromWishListAndShow(id)
{
	$("#removeItemId").val(id);
	$("#filter_type").val('sortby');
	//document.getElementById("orderby").value=obj;
	searchwithZipCityKeyword();

	$("#removeItemId").val('');
}



function share(user_id)
	{
		var status = document.getElementById('status_textarea').value;
		var share_hidden = document.getElementById('share_hidden').value;
		$("#status_textarea").val('');
	    var data= "status="+status+"&user_id="+user_id;
		var RE_STRING = /^[A-Za-z0-9\-,\.\s\'?! ]+$/;   
	    var url="network/share";
		
			//alert(url);
		if(share_hidden != 1)
		{
			
			if(RE_STRING.test(status))
			{
				$("#share_button").fadeOut('slow');
				$.ajax({
					url : site_url+url, // your ajax file
					type : 'post',
					data : data,
					asynchronous: false,
					success : function(resp)
					{
						
					//	document.getElementById(divid).innerHTML = resp;
					if(user_id == 0)
						mytabs('newsfeeds');
					else
						mytabs('newsfeeds',user_id);
					
					//$('a[rel*=facebox]').facebox(); //to reinilize facebox
					//resetAddThis();	//To reinitilize AddThis plugin 
					}
				});
			}
			else
			{
				alert('Please enter valid text only!');
				document.getElementById('status_textarea').focus();
			}
		}
		else
		{
			alert('Please share something!');
			document.getElementById('status_textarea').focus();
		}
	}

	function searchFriend(url)
	{
		var name= document.getElementById('search_user').value;
		var user_type= document.getElementById('user_type_select').value;

				var RE_STRING = /^[A-Za-z0-9\-,\.\s\' ]+$/;   
	    
			
			


		if(name == "")
		{
			name = 0;
					document.getElementById('find_friend_popup').setAttribute('href',site_url+'network/findFriendPopup/'+name+'/'+user_type);
		}
		else{
			if(user_type != "email")
			{
			if(RE_STRING.test(name))
			{
				
				name = name;
				document.getElementById('find_friend_popup').setAttribute('href',site_url+'network/findFriendPopup/'+name+'/'+user_type);
			}
			else
			{
				name = 0;
					document.getElementById('find_friend_popup').setAttribute('href',site_url+'network/findFriendPopup/'+name+'/'+user_type);
			}
			}
			else
			{
			name = name;
				document.getElementById('find_friend_popup').setAttribute('href',site_url+'network/findFriendPopup/'+name+'/'+user_type);
			}
		}
		
	//	var data = 'name='+name+'&user_type='+user_type;
	//	var divid='';
	///	common_submit_form(url,data,divid); 
	
	}


 function resetCaptcha(){}

		function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode != 46)
	{
		if(charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	}
	else
	{ }

 return true;
}


	function lookGoogleImage()
	{
		var itemName = document.getElementById('itemName').value;
		
		// IE hack to prevent 'Are you sure you want to leave this page' alert box
		if(typeof submitting_form != 'undefined')
			submitting_form = true;
		
//		document.getElementById('lookGoogle').setAttribute('href',site_url+'welcome/lookImage/'+itemName);
		showPopWin(site_url+'welcome/lookImage/'+itemName,700,500, null);
	}


function hideItemPopup()
{
	$('.item-popup').hide();
}

// created by neelesh chouksey
// this function is for mobile no verification ( it uses tropo for mobile no verifiction )
function sendVerificationCode(number)
{ 
	$('#send_link').hide();
	$('#enter_code').hide();
	$('#lodr').show();
	
	var url = "profile/sendVerificationCode/"+number;
	$.ajax({
		type: 'get',
		url: site_url+url,
		success: function(data){
			$('#lodr').hide();
			$('#enter_code').show();
			$('#enter_code').html(data);
			if (!data){
				alert("failed");
			}
		},
		error: function(e){
		  alert('Error verifying number: ' + number + ' -- ' + e)
		}
	});
	
	alert('A text message has been sent to your phone with a CODE. Please click OK and type in the code. Thank you!')
}
function verifyno()
{ 
	code = $('#verification_code').val();
	var url = "profile/verifyno/"+code;
	$.ajax({
		type: 'get',
		url: site_url+url,
		success: function(data){ 
			if(data == 2){
			window.location=site_url+'items/rent_submit';
			}else if (data == 0)
			{
				$('#verified').show();
			}
			else
			{
				$('#enter_code').hide();
				$('#verified').hide();
				$('#send_link').show();
				$('#send_link').html(data+' &nbsp;<span style="color:green;">Verified</span>');
				
			}
		}
	});
	
}

function randomString() {
	var chars = "0123456789abcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
//Jitendra

function sendtourl(number)
{
	window.location = site_url + "profile/verify_account"
}


function sorting_post_item(srt,ordename,guest_id)
{
//alert(guest_id);
	var sortby='Sort by: <span class="colorb"><strong>'+ordename+'</strong></span>';
	
	
	$("#vals").val(srt);
	
		
	
	var id=$("#gid").val();
	url=site_url+"network/userPostedItemList";
	if((guest_id==undefined) ||(guest_id=="" ))
	{
		url=url;
	
	}else
	{
		url=url+"/"+guest_id;
	
	}
	
	
	
	datas="sortorder="+srt+"&id="+id;
	$.ajax({
			   type: "post",
			   url: url,
			   data: datas,
			   success: function(data){
			   //	alert(data);
			   document.getElementById('sorting').style.display = 'none';
					$("#itemlist").html(data);
					
					$(".negotiable-new").html(sortby);
					
			}			   
			   
		   });


}

function sorting_rent_item(srt,ordename,guest_id)
{
//alert(guest_id);
 var sortby='Sort by: <span class="colorb"><strong>'+ordename+'</strong></span>';
 
 
 $("#vals").val(srt);
 
  
 
 var id=$("#gid").val();
 url=site_url+"network/userRentedItemList";
 if((guest_id==undefined) ||(guest_id=="" ))
 {
  url=url;
 
 }else
 {
  url=url+"/"+guest_id;
 
 }
 
 
 
 datas="sortorder="+srt+"&id="+id;
 $.ajax({
      type: "post",
      url: url,
      data: datas,
      success: function(data){ $('#sorting').hide();
       $("#itemlist").html(data);
     $(".negotiable-new").html(sortby);
    
   }      
      
     });


}


function sorting_negotiating_item(srt,ordename,guest_id)
{
//alert(guest_id);
 var sortby='Sort by: <span class="colorb"><strong>'+ordename+'</strong></span>';
 
 
 $("#vals").val(srt);
 
  
 
 var id=$("#gid").val();
 url=site_url+"network/userNegotiatingItemList";
 if((guest_id==undefined) ||(guest_id=="" ))
 {
  url=url;
 
 }else
 {
  url=url+"/"+guest_id;
 
 }
 
 
 
 datas="sortorder="+srt+"&id="+id;
 $.ajax({
      type: "post",
      url: url,
      data: datas,
      success: function(data){ $('#sorting').hide();
       $("#itemlist").html(data);
     $(".negotiable-new").html(sortby);
    
   }      
      
     });


}

//payment history page TabMenu
$(document).ready(function()
{
	$('.tab-small-ul li a').bind("click",function()
	{
		$(this).parent().parent().children().children('a').removeClass('active');
		$(this).addClass('active');
		$('#fees, #sentPayments, #receivedPayments, #paymentMethods, #withdrawal').hide();
		$('#'+$(this).attr('rel')).fadeIn();
	});
});


//function to close popup (showin popup) and redirect page
function closePopUp(val)
{
	//alert($("#"+val).attr("rel"));
	window.top.hidePopWin();
	closePopUpURL($("#"+val).attr("rel"));

	
}

function closePopUpURL(val)
{
	parent.window.location.href=val;
}


function userLoginRedirect(rurl)
{

  // Open the sign-in box then call Ajax script to set
  // the redirect URL in the user's SESSION
  if(!$('#pop-up').length){
    $.ajax({ type: 'get', url: site_url + 'ajax/get_login_modal_content', async : false,
      success: function (data) { $('body').append(data); } 
    });
  }
  openPopDiv('pop-up');
  resetCheckBox();

  if(!rurl) return;
  
	var url=site_url+"home/userLoginRedirect";
	datas="rurl="+rurl;
	
	$.ajax({
      type: "post",
      url: url,
      data: datas,
      success: function(data){}      
    });
}

//function created for API buttons
function userLoginRedirectFB(rurl)
{
	var url=site_url+"home/userLoginRedirect";
	datas="rurl="+rurl;
	$.ajax({
      type: "post",
      url: url,
      data: datas,
      success: function(data){ 
	  }      
      });
}

// Static FEEDBACK button onclick
function show_feedback_survey(){
  var params = 'current_url=' + encodeURIComponent(window.location.href) + '&referrer=' + encodeURIComponent(document.referrer);
  window.open(site_url +'survey/feedback_survey?' + params,'mywindow','width=600,height=520,resizable=yes,scrollbars=no');
}

function show_explainer_video_modal(){
	// Redirect iPhone/iPad users since they can't view flash
	if((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPad") != -1)){
		window.location = site_url + "home/howitworks?play";
		return;
	}
	
	if(!$('#explainer_video_modal').length){
	    $.ajax({ type: 'get', url: site_url + 'ajax/get_explainer_video_modal_content', async : false,
	      success: function (data) { $('body').append(data); } 
	    });
	    
	    // Track the Video Play as an event
	    _gaq.push(['_trackEvent', 'Content', 'Explainer Video', 'Play']);
	}
	openPopDiv('explainer_video_modal');
}


