/*function get_ajax_contents(categoryId){
	var p = {};
	p[categoryId] = "lsdjdhkjksuiweier";
    $('#Ajax_Test_Content').load(Ozi_main/getAjaxTestContForDiv,p,function(str){});
}
*/
/***************** This function will be used for displaying sub-categories items*/
				function f1(t,d){
					var v =  t+'='+d; //it works without all elements since we omitted the count of fields check
					//alert(v);
					$("#MainMiddleDiv").slideUp("slow");
					var currClass = $("#MainMiddleDiv").attr("class");
					if (currClass!='y')
					{
					$("#MainMiddleDiv").removeClass(currClass);
					$("#MainMiddleDiv").addClass("y");
					}
//					if($("#MainMiddleDiv").hasClass("n")) {$("#MainMiddleDiv").removeClass("n"); $("#MainMiddleDiv").addClass("y"); }
//					if($("#MainMiddleDiv").hasClass("s")) {$("#MainMiddleDiv").removeClass("s"); $("#MainMiddleDiv").addClass("y"); }
					$.ajax({
					cache: false,
					type: "POST",
					data: v, //Data to be sent to the server
					dataType: "html", //The type of data that you're expecting back from the server.
					//url: "http://localhost/oziv2/ozi_main/ajaxsearch", //this.attr('action'), 
					url: "http://www.ozisale.com/ozi_main/ajaxsearch/",
					beforeSend: function(){$("#LD").fadeIn(500);}, //show loading just when link is clicked
					complete: function(){ $("#LD").fadeOut(500);}, //stop showing loading when the process is complete
					success: function(html){
					$("#MainMiddleDiv").slideDown("slow");
					$("#MainMiddleDiv").html(html);
					  },
					error: function(html){
						$("#MainMiddleDiv").show("slow");
						$("#MainMiddleDiv").html("Apologies, ... , error encountered.!");
					}
				   });
				}
/*****************/

/*************** function to view details       *********************/
function ajaxVD(i){

		//alert($(this).get());
		//e.preventDefault();

		//alert($.cookie("OziRecentlyViewedItems"));
								//set a cookie for this item
		//						if ($.cookie("OziRecentlyViewedItems", "444", { expires: 7, path: '/', domain: 'localhost' , secure:false})) { alert('cookie SET successfully'); }
		//						else { alert('prblms'); }


		var currClass = $("#MainMiddleDiv").attr("class");
		if (currClass!='s')
		{
		$("#MainMiddleDiv").removeClass(currClass);
		$("#MainMiddleDiv").addClass("s");
		}
			   $.ajax({
                type: "POST",
				//data: str,
				cache: false,
				url: "http://www.ozisale.com/ozi_main/GetItemDetails/"+i, //this.attr('action'), 
				//url: $(this).get(),
				beforeSend: function(){$("#LD").fadeIn(500); $("#MainMiddleDiv").slideUp("slow");},	//show loading just when link is clicked
				complete: function(){ $("#LD").fadeOut(500); },									//stop showing loading when the process is complete
				success: function(html){
								$("#MainMiddleDiv").slideDown("slow");
								$("#MainMiddleDiv").html(html);
                },
				error: function(html){
					$("#MainMiddleDiv").show("slow");
					$("#MainMiddleDiv").html("Apologies, ... , error encountered.!");
				}

               });
}
/*************** end function to view details *********************/

$(document).ready(function(){
////////////////// this funciton is called when we load the main page /////////////////////
		$(function(){
		var gUrl = "http://www.ozisale.com/ozi_main/RecentlyAddedItems/0";
		var cUrl = window.location.href.toLowerCase();
		var pos = cUrl.indexOf('viewitemdetails/') ;
		if (pos >0)
		{
			var id = cUrl.substr(pos+15, cUrl.length);
			/*
			var currClass = $("#MainMiddleDiv").attr("class");
				if (currClass!='s')
				{
				$("#MainMiddleDiv").removeClass(currClass);
				$("#MainMiddleDiv").addClass("s");
				}
			*/
		gUrl = "http://www.ozisale.com/ozi_main/GetItemDetails/"+id;
		}
		//alert(gUrl);
				$.ajax({
							type: "POST",
							cache: false,
							//url: "http://localhost/oziv2/ozi_main/RecentlyAddedItems/0", //this.attr('action'), 
							url : gUrl,
							//data: str,
							beforeSend: function(){$("#LD").fadeIn(500);}, //show loading just when link is clicked
							complete: function(){ $("#LD").fadeOut(500);}, //stop showing loading when the process is complete
							success: function(html){ //so, if data is retrieved, store it in html
							$("#MainMiddleDiv").slideDown("slow"); //animation
							$("#MainMiddleDiv").html(html); //show the html inside .content div
							},
							error: function(html){
								$("#MainMiddleDiv").slideDown("slow");
								$("#MainMiddleDiv").html("Apologies, ... , error encountered while trying to get the Recently added items!");
							}
				 }); //close $.ajax(
		});

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


	 $(function(){
	 //$('.ajaxSearchResult').load('http://localhost/oziv2/ajaxsearch');	//by default initally load text from boo.php
			$('#GoImg').click(function() { //start function when any link is clicked
			var str = $("#Ozi_search_form").serialize();
	//alert(str);
		 	$("#MainMiddleDiv").slideUp("normal");
			var currClass = $("#MainMiddleDiv").attr("class");
			if (currClass!='n')
			{
			$("#MainMiddleDiv").removeClass(currClass);
			$("#MainMiddleDiv").addClass("n");
			}
//			if($("#MainMiddleDiv").hasClass("n")) {$("#MainMiddleDiv").removeClass("n"); $("#MainMiddleDiv").addClass("s"); }
						 //var content_show = "testing ajaz"; //$(this).attr("title"); //retrieve title of link so we can compare with php file
							$.ajax({
							type: "POST",
							cache: false,
							url: "http://www.ozisale.com/ozi_main/ajaxsearch/", //this.attr('action'), 
							data: str,
							beforeSend: function(){$("#LD").fadeIn(500);}, //show loading just when link is clicked
							complete: function(){ $("#LD").fadeOut(500);}, //stop showing loading when the process is complete
							success: function(html){ //so, if data is retrieved, store it in html
							$("#MainMiddleDiv").slideDown("slow"); //animation
							$("#MainMiddleDiv").html(html); //show the html inside .content div
							},
							error: function(html){
								$("#MainMiddleDiv").slideDown("slow");
								$("#MainMiddleDiv").html("Apologies, ... , error encountered.!");
							}
				 }); //close $.ajax(
         }); //close click(
	 });

    $(function() 
    { 
       var  sb = $('#searchField'); 
        var code =null; 
        sb.keypress(function(e) 
        { 
            code= (e.keyCode ? e.keyCode : e.which); 
            if (code == 13){ e.preventDefault(); $('#GoImg').click();}
        }); 
 
    });


	$(function(){
		$('#SignUp_Link').click(function(){

			//$("#MainMiddleDiv").load("http://localhost/oziv2/ozi_main/showSignUpFormInMainMiddleDiv")
			$("#MainMiddleDiv").slideUp("slow");	
			var currClass = $("#MainMiddleDiv").attr("class");
			if (currClass!='y')
			{
			$("#MainMiddleDiv").removeClass(currClass);
			$("#MainMiddleDiv").addClass("y");
			}
//			if($("#MainMiddleDiv").hasClass("s")) {$("#MainMiddleDiv").removeClass("s"); $("#MainMiddleDiv").addClass("n"); }
			$.ajax({
							type: "POST",
							cache: false,
							url: "http://www.ozisale.com/ozi_main/showSignUpFormInMainMiddleDiv", //this.attr('action'), 
							//data: str,
							beforeSend: function(){$("#LD").fadeIn(500);}, //show loading just when link is clicked
							complete: function(){$("#LD").fadeOut(500);}, //stop showing loading when the process is complete
							success: function(html){ //so, if data is retrieved, store it in html
							 $("#MainMiddleDiv").slideDown("slow");//animation
							$("#MainMiddleDiv").html(html); //show the html inside .content div
							
							//$("#Fname").focus();
							 //$.scrollTo('+=300px', 800);
							},
							error: function(html){
								$("#MainMiddleDiv").show("slow");
								$("#MainMiddleDiv").html("Apologies, ... , error encountered.!");
							}
				 }); //close $.ajax(
		});
	});

//	$(function(){
//	$("#OziSignUpForm > *").blur(function(){alert('got u');})
//	});


/////
/////
	/*
	 $("[href*='ViewItemDetails']").click(function(e){
		//alert($(this).get());
		e.preventDefault();

		//alert($.cookie("OziRecentlyViewedItems"));
								//set a cookie for this item
		//						if ($.cookie("OziRecentlyViewedItems", "444", { expires: 7, path: '/', domain: 'localhost' , secure:false})) { alert('cookie SET successfully'); }
		//						else { alert('prblms'); }


		var currClass = $("#MainMiddleDiv").attr("class");
		if (currClass!='s')
		{
		$("#MainMiddleDiv").removeClass(currClass);
		$("#MainMiddleDiv").addClass("s");
		}
			   $.ajax({
                type: "POST",
				//data: str,
				cache: false,
				//url: "http://localhost/oziv2/ozi_main/ViewItemDetails/", //this.attr('action'), 
				url: $(this).get(),
				beforeSend: function(){$("#LD").fadeIn(500); $("#MainMiddleDiv").slideUp("slow");},	//show loading just when link is clicked
				complete: function(){ $("#LD").fadeOut(500); },									//stop showing loading when the process is complete
				success: function(html){
								$("#MainMiddleDiv").slideDown("slow");
								$("#MainMiddleDiv").html(html);
                },
				error: function(html){
					$("#MainMiddleDiv").show("slow");
					$("#MainMiddleDiv").html("Apologies, ... , error encountered.!");
				}

               });   
	 });
	 */

}
);
