function alignColumnHeight(elem1, elem2, elem3, elem4) {
	if (document.getElementById(elem1) != null) {
		var navbar=document.getElementById(elem1);
		var jiveSpecific=document.getElementById(elem2);
		var promorail=document.getElementById(elem3);
		var footer=document.getElementById(elem4);
		var mainTable=document.getElementById('mainTable');
		var backgroundFiller=document.getElementById('backgroundFiller');

		A=navbar.offsetHeight;
		B=jiveSpecific.offsetHeight;
		C=promorail.offsetHeight;
		D=footer.offsetTop;

		if(B>C) {
			if (document.all) {
			navbar.style.height=B;
			promorail.style.height=B;
			backgroundFiller.style.height=B-4;
			mainTable.style.height=B-2;
			} else {
			navbar.style.height=B-0;
			promorail.style.height=B-2;
			backgroundFiller.style.height=B-3;
			mainTable.style.height=B-0;
			}
		}

		if(B<C) {
			if (document.all) {
			navbar.style.height=C+11;
			jiveSpecific.style.height=C+11;
			mainTable.style.height=C+10;
			backgroundFiller.style.height=C+8;
			} else {
			navbar.style.height=C+10;
			jiveSpecific.style.height=C+10;
			mainTable.style.height=C+10;
			backgroundFiller.style.height=C+8;
			}
		}
	}
}

function reportThread(email) {
	window.open(email+'/services/report/form?referringPage=' + document.URL,'reportThread','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=414,height=767,left=0,right=0');
}

function emailAFriend(sitehost) {
    // var sitehost = 'http://men.style.com'; 
	// document.location=sitehost + '/services/contact/friends?referringPage=' + document.URL;
	// window.open(sitehost + '/services/contact/friends?thread=' + top.location.href, 'emailAFriend', 'height=500,width=520,resizable=yes,scrollbars=yes');
	top.location.href = sitehost + '/services/emailafriend?referringPage=' + top.location.href;

}

//pagination functions
function gotoForumPage(forumID, pageStart, numPages, pageRequested) {
	if (pageRequested > 0 && pageRequested <= numPages) {
		userPageRequest = 'forum.jspa?forumID='+forumID+'&start='+((pageRequested-1)*pageStart);
		// alert(userPageRequest);
		document.location=userPageRequest;
	}
}
function gotoCategoryPage(categoryID, pageStart, numPages, pageRequested) {
	if (pageRequested > 0 && pageRequested <= numPages) {
		userPageRequest = 'category.jspa?categoryID='+categoryID+'&start='+((pageRequested-1)*pageStart)+'#threads';
		// alert(userPageRequest);
		document.location=userPageRequest;
	}
}
function gotoThreadPage(threadID, pageStart, tstart, numPages, pageRequested) {
        if (numPages != '') {
		if (pageRequested > 0 && pageRequested <= numPages) {
			userPageRequest = 'thread.jspa?threadID='+threadID+'&start='+((pageRequested-1)*pageStart)+'&tstart='+tstart;
			//alert(userPageRequest);
			document.location=userPageRequest;
		}
	}
}
function gotoOnlineUserPage(sort, range, pageStart, numPages, pageRequested) {
        if (numPages != '') {
		if (pageRequested > 0 && pageRequested <= numPages) {
			userPageRequest = 'online.jspa?start='+((pageRequested-1)*pageStart)+'&sort='+sort+'&range='+range;
//			alert(userPageRequest);
			document.location=userPageRequest;
		}
	}
}
function gotoSearchPage(searchParams, pageStart, numPages, pageRequested) {
	if (pageRequested > 0 && pageRequested <= numPages) {
		userPageRequest = 'search.jspa?'+searchParams+'&start='+((pageRequested-1)*pageStart);
//		alert(userPageRequest);
		document.location=userPageRequest;
	}
}

function GetCookie (name) {  

    var arg = name + "=";  
    var alen = arg.length;  
    var clen = document.cookie.length;  
    var i = 0;  

    while (i < clen) {    
      var j = i + alen;    
      if (document.cookie.substring(i, j) == arg) {
        return getCookieVal (j);
      }

      i = document.cookie.indexOf(" ", i) + 1;    

      if (i == 0) {
        break;
      }
    }  

    return null;
} 
       
function getCookieVal(offset) {

    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1) {
      endstr = document.cookie.length;
    }

    return unescape(document.cookie.substring(offset, endstr));

}  
   
function getWishlistCount(wishlistCookie) {

    var wishlistCount = 0;
    var index = 0;
    var value = wishlistCookie;

    if (wishlistCookie != null) {

      index =  wishlistCookie.indexOf('|');

      if(index == -1) {
        return 0;
      }
      else {
        while(index != -1 ) {
          wishlistCount = wishlistCount + 1;
          value = value.substring(index+1, value.length);
          index = value.indexOf('|');
        }
      }
    }
    else  {
       return 0;
    }

    return wishlistCount;
}