function DESemail(emailname,emailserver) {
	document.write("<a href='mailto:" + emailname + "@" + emailserver +"'>");
	document.write(emailname + "@" + emailserver); 
	document.write("</a>"); 
}

// Accessible Pop Ups
function DESopen(url,width,height,toolbar,scroll) {
	window.open(url, "", "scrollbars="+scroll+",toolbar="+toolbar+",height="+ height +",width="+width);
	return false;
}

function validaterequired() {
	// is the email address empty?
	if (document.survey.realemail.value.length == 0){
		alert("Please enter your email address");
		return false; // Don't submit form
	}
	// is the email address missing the obvious?
	if (document.survey.realemail.value.indexOf('@') == -1){
		alert("Please enter a valid email address");
		return false;
	}
	// is the name field empty?
	if (document.survey.realname.value.length == 0){
		alert("Please enter your name");
		return false; // Don't submit form
	}
	// if all is good, submit the form
	return true;
}

function DESphpnewads(zone) {
   if (!document.phpAds_used) document.phpAds_used = ',';
   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
   document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
   document.write ("http://www.fomhost2.com/oa2/adjs.php?n=" + phpAds_random);
   document.write ("&amp;what=zone:" + zone + "&amp;target=_blank&amp;blockcampaign=1");
   document.write ("&amp;exclude=" + document.phpAds_used);
   if (document.referrer)
      document.write ("&amp;referer=" + escape(document.referrer));
   document.write ("'><" + "/script>");
}


function DESopenxads(zone) {
//	document.write ("<!--//<![CDATA[");
   var m3_u = (location.protocol=='https:'?'https://www.fomhost2.com/openx/www/delivery/ajs.php':'http://www.fomhost2.com/openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + zone + "&amp;target=_blank");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//   document.write ("//]]>-->");
}

function DESopenxadsrobs(zone) {
//	document.write ("<!--//<![CDATA[");
   var m3_u = (location.protocol=='https:'?'https://d1.openx.org/ajs.php':'http://d1.openx.org/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + zone + "&amp;block=1&amp;blockcampaign=1&amp;target=_blank");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//   document.write ("//]]>-->");
}


var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

function switch_product_thumbs(siteId, divName, totalImgs) {
			for (var i=1; i<=totalImgs; i++) {
				var showDivName = siteId + '_photo_' + i;
				var showObj = document.getElementById(showDivName);
				if (showDivName == divName)
					showObj.style.display = 'block';
				else
					showObj.style.display = 'none';
			}
		}
		
		
		
 $(document).ready(function() {
    $('#login a').click(function() {
			$('#login_loggedin').toggleClass('hidden');
			$('#community_side_nav_nli').toggleClass('hidden');
			return false;
		});
			
 });
 

 
 $(document).ready(function() {
	$('#add_fav_site a').click(function() {
		 $.ajax({
        method: 'get',
        url: '/addsite_ajax.php',
        data: 'site_id=' + $(this).attr('thesite') +'&uid=' + $(this).attr('uid'),
        beforeSend: function() {
            $('#loading').fadeIn('slow');
        },
        complete: function() {
            $('#loading').fadeOut('slow');
        },
        success: function(html) {
            $('#add_fav_site').fadeIn('slow');
            $('#add_fav_site').html(html);
        }
    });
	return false;
	});
});

