// 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 openWindow(page, width, height) {
    window.open(page, "_blank", "height=" + height + ",width=" + width + ",status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
}

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 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 showhide(id)
{
var obj = document.getElementById(id);

	
	if(obj.style.display=='')
			{
			obj.style.display='none';
			
			}
			else
			{
			obj.style.display='';
			
			} 
			
			
	

}

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 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 + ")";
} 

/*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 popWin (winURL, winName, winWidth, winHeight, winFeatures){
	var scrW = screen.width;
	var scrH = screen.height;
	winFeatures = !winFeatures ? "toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizeable=0" : winFeatures;
	var hWin = window.open (winURL, winName, 'width=' + winWidth + ',height=' + winHeight + ',' + winFeatures + ',left=' +(scrW-winWidth)/2 + ',top=' + (scrH - winHeight - 40)/2);
	hWin.focus();
}

function GetCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function SetCookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "") + ";";
}

function ValidateNumbers(objInput, critName, chkEmpty){
	var chkValue = objInput.value;
	if (chkEmpty){
		if ((chkEmpty && chkValue != '') && (chkValue/chkValue == 1 || chkValue == 0))
			return true;
	} else {
		if (chkValue/chkValue == 1 || chkValue == 0)
			return true;
	}
	alert ("Please enter a valid numeric value for the '" + critName + "' field.");
	objInput.focus();
	objInput.select();
	return false;
}

function ValidateText(objInput, critName){
	if (objInput.value != '')
		return true;
	alert ("Please enter a valid value for the '" + critName + "' field.");
	objInput.focus();
	objInput.select();
	return false;
}

function validateText(objInput, critName){
	if (objInput.value != '')
		return false;
	alert ("Please enter a valid value for the '" + critName + "' field.");
	objInput.focus();
	objInput.select();
	return true;
}

function validateSel(obj, fieldName, ind){
	if (obj.selectedIndex > ind)
		return false;
	alert ("Please select a valid value for the '" + fieldName + "' field.");
	obj.focus();
	return true;
}

function StrRepl(str1, str2, str3){
	var nPos;
	var cTemp = str1;

	while ((nPos = cTemp.indexOf(str2)) >= 0){
	    cTemp = cTemp.substring(0, nPos) + str3 + cTemp.substring(nPos+str2.length, cTemp.length);
	}
	return cTemp;
}

function IsEmail(objInput, allowEmpty){
    if (allowEmpty && objInput.value == "")
        return true;
    if(objInput.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
		objInput.focus();
		alert("Invalid email address!");
        return false;
    } else {
        return true;
    }
}

function ClearForm(){
    if (confirm("Clear this form?"))
        document.forms[0].reset();
    return false;
}

