// JScript source code

function openwindow(page, width, height)
{
window.open(page, "_blank", "height="+height+",width="+width+",status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
}


function PopupBlocked() {
    var pbt = window.open(null, "", "width=100,height=100");
    try { pbt.close(); return false; }
    catch (e) { return true; }
}

-


function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
strString = strString+"";
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function nosee(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function cansee(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}


function showhide_all_divs(link_id, default_text, switch_text)
{
var array_obj = document.getElementsByTagName("DIV");
var link_obj = document.getElementById(link_id);

	for(var i=0;i<=array_obj.length;i++)
	{
	//alert(array_obj[i].style.display);
	if(array_obj[i].style.display=='')
			{
			array_obj[i].style.display='none';
			link_obj.innerHTML = switch_text;
			}
			else
			{
			array_obj[i].style.display='';
			link_obj.innerHTML = default_text;
			} 
			
			
	}

}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function showhide_all_spans(link_id, default_text, switch_text)
{
var array_obj = document.getElementsByTagName("SPAN");
var link_obj = document.getElementById(link_id);

	for(var i=0;i<=array_obj.length;i++)
	{
	//alert(array_obj[i].style.display);
		if(array_obj[i])
		{
				if(array_obj[i].style.display=='')
				{
				array_obj[i].style.display='none';
				link_obj.innerHTML = switch_text;
				}
				else
				{
				array_obj[i].style.display='';
				link_obj.innerHTML = default_text;
				} 
		}	
			
	}

}

function togglevisible(divname, aname, showname, hidename)
	{
		var obj = document.getElementById(divname);
		var a = document.getElementById(aname);
		
		
		if(obj.style.display=="none")
		{
		obj.style.display="";
		a.innerHTML = hidename;
		}
		else
		{
		obj.style.display="none";
		a.innerHTML = showname;
		} 
	}
function showpreview(divname, aname, showname, hidename)
	{
		var obj = document.getElementById(divname);
		var a = document.getElementById(aname);
		
		
		if(obj.className=="preview_off")
		{
		obj.className="preview_on";
		a.innerHTML = hidename;
		}
		else
		{
		obj.className="preview_off";
		a.innerHTML = showname;
		} 
	}
	
function instr(v, srch)
{
 if (v.indexOf(srch)>0)
  {
  return true;
  }
  else
  {
  return false;
  }
}
	
	
function validemail(eml)
	{
	var reEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

        //make sure this is a valid email address
        if (!reEmail.test(eml)) {
            alert("Please enter a valid email address to continue.");
           return false;
        }
        return true;
    }
    
function feedpop(URL) {
var popthis=URL+'&s=2420';
var windowprops = "location=no,menubars=yes,toolbars=no,resizable=yes,scrollbars=no,width=620,height=230";
popup = window.open(popthis,"MenuPopup",windowprops);

}
function blogpop(URL) {
var windowblog = "location=yes,menubars=yes,toolbars=yes,resizable=yes,scrollbars=yes,width=400,height=560";
blogpopup = window.open(URL,"blogMenuPopup",windowblog);


}
function imagepop(URL) {

var windowblog = "location=yes,menubars=yes,toolbars=yes,resizable=yes,scrollbars=yes,width=600,height=560";
imagepop = window.open(URL,"imagepop",windowblog);


}

function premiumpop(URL) {
var windowblog = "location=yes,menubars=yes,toolbars=yes,resizable=yes,scrollbars=yes,width=400,height=350";
blogpopup = window.open(URL,"blogMenuPopup",windowblog);


}

function winPopup(page, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,location=no,menubars=no,toolbars=no,resizable=yes';
	var win = window.open(page, 'popup', winprops)
	return true;
}

function Minimize(obj)
{
obj.innerWidth = 100;
obj.innerHeight = 100;
obj.screenX = screen.width;
obj.screenY = screen.height;
alwaysLowered = true;
}

function Maximize(obj)
{
obj.innerWidth = screen.width;
obj.innerHeight = screen.height;
obj.screenX = 0;
obj.screenY = 0;
alwaysLowered = false;
}


function fader(id, oStart, oEnd, mSec) {
    
    var speed = Math.round(mSec / 100);
    var timer = 0;
    

    if(oStart > oEnd) {
        for(i = oStart; i >= oEnd; i--) {
            setTimeout("setOpacity(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(oStart < oEnd) {
        for(i = oStart; i <= oEnd; i++)
            {
            setTimeout("setOpacity(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function setOpacity(val, id) {
    var object = document.getElementById(id).style;
    object.display = "block";
    object.opacity = (val / 100);
    object.MozOpacity = (val / 100);
    object.KhtmlOpacity = (val / 100);
    object.filter = "alpha(opacity=" + val + ")";
        if(val == 0)
        document.getElementById(id).style.display = 'none';
} 

/*window.onload = function(e) {
   if (document.getElementById && document.getElementById("savedsize") != null) {
	if(document.getElementById("savedsize").value == "")
		resetsavedsize();
	else
		setsavedsize(document.getElementById("savedsize").value);
 
    document.getElementById("textSizer").style.cssText = "display: block; float: right;";
  }
}*/
var settosize=12
	
function getsavedsize() {
  return settosize;
}

function setsavedsize(newsize, obj) {
  settosize = newsize;
  if (document.getElementById) {
  	document.getElementById(obj).style.cssText = "font-size:"+settosize+"px";
  	
  }  
}

function resetsavedsize(obj) {
  settosize = 12;
 // document.getElementById("savedsize").value = savedsize;
  if (document.getElementById) {
  	document.getElementById(obj).style.cssText = "font-size:"+settosize+"px";  	
  }
}

function fontbigger(obj) {
  if (document.getElementById) {
    settosize++;
    //document.getElementById("savedsize").value = savedsize;
    document.getElementById(obj).style.cssText = "font-size:"+settosize+"px";
  }
}

function fontsmaller(obj) {
  if (document.getElementById) {
    settosize--;
    document.getElementById(obj).style.cssText = "font-size:"+settosize+"px";
  }
}

//==============cookies
// JScript source code
function setMPCookie (name,value,expires,path,theDomain,secure) { 
   value = escape(value);
   var theCookie = name + "=" + value + 
   ((expires)    ? "; expires=" + expires.toGMTString() : "") + 
   ((path)       ? "; path="    + path   : "") + 
   ((theDomain)  ? "; domain="  + theDomain : "") + 
   ((secure)     ? "; secure"            : ""); 
   document.cookie = theCookie;
} 

function getMPCookie(Name) { 
   var search = Name + "=" 
   if (document.cookie.length > 0) { // if there are any cookies 
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value 
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value 
         if (end == -1) end = document.cookie.length 
         return unescape(document.cookie.substring(offset, end)) 
      } 
   } 
} 
function delMPCookie(name,path,domain) {
   if (getMPCookie(name)) document.cookie = name + "=" +
      ((path)   ? ";path="   + path   : "") +
      ((domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function MPCookieExists(name){var rs=null;var mc=" " + document.cookie + ";";
var sn=" " + name + "=";var sc=mc.indexOf(sn);var ec;
if (sc!=-1) {sc+=sn.length;ec=mc.indexOf(";",sc);
rs=unescape(mc.substring(sc,ec));}return rs;}


function removehtml(v)
{
var oldtext = v;
var newtext = oldtext.replace(/<[^>]+>/g,'');
return newtext;
}

function countchars(val, max, msgname)
{
var txt = val.value;
var l = txt.length;
    
    if(l>max)
    {
      val.value = Left(txt, max)
    }

	if(document.getElementById(msgname))
		{
		if(l>0)
		{
			document.getElementById(msgname).innerHTML = '<b>Length: '+ l+'<br>Maximum: '+max+'</b>';
		}
		else
		{
			document.getElementById(msgname).innerHTML = '';
		}
		}
}

function setclassname(objname, newclass)
	{
		var obj = document.getElementById(objname);
		obj.className=newclass;
	}
//==============


function isWhitespace (charToCheck)
{
	var whitespaceChars = " \t\n\r\f";
	return whitespaceChars.indexOf (charToCheck) != -1;
}

function ltrim (str)
{
	for (var k = 0; k < str.length && isWhitespace (str.charAt (k)); k++);
	return str.substring (k, str.length);
}

function rtrim (str)
{
	for (var j = str.length-1; j >= 0 && isWhitespace (str.charAt (j)); j--);
	return str.substring (0, j+1);
}

function trim (str)
{
	return ltrim (rtrim (str));
}

function KeepAlphaNum (str)
{
	var result = "";
	for (var i = 0; i < str.length; i++)
	{
		var c = str.charAt (i).toLowerCase ();
		if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c == ' '))
		{
			result += c;
		}
	}
	result = trim (result);
	return result;
}

function addinnerhtml(elem, v)
{
obj = document.getElementById(elem);
	if(v!='')
	{
	obj.innerHTML=v;
	}
	else
	{
	obj.innerHTML='';
	}
}
 
 function removetags(v)
 {
 str = v;
 return str.replace(/<[^>]+>/g,'')
 }
 
 function sponsored_link_track(id)
 {
  ajaxgo('/advertising/track/?id='+id);
 }


function URLEncode (clearString) {
           var output = '';
           var x = 0;
           clearString = clearString.toString();
           var regex = /(^[a-zA-Z0-9_.]*)/;
           while (x < clearString.length) {
               var match = regex.exec(clearString.substr(x));
               if (match != null && match.length > 1 && match[1] != '') {
               	  output += match[1];
                  x += match[1].length;
               } else {
                  if (clearString[x] == ' ')
                      output += '+';
                  else {
                      var charCode = clearString.charCodeAt(x);
                      var hexVal = charCode.toString(16);
                      output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
                  }
               x++;
               }
           }
      return output;
  }