/*	Sets the two components to the larger of the two
	This is used to stretch the the shorter column in column layout
*/
function setEqualHeight(item1, items) {
	//alert(item1.height() + " " + item2.height());
	items.each(function () {
		if(item1.height()>$(this).height()) {
			$(this).height(item1.height());	
		} else {
			item1.height($(this).height());	
		}
	});
}
(function($) {
  $.fn.equalizeCols = function(children){
    var child = Array(0);
    if (children) child = children.split(",");
    var maxH = 0;
    this.each(
      function(i) 
      {
        if (this.offsetHeight>maxH) maxH = this.offsetHeight;
      }
    ).css("height", "auto").each(
      function(i)
      {
        var gap = maxH-this.offsetHeight;
        if (gap > 0)
        {
          t = document.createElement('div');
          $(t).attr("class","fill").css("height",gap+"px");
          if (child.length > i)
          {
            $(this).find(child[i]).children(':last-child').after(t);
          } 
          else 
          {
            $(this).children(':last-child').after(t);
          }
        }
      }  
    );
    
  }
})(jQuery);

function changeImage(newImage,appID,aID) {
	bID=parseInt(aID)+1;
	t_len=document.getElementById('total_records').value;
	if(bID>t_len){bID=1;}
	t_val=document.getElementById('nNext'+bID).value;
	document.getElementById('demoImg').style.backgroundImage = newImage;
	document.getElementById('apName').innerHTML = appID;
	valt = t_val.split("-");
	//alert(valt[0]+","+valt[1]+","+valt[2]+","+valt[3]);
	document.getElementById('bNext').innerHTML = "<i><a class=\"normal\" style=\"text-decoration:none\" href=\"javascript:document.getElementById('myFrame').src='http://www.digitalmarketingbox.com/webtool/menubox?apiid="+valt[0]+"&apicode="+valt[1]+"';changeImage('url(images/"+valt[2]+")','"+valt[3]+"','"+bID+"');\">Next >></a></i>&nbsp;";
	
	for(i=1;i<=t_len;i++){
		if(i==aID){
			document.getElementById('id'+i).className = "normalo";
		}else{
			document.getElementById('id'+i).className = "normal";
		}
	}
}
function updateSideMen(restoID){
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			document.getElementById("clientlist").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","getrestotype.php?restoID="+restoID+"&action=GETRESTO",true);
	xmlhttp.send();
}
function createxmlhttpobject()
{
	var xmlhttp1;	
	if (window.XMLHttpRequest)
  	{
  		xmlhttp1=new XMLHttpRequest();
		return xmlhttp1;
  	}
	else if (window.ActiveXObject)
  	{
  		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		return xmlhttp1;
  	}
	else
  	{
  		alert("Your browser does not support XMLHTTP!");
		return false;
  	}
}
function getclientlist(clienttypeid,prfid)
{
	var xmlhttp;	
	xmlhttp=createxmlhttpobject();
	if(xmlhttp==false) return;
	var params = "datatype=getclientlist&clienttype=" + clienttypeid + "&profileid=" + prfid; 
	xmlhttp.open("POST","menubox_ops.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange=function()
  	{
  			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
					document.getElementById("clientlist").innerHTML=xmlhttp.responseText;	
					 if(prfid!=0)
					 {
					 	getclientdetails(0,prfid);
					 }
					 else
					 {
					 	getclientdetails(1,prfid);
					 }
					 
			}
	}
	xmlhttp.send(params);
}
function getclientdetails(rowsel,profileid)
{
	profileid = typeof(profileid) != 'undefined' ? profileid : "0";
	clienttypeid=document.getElementById("clienttype").options[document.getElementById("clienttype").selectedIndex].value;
	tclient=document.getElementById("totalclient").value;
	if(rowsel!=0)
	{
		for(j=1;j<=tclient;j++)
		{
			if(j==rowsel)
			{
				document.getElementById("profile_" + j).className="selectedclient";
			}
			else
			{
				document.getElementById("profile_" + j).className="normalclient";
			}
		}
	}
	var xmlhttp;	
	xmlhttp=createxmlhttpobject();
	if(xmlhttp==false) return;
	var params = "datatype=getclientdetail&rownum=" + rowsel + "&clienttype=" + clienttypeid + "&profileid=" + profileid;
	
	xmlhttp.open("POST","menubox_ops.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange=function()
  	{
  			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
					document.getElementById("contentid").innerHTML=xmlhttp.responseText;		
			}
	}
	xmlhttp.send(params);	
}
						  
