
function submitform()
{
  document.siteSearchForm.submit();
}
	
	function checkBoxPopup_login()
	{
		window.document.getElementById('tip_login').style.display="block";
		timedout_login();
	}
	function timedout_login()
	{
		var tt=setTimeout("window.document.getElementById('tip_login').style.display='none';",30000);
	}
	function verifycheckout()
	{
		/*if(window.document.getElementById('txtus').value == 1) //Unverified User
		{
			alert("You can complete this transaction only after you have activated your account.");
			return false;
		}*/

		/*if(window.document.getElementById('residential').value == 0){
		//if(window.document.getElementById('residential').value == 1){
			//alert("A residential delivery fee of $5.00 that will be added to the INVOICE but NOT added to the transaction total/processed cc payment.");
			//return false;
			//alert("A residential delivery fee of $5.00 will be applied to the Invoice. <br /> This fee will not be processed in your credit card transaction online.",1);
			elm = document.getElementById('alertBox');
			elm.style.display='';
			w = parseInt(elm.style.width);
			elm.style.left = (((screen.width-w)/2)-30) + 'px';
			return false;

		}else{*/
			window.location.href='/shopping/order_summary.php';
		/*}*/
	}
	function show_alert(){
			elm1 = document.getElementById('alertBox');
			elm1.style.display='none';
			elm = document.getElementById('alertBox1');
			elm.style.display='';
			w = parseInt(elm.style.width);
			elm.style.left = ((screen.width-w)/2) + 'px';
			return false;
	}
function checkBoxPopup(id)

	{
		$('#tip').css('display','block').css('position','fixed').css('top','10%');
		/*if(id != ''){
		 var new_position = $('#'+id).offset();
    	window.scrollTo(new_position.left,new_position.top);
    	}*/
		timedout();
	}
	function timedout()
	{
		var t=setTimeout("	$('#tip').css('display','none');",5000);
	}
$(function(){

$("#LiveChat_1310424959").animate({
    top: "+=506px"
  }, 1500 );

	  /*$('input').each(function() {
        //$(this).watermark($(this).attr('watermark'));
    });*/
    $("#catalog_tree > ul > li").each(function(){
        $(this).css("height","24px");
    });
    $("a.hoverMenu").each(function(){
        $(this).append("<span class='arrow'></span>");
    });

    $(".leftHover").each(function(){
        $(this).append("<a href='#' class='closea'><img src='/images/close.png' class='close'/></a>");
    });



    $('.closea').live("click",function(e){
        e.preventDefault();
        $(this).parent('.leftHover').hide();
        $("#catalog_tree > ul > li > a").removeClass("hoverclass");
    });
       $("a.hoverMenu").mouseover(function(){
            $this = $(this);
            $('.trans').remove();
            $("#catalog_tree > ul > li > a").removeClass("hoverclass");
            $this.addClass("hoverclass");
         //  $(this).parents('li').prepend("<img src='/images/1x1trans.gif' height='8' width='1' class='trans'/>").css("position","relative");
            $(this+' > span').empty();
            $this.next("div.leftHover").css("display","block").addClass("leftHover");
            $this.parent("li").css("height","24px");
            remove =  $this.next("div.leftHover");
            $("div.leftHover").not(remove).css("display","none");
            height =  $this.next("div.leftHover").children(".leftHoverInner").height();
//            alert(height);
            gos = height + 10;
            $("div.leftHover").height( gos + "px");
            d = gos/2;
            p = $this.position();
            if(height > 600) {
                a = p.top - d + 50;
            } else {
                a = p.top - d + 10;
            }

            $("div.leftHover").css("top",a);


           // $("div.leftHover").height( goheight + "px");
            //$("div.leftHoverInner").height( goheight2 + "px");
            //$("div.leftHover").height( $(".height").height() + "px");
        });

    $("div.leftHover").mouseleave(function(){
       $("div.leftHover").fadeOut(100, function() {
           $("#catalog_tree > ul > li > a").removeClass("hoverclass");
        });

    });
    function hide(){
        $("div.leftHover").fadeOut(100, function() {
           $("#catalog_tree > ul > li > a").delay(900).removeClass("hoverclass");
        });
    }
    function show(){

    }
    var config = {
     over: show, // function = onMouseOver callback (REQUIRED)
     timeout: 400, // number = milliseconds delay before onMouseOut
     out: hide // function = onMouseOut callback (REQUIRED)
};
if ($("#catalog_tree").length > 0){
    $("#catalog_tree").hoverIntent(config);

    $("div > a").each(function(){
                   a=  $(this).attr("id");
                  // a.replace(/%/g,'');
                });


        $("ul").each(
          function() {
            var elem = $(this);
            if (elem.children().length == 0) {
              elem.remove();
            }
          }
        );


        $('a.setcookie').click(function(e){
            e.preventDefault;
            var g = $(this).attr('id');
            $.cookie('location', g);
            console.log(g);

    });
    if($.cookie('location') != null){
    window.location='#'+$.cookie('location');
    }

   // console.log($.cookie('location'));

}
});


$("#submitContactform").submit(function(){
	// validate signup form on keyup and submit
	var validator = $("#signupform").validate({
		rules: {
			v_personName: {
			required: true
			},
			v_companyName: {
				required: false
			},
			email: {
				required: true,
				email: true,
				remote: "emails.php"
			},
			v_phone:{
			required: true
			},

			v_imageCode:{
			required: true,
			minlength: 6,
			equalTo: "#v_security"
			},
			dateformat: "required",
			terms: "required"
		},
		messages: {
			v_personName: "Enter your firstname",

			v_companyName: " ",

			email: {
				required: "Please enter a valid email address",
				minlength: "Please enter a valid email address",
				remote: jQuery.format("{0} is already in use")
			},
			v_phone: "Enter your phone no.",

			v_imageCode: {
				required: "Please enter correct security code",
				minlength: jQuery.format("Enter at least {0} characters"),
					equalTo: "Enter the same security code as above"
			},

			dateformat: "Choose your preferred dateformat",
			terms: " "
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			//alert("submitted!");
			this.form.submit();
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	
	
	
	
});	
/**** refer a friend ****/
function checkForReferFriendData()
{	with(window.document.referForm)
	{	 

		if(v_your_name.value=="")
		{	alert("Enter Your Name.");
			v_your_name.focus(); return false;
		}
		if(v_your_email.value=="")
		{	alert("Enter Your Email.");
			v_your_email.focus(); return false;
		}

		if(!(isValidMail(v_your_email.value)))
		{	alert("Enter your valid Email address.");
			v_your_email.focus(); return false;
		}
		if(v_frid_name.value=="")
		{	alert("Enter Your Friend's Name.");
			v_frid_name.focus(); return false;
		}
		if(v_frid_email.value=="")
		{	alert("Enter Your friend's Email.");
			v_frid_email.focus(); return false;
		}

		if(!(isValidMail(v_frid_email.value)))
		{	alert("Enter Your friend's valid Email address.");
			v_frid_email.focus(); return false;
		}
		 
		if(t_message.value.length < 10)
		{	alert("Enter Message more then 10 char.");
			t_message.focus(); return false;
		}
		
		return true;
	}
}
	function checkFeedbackForm()
	{	with(window.document.feedback)
		{
			if (v_message_type[0].checked == false && v_message_type[1].checked == false  && v_message_type[2].checked == false )
			{	alert("Please click the feedback type (Appreciation, Suggestion, or Complaint)");
				v_message_type[0].focus(); return false;
			}

			if (v_personName.value == "")
			{	alert("Enter Name");
				v_personName.focus(); return false;
			}
			if (v_email.value == "")
			{	alert("Enter Email Address");
				v_email.focus(); return false;
			}
			if (!(isValidMail(v_email.value)))
			{	alert("Enter valid Email Address");
				v_email.focus(); return false;
			}
			if (t_message.value == "")
			{	alert("Enter Comment");
				t_message.focus(); return false;
			}


			return true;
		}
	}
	

(function($){

	$.randomImage = {
		defaults: {
			path: '/images/', 
			myImages: ['rand1.jpg', 'rand2.jpg' ]		
		}			
	}
	$.fn.extend({
			randomImage:function(config) {
				var config = $.extend({}, $.randomImage.defaults, config); 
				 return this.each(function() {
						var imageNames = config.myImages;
						var imageNamesSize = imageNames.length;
						var lotteryNumber = Math.floor(Math.random()*imageNamesSize);
						var winnerImage = imageNames[lotteryNumber];
						var fullPath = config.path + winnerImage;
						$(this).attr( {
										src: fullPath,
										alt: winnerImage
									});
				});	
			}
	});
})(jQuery);

function setSelectionRange(input, selectionStart, selectionEnd) {
  if (input.setSelectionRange) {
    input.focus();
    input.setSelectionRange(selectionStart, selectionEnd);
  }
  else if (input.createTextRange) {
    var range = input.createTextRange();
    range.collapse(true);
    range.moveEnd('character', selectionEnd);
    range.moveStart('character', selectionStart);
    range.select();
  }
}

function setCaretToPos (input, pos) {
  setSelectionRange(input, pos, pos);
}




