//GG designs Slideshow
function processSlideshow(elem, imageList, textElem, textList, imageDuration, fadeSpeed, current) 
{
	var listSize = imageList.length;
    if (!current || current >= listSize) current = 0;
    if (!imageDuration) imageDuration = 2000;
    if (!fadeSpeed) fadeSpeed = 1000;
    
    $(textElem).html(textList[current]);
    $(elem + " img").attr("src", imageList[current]);
    
    if (current == (listSize - 1)) { 
        $(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
        $(textElem).html(textList[current]);
    } else {
        $(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
        $(textElem).html(textList[current]);
    }

    /*$("#header-right").animate({ opacity: "1" }, imageDuration).
	      animate({ opacity: "0.01" }, fadeSpeed, function() 
		   {
		     $(this).css("opacity", "1"); 
			});
      */          
    $(elem + " img").animate({ opacity: "1" }, imageDuration).
	      animate({ opacity: "0.01" }, fadeSpeed, function() 
		   {
		     $(this).css("opacity", "1"); 
             processSlideshow(elem, imageList, textElem, textList, imageDuration, fadeSpeed, current + 1) 
			});
    
} 

//GG designs CRM & WebCMS
$(document).ready(function() {
    
	$("#open").click(function(){
		$("div#panel").slideDown("normal");	
	});	
	
	$("#close").click(function(){
		$("div#panel").slideUp("normal");	
	});		
	
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
		
});

//GG designs Ajax
function ajax(url, post, target)
{
	var xmlHttp;
		
	try
	{
		xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  
		try
		{    
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		}
		catch (e)
		{    
			try
			{      
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}
			catch (e)
			{      
				alert("Your browser does not support AJAX!");      
				return false;      
			}    
		}  
	}

	xmlHttp.onreadystatechange = function() 
	{
		if(xmlHttp.readyState == 4) 
		{
            document.getElementById(target).innerHTML = xmlHttp.responseText
		}
		else
		{
	      	document.getElementById(target).innerHTML = '<div class="box"><h2>Filter</h2><p></p><div id="portfolio"><div style="text-align:center; margin-top:150px;"><img src="http://localhost/ggdesigns/images/loading.gif" /></div></div></div>';
        }
    }
	
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
    xmlHttp.send(post);
}
