// JavaScript
var checkval;
var CatStr;
function bookmark(url,title) 
{ 
    url="http://www.helpwithforeclosure.com";
	if(document.all)
	{
	    window.external.AddFavorite(url, title);
	}
	else if (window.sidebar) // firefox
	{
		window.sidebar.addPanel(title, url, "");
	}
	else if(window.opera && window.print) // opera
	{
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
} 

function viewGnbsub(layerId,disp)
{
    try
    {
        var lid = layerId+"_aro" ;
        if(layerId!='' && disp!='')
        {
            if(disp != "none") 
            {
                //document.getElementById(layerId).style.display=disp;
                //document.getElementById(lid).style.display=disp;
                document.getElementById(layerId).style.visibility=disp;
            }
            else
            {
                //document.getElementById(layerId).style.display=disp;
                //document.getElementById(lid).style.display=disp;
                document.getElementById(layerId).style.visibility=disp;
            }
        }
    }catch(e){}
}

function popupwin(name)
{
    if(name!="")
    {
        //window.open(name);
    }
}
function loginform(action)
{
   try
   {
    if(action=="show")
    {
        document.getElementById('loginform').style.display="block";
        if(document.getElementById('ctl00_loginfrm_username')!=null)
        {
            //document.getElementById('ctl00_loginfrm_username').focus();
        }
        
    }
    if(action=="hide")
    {
        document.getElementById('loginform').style.display="none";
    }   
   }
   catch(e){ alert(e.message); }
}
function getYoutubeImage(url,size)
{
  if(url === null){ return ""; }

  size = (size === null) ? "big" : size;
  var vid;
  var results;

  results = url.match("[\\?&]v=([^&#]*)");

  vid = ( results === null ) ? url : results[1];

  if(size == "small"){
    return "http://img.youtube.com/vi/"+vid+"/2.jpg";
  }else {
    return "http://img.youtube.com/vi/"+vid+"/0.jpg";
  }
}
function urlredirect(url)
{
    try
    {
        if(url.length>0)
        {
            document.location.href = url;
        }
    }
    catch(e){alert(e.message);}
}
function IsMail(frm,ID)
{
   var reg = "/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/";
   var address = document.forms[frm].elements[id].value;
   if(reg.test(address) == false) 
   {
      alert('Invalid Email Address');
      return false;
   }

}

function Validate(id)
{
    var reg ="/^(['\*\&\$\%\~?/\<>^]) /";
    if(reg.test(document.getElementById(id).value) == false)
    {
        alert("Dont use ' \ * & $ % ~ ? / \ < > ^");
        return false;
    }
}
function OpenPopup(name) 
{
    try
    {
        window.open(name,"List","scrollbars=no,resizable=no,width=400,height=280");
    }
    catch(e)
    {
        alert(e.message);
    }
    return false;
}
function GoURL(url)
{
    try
    {
    window.open(url);
    }
    catch(e){alert(e.message);}
}
function gotologin()
{
    try
    {
        loginform("show");

	  	 $('#fade , .popup_block').fadeOut(function()
	  	 {
			$('#fade, a.close').remove();  
	        window.scroll(0,350);
	     }); //fade them both out
    }
    catch(e)
    {
       // alert(e.message);
    }
}

function checkCondition()
{
    if(window.close()==true)
    {
        checkval=1;
    }
    else
    {
        checkval=0
    }
}
window.onbeforeunload = function(evt) 
{
    if(checkval==1)
    {
        var message = 'Are you sure you want to leave? Your work is not saved!';
        if (typeof evt == 'undefined') 
        {//IE
            evt = window.event;
        }
        if (evt)
        {
            evt.returnValue = message;
        }
        return message;
    }
}
function forgotpass()
{
    try
    {
        window.location.href="ForgotPass.aspx";
    }
    catch(e)
    {
        alert(e.message);
    }
}
function showframe(id)
{
    try {
        document.getElementById(id).style.visibility="visible";
    }
    catch(e)
    {
        alert(e.message);
    }
}
function Loading(id,imgid) {
   if (document.getElementById(id) != null)
   document.getElementById(id).style.visibility="visible";
   
   if(document.getElementById(imgid)!=null)
    document.getElementById(imgid).style.display="none";
}
function getDataList(url)
{
    var XmlHttp = new CreateXHR();
	XmlHttp.open("GET",url,true);   
	XmlHttp.onreadystatechange = HandleResponse;
    XmlHttp.send(null);
}

function CreateXHR() 
{
    var request = false;
        try 
		{
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e)
		{
            try 
			{
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) 
			{
				try 
				{
					request = new XMLHttpRequest();
				}
				catch (e) 
				{
					request = false;
				}
            }
        }
    	return request;
}

function HandleResponse()
{
    if(XmlHttp.readyState == 4)
    {
        if(XmlHttp.status == 200)
        {
            //ClearAndSetStateListItems(XmlHttp.responseXML.documentElement);
        }
        else
        {
            alert("There was a problem retrieving data from the server." );
        }
    }
}
/////////////////popup win
function openpop(popname, popwidth, htmlcontent) {
    try {
        //Popup Append
        $('body').append('<div id=' + popname + ' class="popup_block"></div>');
        $('#' + popname).append(htmlcontent);

        //Fade in the Popup and add close button
        $('#' + popname).fadeIn().css({ 'width': Number(popwidth) }).prepend('<a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
        $('#' + popname).css({ 'width': Number(popwidth) }).prepend('<a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
        //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
        var popMargTop = ($('#' + popname).height() + 80) / 2;
        var popMargLeft = ($('#' + popname).width() + 80) / 2;

        //Apply Margin to Popup
        $('#' + popname).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });

        //Fade in Background
        $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
        $('#fade').css({ 'filter': 'alpha(opacity=70)' }).fadeIn(); //Fade in the fade layer

        //Close Popups and Fade Layer
        $('a.close').live('click', function() { //When clicking on the close or fade layer...
            $('#fade , .popup_block').fadeOut(function() {
                $('#fade, a.close').remove();
            }); //fade them both out

            return false;
        });


    } catch (e) { alert(e); }
    return;

}


function ShowDialog(url,height,width)
{
	//declare a string variable
    var retval = "";
	//show modal dialog box and collect its return value
	retval = window.showModalDialog(url,'',"dialogWidth:"+width+"px; dialogHeight:"+height+"px; center:on;status:off;dialogLeft:"+(screen.width-width)/2+"px; dialogTop:"+(screen.height-height)/2+"px; status:off;");

	//check if user closed the dialog 
	//without selecting any value
	if(retval!="" && retval!=null)
	{
		
	}
}

function numbersonly(e) {
    var unicode = e.charCode ? e.charCode : e.keyCode
    if (unicode != 8) { //if the key isn't the backspace key (which we should allow)
        if (unicode < 48 || unicode > 57) //if not a number
            return false //disable key press
    }
}

