function ajaxFunction(type, arg1, offset, cid){

	var ajaxRequest = null;  // The variable that makes Ajax possible!

   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {

   try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("This feature was disabled by your browser.");
				return false;
			}
		}
	}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
//          if (type == 'search')
	      var ajaxDisplay = document.getElementById('fuzzysearch');
          if (type == 'ymctv')			
		  {
            ajaxDisplay = document.getElementById('videos');
            ajaxCatName = document.getElementById('catName');				
			ajaxCatName.innerHTML = arg1;			  			
			ajaxDisplay.innerHTML = ajaxRequest.responseText;			  
		  } else if (type == 'rating')			
		  {
            ajaxDisplay = document.getElementById('rating');			  
			ajaxDisplay.innerHTML = ajaxRequest.responseText;			  
		  }  else if (type == 'ymctvHomePage')				
		  {
            ajaxDisplay = document.getElementById('ymctvHomePage');			  
			ajaxDisplay.innerHTML = ajaxRequest.responseText;			  
		  } else
		  {
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
	        ajaxDisplay.className="visible";			
            if (ajaxRequest.responseText.length > 500)
			{
			  ajaxDisplay.style.height = '300px';
			  ajaxDisplay.style.overflow = 'auto';			  
			} else
			{
			  ajaxDisplay.style.height = '';
			  ajaxDisplay.style.background = '#FFFFFF';			  
			  ajaxDisplay.style.overflow = "visible";				  
			}			
		  }
      }
	}

    if (type == 'search'){
	  var rowsPerPage = 10;
      var queryString = "?searchText=" + document.getElementById('sSearch').value; 
//	  alert(queryString);
	  if (document.getElementById('sSearch').value.length >= 3)
	  {
        ajaxRequest.open("GET", "./includes/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
	  }
 	}	
    if (type == 'archive'){
	  var rowsPerPage = 10;
      var queryString = "?searchType=archive&searchText=" + document.getElementById('sSearch2').value; 
//	  alert(queryString);
	  if (document.getElementById('sSearch2').value.length >= 3)
	  {
        ajaxRequest.open("GET", "./includes/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
	  }
 	}	
    if (type == 'shop'){
	  var rowsPerPage = 10;
      var queryString = "?searchType=shop&searchText=" + document.getElementById('sSearch3').value; 
	  if (document.getElementById('sSearch3').value.length >= 3)
	  {
        ajaxRequest.open("GET", "./includes/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
	  }
 	}		
    if (type == 'ymctv'){
      var queryString = "?catID=" + cid + "&pageNum=" + offset; 
      ajaxRequest.open("GET", "./includes/ajaxYmcTV.php" + queryString, true);
      ajaxRequest.send(null);	
 	}		
    if (type == 'ymctvHomePage'){
      var queryString = "?action=h&catID=" + cid + "&pageNum=" + offset; 
      ajaxRequest.open("GET", "./includes/ajaxYmcTV.php" + queryString, true);
      ajaxRequest.send(null);	
 	}			
    if (type == 'rating'){
      var queryString = "?action=r&ymctvID=" + cid + "&rating=" + arg1; 
      ajaxRequest.open("GET", "./includes/ajaxYmcTV.php" + queryString, true);
      ajaxRequest.send(null);	
 	}		
	
}

function selectTag() {
//   var id = document.getElementById('selectTag').options[document.getElementById('selectTag').selectedIndex].id;

 window.location = "blog.php?tag=" + document.getElementById('selectTag').value;

}

function activeSearch() {
	element('searchField').className="activeSearch";
	element('searchField').value="";
	element('fuzzysearch').className="visible";
}

function closeSearch() {
	element('fuzzysearch').className="hidden";
}

function element( elementId )
{
   if ( document.getElementById )
   {
      return document.getElementById( elementId )
   }
   else if ( document.all )
   {
      return document.all[elementId]
   }
   else if ( document.layers ) 
   {
      return document[ elementId ]
   }
   else
   {
      //alert( "no element: " + elementId )
   }
}

    function openWindow(url, uri) 
    { 
		  popupWin = window.open('http://207.97.252.121/dev/' + url + '?uri=' + uri,'remote','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,dependent,width=420,height=590,left=200,top=160');

    } 

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

function showDiv(divID)
{
	var div = document.getElementById(divID);
	
	if (!div)
	{
		return;
	}
	
	//div.className = "signup_visible";
	div.style.display = "block";
}

function editPageLoad(url) {
	var id = document.getElementById('pageselect').options[document.getElementById('pageselect').selectedIndex].id;
	if (id == 'null') {
		document.getElementById('editframe').value = '';
		return false;
	}
	
	window.location = document.getElementById('pageselect').value;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

  function drawDisqus()
  {
   document.getElementById("disqus").style.display = "";  
   document.getElementById("disqus").innerHTML = '<div id="disqus_thread"></div><script type="text/javascript" src="http://disqus.com/forums/yummymummyclub/embed.js"></script><noscript><a href="http://disqus.com/forums/yummymummyclub/?url=ref">View the discussion thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>';
  }
