var arrCaseStudy = new Array();
var currentCaseStudy = 0;

var currPage = 1;
var totalPage = 1;
var keyword = "";

function initPage() {
  var genre = getGenre();
  showLoading();
  getSearchDesign('','',genre,'','');
  
  for (i=1; i<=9; i++) {
    arrCaseStudy[i] = new Array();
    arrCaseStudy[i]['title'] = '';
    arrCaseStudy[i]['thumbpic'] = '';
    arrCaseStudy[i]['displaypic'] = '';
    arrCaseStudy[i]['originalpic'] = '';
    arrCaseStudy[i]['desc'] = '';
  }
  
  getCaseStudy();
  
  if (location.hash != "" && location.hash.substr(0, 5) == "#mid_") {
    var pid = parseInt(location.hash.substr(5),10);
    getMemberInfo(pid);
  }  
}

//INETERACTIVES 

function getDesignDir(){
    var exp = "";
    var size = "";
    var genre = "";
    var keyword = "";
    var association = "";
    exp = document.getElementById("ddlExp").value;
    size = document.getElementById("ddlSize").value;
    keyword = document.getElementById("txtKeyword").value;
    association = document.getElementById("ddlAssociations").value;
    
    if(exp=='0')exp='';
    if(size=='0')size='';
    if(association=='0')association='';
    
    genre = getGenre();
    if(genre=='\'\'')genre='';
    currPage = 1;
    
    getSearchDesign(exp,size,genre,keyword,association);
}

function getDesignDirNP(){
    var exp = "";
    var size = "";
    var genre = "";
    var keyword = "";
    var association = "";
    
    exp = document.getElementById("ddlExp").value;
    size = document.getElementById("ddlSize").value;
    keyword = document.getElementById("txtKeyword").value;
    association = document.getElementById("ddlAssociations").value;
    
    if(exp=='0')exp='';
    if(size=='0')size='';
    if(association=='0')association='';
    
    genre = getGenre();
    if(genre=='\'\'')genre='';



    getSearchDesign(exp,size,genre,keyword,association);
}

function reset(){
    document.getElementById("ddlSize").value = "0";
    document.getElementById("ddlExp").value = "0";
    checkAllGenreList(document.frmDesignDirectory,'chkListGenre');
    document.getElementById("txtKeyword").value = "";
    document.getElementById("ddlAssociations").value = "0";
    
    getDesignDirNP();
}
function uncheckAll(){
    totalPage = 1;
    currPage = 1;
    uncheckAllGenreList(document.frmDesignDirectory,'chkListGenre');
    getDesignDirNP();
}

function checkAll(){
    totalPage = 1;
    currPage = 1;
    checkAllGenreList(document.frmDesignDirectory,'chkListGenre');
    getDesignDirNP();
}

function uncheckAllGenreList(obj, prefix){
  var len = prefix.length;
  
  for (i=0; i<obj.elements.length; i++) {
    if (obj.elements[i].name.substring(0, len) == prefix) {    
      obj.elements[i].checked = false;
    }
  }     
}

function checkAllGenreList(obj, prefix){
  var len = prefix.length;
  
  for (i=0; i<obj.elements.length; i++) {
    if (obj.elements[i].name.substring(0, len) == prefix) {    
      obj.elements[i].checked = true;
    }
  }     
}

function getDesignDirByKey(e){    
    var keynum;
	var keychar;
    var exp = "";
    var size = "";
    var genre = "";
    
    
	if(e != "" && e != null){	    
		if(window.event){
			keynum = e.keyCode
		}
		else if(e.which){
			keynum = e.which
		}

		keychar = String.fromCharCode(keynum);
        
		if((keynum >= 65 && keynum <= 90) || (keynum >= 48 && keynum <= 57)) {
			keyword = keyword + keychar;
		}else if(keynum == 8) {
			keyword = keyword.substring(0,keyword.length-1);		
		}else if(keynum == 32) {
		    if(keyword.length > 0)
		    {
		        keyword = keyword + " ";
		    }
		}
		else{
			return;
		}
	}	
    
    exp = document.getElementById("ddlExp").value;
    size = document.getElementById("ddlSize").value;
    association = document.getElementById("ddlAssociations").value;
    
    if(exp=='0')exp='';
    if(size=='0')size='';
    if(association=='0')association='';   
    
    genre = getGenre();
    if(genre=='\'\'')genre='';
    currPage = 1;
    getSearchDesign(exp,size,genre,keyword,association);
}



//AJAX
var httpDesignDir;
var httpCaseStudy;
var httpPortfolio;
var httpMemberInfo;
var httpSinglePortfolio;
var httpBookMark;

function getSearchDesign(exp,size,genre,keyword,association) {
  if (httpDesignDir == null) {
    httpDesignDir = GetXmlHttpObject();
  }
  
  if (httpDesignDir != null)  {
    if (httpDesignDir.readyState == 4 || httpDesignDir.readyState == 0) {
      var url="process.aspx?type=SEARCH_MEMBER&exp="+exp+"&size="+size+"&genre="+genre+"&keyword="+keyword+"&page="+currPage+"&association="+association+"";
        
      httpDesignDir.onreadystatechange=drawResult;
      httpDesignDir.open("GET",url,true);
      httpDesignDir.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpDesignDir.send(null);
    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
  
}

function showLoading() {
  document.getElementById("DDListing").innerHTML = getLoadingBar();
}

function drawResult() {
  if (httpDesignDir != null)  {
    if (httpDesignDir.readyState==4 && httpDesignDir.status == 200)  {
      var xmlDoc = httpDesignDir.responseXML.documentElement; 
      var buff = "";
      var buff1 = "";
      var iconClass;
      var i=1;
      var arrBookmark = new Array();
      var noresult = 0;
      totalPage =0;
      
      buff += "<table cellpadding='0' cellspacing='0' border='0' style='padding-bottom:15px;'>";
      for (n=0; n<xmlDoc.childNodes.length; n++) {
        if (xmlDoc.childNodes[n].nodeName == "member") {

          var mNode = xmlDoc.childNodes[n];
          var strNew = "";

          structNew = nodeFieldsToArray(mNode);
          
          if(i%2!=0){
            buff += "<tr>";
          }
          
          
          if(i==1||i==2)
            iconClass = "IconWrapper1";
          else if(i==3||i==4)
            iconClass = "IconWrapper2";
          else if(i==5||i==6)
            iconClass = "IconWrapper3";
          else if(i==7||i==8)
            iconClass = "IconWrapper4";
          else 
            iconClass = "IconWrapper1";
          
          
          buff += "<td class='linedot' valign='top'>";
          buff += "<div class='divMWrapper'>\n";
          buff += "  <div class='"+iconClass+"'>\n";
          //buff += "    <a href='design_directory_detail.aspx?id=" + structNew["id"] + "' /><img class='noBorder' src='" + structNew["logo_name"] + "' class='imgIcon' style='width:60px;height:60px'/></a>\n"
          if(structNew["logo_name"]!="")
          {
            buff += "    <a onclick='Javascript:getMemberInfo(" + structNew["id"] + ")' href='#mid_"+structNew["id"]+"' /><img class='noBorder' src='" + structNew["logo_name"] + "' class='imgIcon' style='width:60px;height:60px'/></a>\n"
          }else{
            buff += "\n"
          }
          buff += "  </div>";
          buff += "  <div class='titleWrapper'><a onclick='Javascript:getMemberInfo(" + structNew["id"] + ")' href='#mid_"+structNew["id"]+"'/>"+structNew["company_name"]+"</a><div class='genreList'>"+structNew["genre_short"]+"</div></div>\n";
          if(arrBookmark[structNew["id"]]!=undefined&&arrBookmark[structNew["id"]]!="")
            buff += drawbookmarkBtn(structNew["id"],true,"designfirm");
          else
            buff += drawbookmarkBtn(structNew["id"],false,"designfirm");
          buff += "  <div style='clear:both;'></div>\n";
          buff += "</div>\n";
          buff += "</td>";
          
          
          if(i%2==0){
            buff += "</tr>";
          }
          
          i++;
            
        }else if(xmlDoc.childNodes[n].nodeName == "totalpage"){
           totalPage = xmlDoc.childNodes[n].childNodes[0].nodeValue;
        }else if(xmlDoc.childNodes[n].nodeName == "noresult"){
           buff1 = "<div style='margin-top:20px;margin-left:10px;' class='noresult'>There are no firms under this category.</div>";
           noresult = 1;
           break;
        }else if(xmlDoc.childNodes[n].nodeName == "bookmark"){
            var node = xmlDoc.childNodes[n]; 
            for (j=0; j<node.childNodes.length; j++) {
                if (node.childNodes[j].childNodes[0] != undefined) {
                  arrBookmark[(node.childNodes[j].childNodes[0].nodeValue)] = node.childNodes[j].childNodes[0].nodeValue;
                }
            }
        }
      }
      
      if(i%2==0){
         buff += "<td>&nbsp;</td></tr>";
      }
      buff += "</table>";
      
      
      buff += "<div style='clear:both'></div>";
      buff1 += "<div style='clear:both;'></div>";      
      buff += drawPaging(currPage,totalPage);
      
      if(noresult==1){
        document.getElementById("DDListing").innerHTML = buff1;
      }else{
        document.getElementById("DDListing").innerHTML = buff;
      }
      httpDesignDir = null;
    }
  }
}

function goPage(page){
    currPage = page;
    getDesignDirNP();
}



function drawPaging(cp,tp){
      var currentpage = parseInt(cp);
      var totalpage = parseInt(tp);
      var buff = "";
      var page_range = 3;
      var func_name = "goPage";
      var i;
      
      /*if(totalPage!=0){
          if(currentpage==1&&totalpage!=1){
            buff += "<div style='width:444px'><a href='javascript:goNextPage()' class='gonext'></a></div>";
          }
          else if(currentpage<totalpage)
          {
            buff += "<div style='width:444px'><a href='javascript:goNextPage()' class='gonext'></a>";
            buff += "<a href='javascript:goPrevPage()' class='goprev'></a></div>";
          }
          else if(currentpage==totalpage&&totalpage!=1){
            buff += "<div style='width:444px'><a href='javascript:goPrevPage()' class='goprev'></a></div>";
          }
          buff +="<div style='clear:both'></div>";
      }*/
      //document.getElementById("divMpPaging").innerHTML = buff;
      
      var curWin = Math.ceil((currentpage) / page_range); //this is the current "Window"
      var totalWin = Math.ceil(totalpage / page_range);
      var pStart = ((curWin -1) * page_range) + 1;
      
      buff += "<div style='float:right;width:30px'>&nbsp;</div>";     
      if (curWin < totalWin) {
        buff += "<a href='javascript:"+func_name+"("+ ((curWin * page_range) + 1) +")' class='gonext'></a>"; 
      }
      
      buff += "<div  class='paging'>";
      for (p=pStart; p<(pStart+page_range)&&p<=totalpage; p++) {
        if (p == currentpage) {
          buff += "&nbsp;<b>" + p + "</b>&nbsp;";
        }
        else {
          buff += "&nbsp;<a href='javascript:"+func_name+"("+ p +")'>" + p + "</a>&nbsp;";
        }
      }
      buff += "</div>";
      
      if (currentpage > page_range) {
        buff += "<a href='javascript:"+func_name+"("+ (((curWin-2) * page_range) + 1) +")' class='goprev'></a>";
      }
      
      buff +="<div style='clear:both'></div>";
      
      return buff;
}

function getMemberInfo(member_id){

    document.getElementById("poftfolioWrapper").style.display="";
    document.getElementById("ddcasestudy").style.display="none";
    document.getElementById("diVBackToCaseStudy").style.display="";
    
    clearInnerHTML();
        
    getPortfolio(member_id);
    getMemberDetail(member_id);
}

function hidePortfolio(){
    document.getElementById("poftfolioWrapper").style.display="none";
    document.getElementById("ddcasestudy").style.display="";
    document.getElementById("diVBackToCaseStudy").style.display="none";
}

function getPortfolio(member_id) {
    
  if (httpPortfolio == null) {
    httpPortfolio = GetXmlHttpObject();
  }
  
  if (httpPortfolio != null)  {
    if (httpPortfolio.readyState == 4 || httpPortfolio.readyState == 0) {
      var url="process.aspx?type=SEARCH_MEMBER_PORTFOLIO&member_id="+member_id+"";
      httpPortfolio.onreadystatechange=drawPortfolio;
      httpPortfolio.open("GET",url,true);
      httpPortfolio.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpPortfolio.send(null);
    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
}


function drawPortfolio() {
    
  var firstPortfolio = 0;
  if (httpPortfolio != null)  {
    if (httpPortfolio.readyState==4 && httpPortfolio.status == 200)  {
      var xmlDoc = httpPortfolio.responseXML.documentElement; 
      var buff = "";
      var buff1 = "";
      var iconClass;
      var divID;
      var i = 1
      var description = '';
      var title = '';
      
      for (n=0; n<xmlDoc.childNodes.length; n++) {
        if (xmlDoc.childNodes[n].nodeName == "member") {

          var mNode = xmlDoc.childNodes[n];
          var strNew = "";

          structNew = nodeFieldsToArray(mNode);
          description = structNew["description"];
          title = structNew["title"];
          description = title + "<br/><br/>" + description;
          
          //alert(title);
          divID = "divPfl"+i;
         
          if(i<=6){
          //buff = "<div><a href='javascript:void(0)' onclick='javascript:showPortfolioDesc("+i+");showPortfolioImage("+i+","+1+");' ><img src='"+structNew["icon"]+"' alt='' alt='' style='border:0px;vertical-align:bottom' /></a></div>"; 
              buff += "<div class='caseBox'><div>\n";
              buff += "  <a href='"+structNew["image_name"]+"' rel='lightbox[a]' title='" + description + "' style='display:block;float:left:border:0px'>\n";
              
              buff += "    <img src='"+(structNew["icon"])+"' alt='"+title.replace("'", "\'")+"'/>";
              buff += "  </a>\n";
              buff += "</div></div>\n";
              
              if(i%3==0){
                buff += "<div style='clear:both'></div>\n";
              }
          }else{
              buff1 += "<div class='caseBox'><div>\n";
              buff1 += "  <a href='"+structNew["image_name"]+"' rel='lightbox[a]' title='" + description + "' style='display:block;float:left:border:0px'>\n";
              
              buff1 += "    <img src='"+(structNew["icon"])+"' alt='"+title.replace("'", "\'")+"'/>";
              buff1 += "  </a>\n";
              buff1 += "</div></div>\n";
              
              if(i%3==0){
                buff1 += "<div style='clear:both'></div>\n";
              }  
          }
          
          i++;
        }
      }
      document.getElementById("divPflPanel1").style.display="none";
      if(i<=7){
        document.getElementById("divPflMorebtn").style.display="none";
        
      }else{
        document.getElementById("divPflMorebtn").style.display="";
      }
      
      buff += "<div style='clear:both'></div>";
      buff1 += "<div style='clear:both'></div>";
      document.getElementById("divPflPanel").innerHTML = buff;
      document.getElementById("divPflPanel1").innerHTML = buff1;
      
      httpPortfolio = null;
      if(i!=1){
        document.getElementById("portfolioList").style.display = "";
      }else{
        document.getElementById("portfolioList").style.display = "none";
      }
     
    }
  }
}

function showPflMore(){
    document.getElementById("divPflPanel1").style.display="";
    document.getElementById("divPflMorebtn").style.display="none";
}

function showPortfolioDesc(index){
	document.getElementById("pflDesc").innerHTML = 
    (portfolioTitleArray[index]==undefined?"": "<div><b>" + portfolioTitleArray[index] + "</b></div>") +
    (portfolioDescArray[index]==undefined?"": "<div>" + (portfolioDescArray[index]).replace(/\n/g, "<br />") + "</div>");
  document.getElementById("pflDesc").style.display = "";
  document.getElementById("pflDescTitle").style.display = "";
}

function showPortfolioImage(index,show){
  if(show==1){
		document.getElementById("divPflLargeImg").style.display = "";
		//document.getElementById("divPflPanel").style.display = "none";
    
    if (index == 3 || index == 6) {
      document.getElementById("divPflLargeImg").style.marginLeft = "108px";
    }
    else  {
      document.getElementById("divPflLargeImg").style.marginLeft = "0px";
    }
    
		document.getElementById("divPflLargeImg").innerHTML = 
      "<div style='position:absolute;margin-left:148px;z-index:10'><a href='javascript:clearInnerHTML()' style='display:block;height:20px;width:50px;text-align:center;padding:5px;text-decoration:none;color:#666666;background-color:#ffffff;'>Close</a></div>" +
      "<div style='position:absolute;width:208px;height:212px;overflow:hidden'><img id='img_pfl_" + index + "' src='"+portfolioImgArray[index]+"' alt='' /></div>";
		
    //alert(portfolioImgArray[index]);
  }else{
		document.getElementById("divPflLargeImg").style.display = "none";
		//document.getElementById("divPflPanel").style.display = "";
		document.getElementById("divPflLargeImg").innerHTML = "";
  }
}

function clearInnerHTML(){
    //document.getElementById("divPflPanel").style.display = "";
    document.getElementById("divPflLargeImg").style.display = "none";    
    document.getElementById("divPflLargeImg").innerHTML = "";
    document.getElementById("pflDesc").style.display = "none";
    document.getElementById("pflDescTitle").style.display = "none";
}

function drawFirstPortfolio(image,desc){
    document.getElementById("portfolioImage").innerHTML = "<img src='"+image+"' alt='' style='vertical-align:bottom'></img>";
    document.getElementById("Portfoliodesc").innerHTML = desc;
}

function getMemberDetail(member_id) {

  if (httpMemberInfo == null) {
    httpMemberInfo = GetXmlHttpObject();
  }
  
  if (httpMemberInfo != null)  {
    if (httpMemberInfo.readyState == 4 || httpMemberInfo.readyState == 0) {
      var url="process.aspx?type=SEARCH_MEMBER_BY_ID&member_id="+member_id+"";

      httpMemberInfo.onreadystatechange=drawMemberInfo;
      httpMemberInfo.open("GET",url,true);
      httpMemberInfo.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpMemberInfo.send(null);
    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
}

function drawMemberInfo() {
  if (httpMemberInfo != null)  {
    if (httpMemberInfo.readyState==4 && httpMemberInfo.status == 200)  {
      var xmlDoc = httpMemberInfo.responseXML.documentElement; 
      var buff = "";
      var iconClass;
      var i=1;
      for (n=0; n<xmlDoc.childNodes.length; n++) {
        if (xmlDoc.childNodes[n].nodeName == "member") {

          var mNode = xmlDoc.childNodes[n];
          var strNew = "";
          structdd = nodeFieldsToArray(mNode);
          
          var tel = structdd["contact_no"]==""?"-":structdd["contact_no"];
          var fax = structdd["fax_no"]==""?"-":structdd["fax_no"];

          
          document.getElementById("lblOverview").innerHTML = structdd["overview"]==""?"-":structdd["overview"];    
          document.getElementById("lblAward").innerHTML = structdd["award"]==""?"-":structdd["award"];
          document.getElementById("lblAward").innerHTML = structdd["award"]==""?"-":structdd["award"];
          document.getElementById("lblYoi").innerHTML = structdd["yoi"]==""?"-":structdd["yoi"];
          document.getElementById("lblIndustry").innerHTML = structdd["genre_list"]==""?"-":structdd["genre_list"];
          document.getElementById("lblNoEmployee").innerHTML = structdd["company_size"]==""?"-":structdd["company_size"];
          document.getElementById("lblExp").innerHTML = structdd["experience_year"]==""?"-":structdd["experience_year"];
          document.getElementById("lblLocation").innerHTML = structdd["location"]==""?"-":structdd["location"];
          if(structdd["website"]==""){
            document.getElementById("divWebsite").style.display = "none";
          }else{
            document.getElementById("divWebsite").style.display = "";
            document.getElementById("divWebsite").innerHTML = structdd["website"]==""?"":"<a href='http://"+structdd["website"]+"' target='_blank' class='ddehyLink'>View website</a>";
          }
          document.getElementById("lblContactNo").innerHTML ="Tel : " + tel + "<br/>" + "Fax : " + fax;
          document.getElementById("divEmail").innerHTML = structdd["email"]==""?"":"<a href='mailto:"+structdd["email"]+"' class='ddehyLink'>Send email</a>";
          document.getElementById("lblClientList").innerHTML = structdd["clientlist"]==""?"-":structdd["clientlist"];
          document.getElementById("divCompanyName").innerHTML = structdd["company_name"]==""?"-":structdd["company_name"];
          document.getElementById("lblAffA").innerHTML = structdd["aff_Association"]==""?"-":("<a href='"+structdd["aff_Associationlink"]+"' class='ddehyLink' target='_blank'>"+structdd["aff_Association"]+"</a>");
        }
      }
      
      httpMemberInfo = null;
    }
  }
}


function getSinglePortfolio(portfio_id) {

  if (httpSinglePortfolio == null) {
    httpSinglePortfolio = GetXmlHttpObject();
  }
  
  if (httpSinglePortfolio != null)  {
    if (httpSinglePortfolio.readyState == 4 || httpSinglePortfolio.readyState == 0) {
      var url="process.aspx?type=SEARCH_MEMBER_PORTFOLIO_BY_ID&portfolio_id="+portfio_id+"";

      httpSinglePortfolio.onreadystatechange=drawSinglePortfolio;
      httpSinglePortfolio.open("GET",url,true);
      httpSinglePortfolio.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpSinglePortfolio.send(null);
    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
}

function drawSinglePortfolio() {
  if (httpSinglePortfolio != null)  {
    if (httpSinglePortfolio.readyState==4 && httpSinglePortfolio.status == 200)  {
      var xmlDoc = httpSinglePortfolio.responseXML.documentElement; 
      var buff = "";
      var iconClass;
      var i=1;
      for (n=0; n<xmlDoc.childNodes.length; n++) {
        if (xmlDoc.childNodes[n].nodeName == "member") {

          var mNode = xmlDoc.childNodes[n];
          var strNew = "";

          structNew = nodeFieldsToArray(mNode);
          drawFirstPortfolio(structNew["image3"],structNew["description"]);
        }
      }
      
      httpSinglePortfolio = null;
    }
  }
}



function drawbookmarkBtn(id,isAdded,prefix){
    
    if(isAdded){
        //return "<div style='bookmark'><a id='"+prefix+"bookmark_"+id+"' href='javascript:addBookmark("+id+")' class='bookmarkAddedlink'  title='Add Bookmark'></a></div>";
        return "<div style='bookmark'><a id='"+prefix+"bookmark_"+id+"' href='javascript:;' class='bookmarkAddedlink'  title='Bookmarked'></a></div>";
    }else{
        return "<div style='bookmark'><a id='"+prefix+"bookmark_"+id+"' href='javascript:addBookmark("+id+")' class='bookmarklink'  title='Add Bookmark'></a></div>";
    }
}

function addBookmark(new_id) {
    
  if (httpBookMark == null) {
    httpBookMark = GetXmlHttpObject();
  }
  
  if (httpBookMark != null)  {
    if (httpBookMark.readyState == 4 || httpBookMark.readyState == 0) {
      var url="process.aspx?type=ADD_BOOKMARK_DESIGNDIR&id=" + new_id;
      httpBookMark.onreadystatechange=bookmarkstatus;
      httpBookMark.open("GET",url,true);
      httpBookMark.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpBookMark.send(null);

    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
}

function bookmarkstatus() {

  if (httpBookMark != null)  {

    if (httpBookMark.readyState==4 && httpBookMark.status == 200)  {
        
      var xmlDoc = httpBookMark.responseXML.documentElement; 
      var buff = "";
      for (n=0; n<xmlDoc.childNodes.length; n++) {
        if (xmlDoc.childNodes[n].nodeName == "error") {
          var newNode = xmlDoc.childNodes[n];
          structNew = nodeFieldsToArray(newNode);
          if(structNew["responseUrl"]!=""){
            location.href = structNew["responseUrl"];
            break;
          }
          break;
          
        }else if(xmlDoc.childNodes[n].nodeName == "Update") {
          
           var newNode = xmlDoc.childNodes[n];
          structNew = nodeFieldsToArray(newNode);
          
          
          if(structNew["description"]=="BOOKMARKADDED"&&structNew["bookmark_id"]!=""){
            
            if(document.getElementById("designfirmbookmark_"+structNew["bookmark_id"])!=undefined)
                document.getElementById("designfirmbookmark_"+structNew["bookmark_id"]).className = "bookmarkAddedlink";    
          }
          break;
        }
      }
      httpBookMark = null;
      
    }
    
  }
}

function getCaseStudy() {
  httpCaseStudy = GetXmlHttpObject();
  
  if (httpCaseStudy != null)  {
    if (httpCaseStudy.readyState == 4 || httpCaseStudy.readyState == 0) {
      var url="process.aspx?type=CASE_STUDY";
      httpCaseStudy.onreadystatechange=processCaseStudy;
      httpCaseStudy.open("GET",url,true);
      httpCaseStudy.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      httpCaseStudy.send(null);
    }
  }
  else  {
    alert ("Your browser does not support AJAX!");
  }
}

function processCaseStudy() {
  if (httpCaseStudy != null)  {
    if (httpCaseStudy.readyState==4 && httpCaseStudy.status == 200)  {
      var xmlDoc = httpCaseStudy.responseXML.documentElement; 
      
      var idx = 0;
      for (n=0; n<xmlDoc.childNodes.length && idx<9; n++) {
        if (xmlDoc.childNodes[n].nodeName == "casestudy") {

          var cNode = xmlDoc.childNodes[n];
          
          structCaseStudy = nodeFieldsToArray(cNode);

          idx++;
          arrCaseStudy[idx]['thumbpic'] = structCaseStudy['thumbpic'];
          arrCaseStudy[idx]['displaypic'] = structCaseStudy['displaypic'];
          arrCaseStudy[idx]['originalpic'] = structCaseStudy['originalpic'];
          arrCaseStudy[idx]['desc'] = structCaseStudy['description'];
          arrCaseStudy[idx]['title'] = structCaseStudy['title'];
          arrCaseStudy[idx]['designfirm_id']= structCaseStudy['designfirm_id'];
          arrCaseStudy[idx]['designfirm_name'] = structCaseStudy['designfirm_name'];
          
        }
      }
      
      displayCaseStudy();
    }
  }
}

function displayCaseStudy() {
  for (c=1; c<=9; c++) {
    if (arrCaseStudy[c]['thumbpic'] != '') {
      document.getElementById("caseStudy_" + c).innerHTML = 
        "<div><img src='" + arrCaseStudy[c]['thumbpic'] + "' alt='' onclick='showCaseStudy(" + c + ")' style='vertical-align:bottom;text-align:right' /></div>";
        
        //"<div><img src='" + arrCaseStudy[c]['thumbpic'] + "' alt='' onMouseOver='showCaseStudy(" + c + ")' /></div>";
    }
  }
}

function showCaseStudy(cid) {
  if ((cid != 0 && arrCaseStudy[cid]['thumbpic'] != '') || currentCaseStudy != 0) {
    var obj = document.getElementById("caseDisplay");
    if (cid != 0 && arrCaseStudy[cid]['thumbpic'] != '') {
      currentCaseStudy = cid;
      c = cid;
    }
    else  {
      c = currentCaseStudy;
    }
    
    /*
    var mL = 0; 
    var mT = 0;
    var row = Math.ceil(c / 3);
    var col = (c % 3==0? 3 : c % 3);
    
    //top left
    if (col <= 2 && row <= 2) {
      mL = (col -1) * 108;
      mT = (row -1) * 110;
    }
    //top right 
    else if (col <= 4 && row <= 2) {
      mL = (col -3) * 108;
      mT = (row -1) * 110;
    }
    //bottom left
    else if (col <= 2 && row <= 4) {
      mL = (col -1) * 108;
      mT = (row -3) * 110;
    }
    //bottom right
    else if (col <= 4 && row <= 4) {
      mL = (col -3) * 108;
      mT = (row -3) * 110;
    }
    */
    
    obj.innerHTML = 
      "<div style='position:absolute;width:325px;height:20px;padding:5px;z-index:5;background-color:#ffffff;opacity:0.75;filter:alpha(opacity=75);font-style:italic'>Read below for more information</div>" +
      "<div style='position:absolute;margin-left:265px;z-index:10'><a href='javascript:hideCaseStudy()' style='display:block;height:20px;width:50px;text-align:center;padding:5px;text-decoration:none;color:#666666;background-color:#ffffff;'>X</a></div>" +
      "<div style='position:absolute;width:325px;padding:10px;height:40px;background-color:#ffffff;z-index:10;margin-top:259px;opacity:0.75;filter:alpha(opacity=75);font-weight:bold'>" + arrCaseStudy[c]['title'] + "</div>" + 
      "<div style='position:absolute'><img src='" + arrCaseStudy[c]['displaypic'] + "' alt='' /></div>";
    //obj.style.marginLeft = mL + "px";
    //obj.style.marginTop = mT + "px";
    obj.style.visibility = "visible";
    
    
          
    if(arrCaseStudy[c]['designfirm_id']!=""&&arrCaseStudy[c]['designfirm_name']!=""&&arrCaseStudy[c]['designfirm_id']!="0"){
      document.getElementById("caseStudy_desc").innerHTML = "<a onclick='Javascript:getMemberInfo("+arrCaseStudy[c]['designfirm_id']+")' href='#mid_"+arrCaseStudy[c]['designfirm_id']+"' class='companylistLink'>"+arrCaseStudy[c]['designfirm_name']+"</a>"+"<div>&nbsp;</div>" + "<div><b>" + arrCaseStudy[c]['title'] + "</b></div><div>" + (arrCaseStudy[c]['desc']).replace(/\n/g, '<br />') + "</div>";  
    }else{
      document.getElementById("caseStudy_desc").innerHTML = "<div><b>" + arrCaseStudy[c]['title'] + "</b></div><div>" + (arrCaseStudy[c]['desc']).replace(/\n/g, '<br />') + "</div>";  
    }
    
    document.getElementById("caseStudy_desc").style.display = "block";
    document.getElementById("directorySlogan").style.display = "none";
  }
}

function hideCaseStudy() {    
  if (currentCaseStudy != 0) {
    document.getElementById("caseDisplay").style.visibility = "hidden";
    document.getElementById("caseDisplay").innerHTML = "";
    currentCaseStudy = 0;
    
    document.getElementById("caseStudy_desc").style.display = "none";
    document.getElementById("directorySlogan").style.display = "";
  }
}

function hideCaseStudy2() {      
    document.getElementById("caseDisplay").style.visibility = "hidden";
    document.getElementById("caseDisplay").innerHTML = "";
    document.getElementById("caseStudy_desc").style.display = "none";
    document.getElementById("directorySlogan").style.display = "";  
}

//detail page
function showProfile(){
    document.getElementById('divProfile').style.display = '';
    document.getElementById('divPortfolio').style.display = 'none';
    document.getElementById('aProfile').className = "secTabSel";
    document.getElementById('aPortfolio').className = "secTab";
}

function showPortfolio(){
    document.getElementById('divProfile').style.display = 'none';
    document.getElementById('divPortfolio').style.display = '';
    document.getElementById('aProfile').className = "secTab";
    document.getElementById('aPortfolio').className = "secTabSel";
}


