function $(ObjectId){
    return document.getElementById(ObjectId);
};

function OverBgImage(o,bg){
    $(o.id).style.backgroundImage=bg;
};

function OutBgImage(o,bg){
    $(o.id).style.backgroundImage=bg;
};

// News marquee ----------------------------------------------------------------------------------------------------

var delayb4scroll=0; //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1; //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1; //Pause marquee onMousever (0=no. 1=yes)?
var copyspeed=marqueespeed;
var pausespeed=(pauseit==0)? copyspeed: 0;
var actualheight='';

function scrollmarquee(){
    var s = 8;
    
    if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+s)){
        cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px";
    }
    else{
        cross_marquee.style.top=parseInt(marqueeheight)+s+"px";
    }
};

function initializemarquee(){
    if ($("vmarquee")){
        cross_marquee=$("vmarquee");
        cross_marquee.style.top=0;
        marqueeheight=$("marqueecontainer").offsetHeight;
        actualheight=cross_marquee.offsetHeight;
        if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
            //if Opera or Netscape 7x, add scrollbars to scroll and exit
            cross_marquee.style.height=marqueeheight+"px";
            cross_marquee.style.overflow="scroll";
            return;
        }

        setTimeout('lefttime=setInterval("scrollmarquee();",50)', delayb4scroll);
    }
};

if (window.addEventListener){
    window.addEventListener("load", initializemarquee, false);
}
else if (window.attachEvent){
    window.attachEvent("onload", initializemarquee);
}
else if (document.getElementById){
    window.onload=initializemarquee;
}

function openNew(id){
	window.open('http://www.mentormedic.com/New/' + id,'WinNews',config='status=yes,menubar=no, toolbar=no,location=no,scrollbars=yes,width=400,height=275,top=100,left=100');
};

// News marquee ----------------------------------------------------------------------------------------------------


var pic;
var t;

function checkChecks(o, cb, max){
    var c=0;
    for(var i=0; i<cb.length;i++){
        if(document.getElementById(cb[i]).checked){
            c++;
            if(c==max){
                for(var y=0;y<cb.length;y++){
                    if(document.getElementById(cb[y]).checked){
                        document.getElementById(cb[y]).disabled=false;   
                    }else{document.getElementById(cb[y]).disabled=true; }
                }
            }
            else{
                for(var y=0;y<cb.length;y++){
                    document.getElementById(cb[y]).disabled=false;
                }
            }
        }
    }
};

function ShowTxtForOtherDetails(cb,txt,cbs,max,RFV){
    if($(cb).checked){
        $(txt).style.visibility='visible';
        //alert($(RFV).id);
    }
    else{
        $(txt).style.visibility='hidden';
        //alert($(RFV).id);
    }
    checkChecks(cb, cbs, max);
};

function ShowTxt(txt,ddlId,value,tr){
    //alert([txt,ddlId,value]);
    var x=document.getElementById(ddlId);
    var v=x.options[x.selectedIndex].text;
    if(v==value){
        $(txt).style.visibility='visible';
        $(tr).style.display='block';
        if($(tr).style.display=='block'){
            $(txt).focus();
            $(txt).style.backgroundColor='Yellow';
        }
    }
    else{
        $(txt).style.visibility='hidden';
         $(tr).style.display='none';
         $(txt).style.backgroundColor='White';
    }
};

function passIt(c0,c1,c2,c4,c5,c6,c7,r0,r1,r2,r3,r5,r6,r7,r8,r9,cb){
    var b=false;
    for(var i=0; i<cb.length; i++){
        if(document.getElementById(cb[i]).checked){
            document.getElementById('infoSpan').innerHTML='';
            b=true;
            break;
        }
        else{
            document.getElementById('infoSpan').innerHTML='חובה לבחור לפחות שדה קטגוריה אחת';
            b=false;
        }
    }
    
    if(b==false){
        return;
    }
    var cont=[c0,c1,c2,c4,c5,c6,c7];
    var valid=[r0,r1,r2,r3,r5,r6,r7,r8,r9];
    var flg=[false,false,false,false,false,false,false,false];
    var name=document.getElementById(c0).value;
    var phone=document.getElementById(c1).value;
    var prePhone=document.getElementById(c2).value;
    var gender=(document.getElementById('Radio1').checked)? "0":"1";
    var email=document.getElementById(c4).value;
    var hLst = document.getElementById(c5);
	var hIndex  = hLst.selectedIndex;
	var day = hLst.options[hIndex].value;
    
    var hLst = document.getElementById(c6);
	var hIndex  = hLst.selectedIndex;
	var month = hLst.options[hIndex].value;
	
	var hLst = document.getElementById(c7);
	var hIndex  = hLst.selectedIndex;
	var year = hLst.options[hIndex].value;
	
	var path2="&name="+name+"&prePhone="+prePhone+"&phone="+phone+"&email="+email+"&gender="+gender+"&day="+day+"&month="+month+"&year="+year;
	
    var mainFlag=true;
    for(var i=0;i<valid.length;i++){
        document.getElementById(valid[i]).style.display="none";
    }
    
    var telnoRegxp = /[0-9]{7}/;
    var eml = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    
    if(document.getElementById(c0).value.length==0){//1
        document.getElementById(r0).style.display="inline";
        flg[0]=false;
    }
    else{
        document.getElementById(r0).style.display="none";
        flg[0]=true;
    }//1
    
    if(document.getElementById(c1).value.length==0){//2
        document.getElementById(r1).style.display="inline";
        flg[1]=false;
    }
    else if(document.getElementById(c1).value.length>0 & telnoRegxp.test(document.getElementById(c1).value)!=true){
        document.getElementById(r3).style.display="inline";
        flg[2]=false;
    }
    else{
        document.getElementById(r1).style.display="none";
        flg[1]=true;
        document.getElementById(r3).style.display="none";
        flg[2]=true;
    }//2
    
    if(document.getElementById(c2).selectedIndex==0){//3
        document.getElementById(r2).style.display="inline";
        flg[3]=false;
    }
    else{
        document.getElementById(r3).style.display="none";
        flg[3]=true;
    }//3
        
    if(document.getElementById('Radio1').checked || document.getElementById('Radio2').checked){//4
        document.getElementById('radioSpan').style.display="none";
        flg[4]=true;
    }
    else{
        document.getElementById('radioSpan').style.display="inline";
        flg[4]=false;
    }//4
    
    if(document.getElementById(c4).value==0){//5
        document.getElementById(r5).style.display="inline";
        flg[5]=false;
    }

    else if(document.getElementById(c4).value!=0 & eml.test(document.getElementById(c4).value)!=true){
        document.getElementById(r6).style.display="inline";
        flg[6]=false;
    }
    else{
        document.getElementById(r5).style.display="none";
        flg[5]=true;
        document.getElementById(r6).style.display="none";
        flg[6]=true;
    }//5
    
    if(document.getElementById(c5).selectedIndex==0){//6
        document.getElementById(r7).style.display="inline";
        flg[7]=false;
    }
    else{
        document.getElementById(r7).style.display="none";
        flg[7]=true;
    }//6
    
    if(document.getElementById(c6).selectedIndex==0){//7
        document.getElementById(r8).style.display="inline";
        flg[8]=false;
    }
    else{
        document.getElementById(r8).style.display="none";
        flg[8]=true;
    }//7
    
    if(document.getElementById(c7).selectedIndex==0){//8
        document.getElementById(r9).style.display="inline";
        flg[9]=false;
    }
    else{
        document.getElementById(r9).style.display="none";
        flg[9]=true;
    }//8
    
    var path = '';var f = true; var counter=0;
    var o;
    for(var i=0; i<cb.length;i++){
        if(document.getElementById(cb[i]).checked){
            o=document.getElementById(cb[i]);
            if(f){
               path +='?v'+counter+'='+o.value;
               f = false;
               counter++;
            }
            else{
               path +='&v'+counter+'='+o.value;
               counter++;
            }
        }
    }
    
    for(var i=0;i<flg.length;i++){
        if(flg[i]==false){
            mainFlag=false;break;
        }
    }
    
    if(mainFlag){
        window.open('NewsLetter.aspx'+path+path2, '_parent');
    }
};
    
function countChangeAndManage(size, field, info, button, quota){
	MaxLen  = size; 
	Msg     = window.document.getElementById(field).value;
	Msglen  = Msg.length;
    
    var my_array = new Array();
    my_array = Msg.split(' ');
    
    for(var i = 0; i < my_array.length; i++)
    {
        if (my_array[i].length > quota)
        {
            my_array[i] = my_array[i].substring(0,quota);
		    window.document.getElementById(field).value = my_array.join(' ');
            window.document.getElementById(button).disabled = true;
		    window.document.getElementById(info).innerHTML 	= "<span style='color:#ff0000;font-size:11px;font-weight:bold;'>נא לא להכניס יותר מ-" + quota + " תווים ברצף</span>";
        }
        else if (my_array[i].length <= quota)
        {
	        if (Msglen > MaxLen) 
	        {
		        window.document.getElementById(info).innerHTML 	= "<span style='color:#ff0000;font-size:11px;font-weight:bold;'>נא לא להכניס יותר מ-" + MaxLen + " תווים</span>";
		        window.document.getElementById(field).value = Msg.substring(0,MaxLen);
		        window.document.getElementById(button).disabled = true;
	        }
	        else if (Msglen <= MaxLen)
	        {
		        window.document.getElementById(info).innerHTML = MaxLen-Msglen + " תווים";
		        window.document.getElementById(button).disabled = false;
	        }
        }
    }
};

function showBullon(f,navigateUrl,imageUrl,oper,e,type){
    var vnt;
    vnt = e||window.event||event;
     
	if (document.getElementById('contSpan').style.visibility == 'hidden')
	{
	    if (document.all) 
		    { 
		        if(type == '0') //image
	            {
		            pic 	= new Image;
		            pic.src = imageUrl;
    		        
		            document.getElementById('contImg').src = pic.src;
		            document.getElementById('contUrl').href = navigateUrl;
		            document.getElementById('t_img').style.display = 'inline';
		            document.getElementById('t_fl').style.display = 'none';
		        }
		            else if (type == '1') //flash
		        {
		            document.getElementById('flashUrl').innerHTML = "<table cellpadding='0' cellspacing='0' width='200' border='0'><tr><td style='height:80px;'><object type='application/x-shockwave-flash' data='" + imageUrl + "' width='200' height='80'><param name='movie' value='" + imageUrl + "' /></object></td></tr></table>";
		            document.getElementById('t_img').style.display = 'none';
		            document.getElementById('t_fl').style.display = 'inline';
		        }
		   }
		   else
		   {
		        if(type == '0') //image
	            {
		            pic 	= new Image;
		            pic.src = imageUrl;
    		        
		            document.getElementById('contImg').src = pic.src;
		            document.getElementById('contUrl').href = navigateUrl;
		            document.getElementById('t_img').style.display = 'inline';
		            document.getElementById('t_fl').style.display = 'none';
		        }
		        else if (type == '1') //flash
		        {
		            document.getElementById('flashUrl').innerHTML = "<table cellpadding='0' cellspacing='0' width='200' border='0'><tr><td style='height:80px;'><object type='application/x-shockwave-flash' data='" + imageUrl + "' width='200' height='80'><param name='movie' value='" + imageUrl + "' /></object></td></tr></table>";
		            document.getElementById('t_img').style.display = 'none';
		            document.getElementById('t_fl').style.display = 'inline';
		        }
		   }
		
		if (document.all) 
		{ 
			document.getElementById('contSpan').style.top = vnt.clientY + getScroll_Top_IE() - 100 + "px";
			document.getElementById('contSpan').style.left = vnt.clientX + getScroll_Left_IE() - 120 + "px";
		}
		else
		{
			document.getElementById('contSpan').style.top = vnt.pageY - 40 + "px";
			document.getElementById('contSpan').style.left = vnt.pageX - 100 + "px";
		}
		
		document.getElementById('contSpan').style.visibility = 'visible';
		document.getElementById(f.id).className = 'green2';
	}
	else
	{
		document.getElementById(f.id).className = 'green1';
	}
};

function getScroll_Top_IE()
{
	return (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getScroll_Left_IE()
{
	return (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function checkEmailNotEmpty(checkBox,textBox,span)
{
    if(document.getElementById(textBox).value.length < 5)
    {
        document.getElementById(checkBox).checked = false;
        document.getElementById(span).innerText = ' - אין כתובת דואר אלקטרוני';
    }
    else
    {
        document.getElementById(span).innerText = '';
    }
}
                                                                 
function getDisableTimeOut(obj,ms)
{
    obj.disabled = true;
    var t = setTimeout(function(){document.getElementById(obj.id).disabled = false;},ms)
}                                                              
                                                                
function makeLink(this_field) 
{
    if (document.selection)
    {
  	    var str = document.selection.createRange().text;
      	
  	    if(str.length > 0)
  	    {
  		    document.getElementById(this_field).focus();
      		
  		    var my_link = prompt("URL כתובת","http://");

  		    if (my_link != null && my_link.length > 2) 
  		    {
  			    if(my_link.match("http://") == null)
			    {
				    my_link = "http://" + my_link;
			    }
    			
    		    var sel = document.selection.createRange();
			    sel.text = "[a href='" + my_link + "' id='link']" + str + "[/a]";
  		    }
  		    return;
  	    }
  	    else
  	    {
  		    return alert('יש לסמן את הטקסט ממנו יבוצע הקישור ולהקיש על הכפתור');
  	    }
  	}
  	else if (document.getSelection || window.getSelection)
  	{
  	    var str = document.getElementById(this_field).value.substring(document.getElementById(this_field).selectionStart,document.getElementById(this_field).selectionEnd);
      	
  	    if(str.length > 0)
  	    {
  		    document.getElementById(this_field).focus();
      		
  		    var my_link = prompt("URL כתובת","http://");

  		    if (my_link != null && my_link.length > 2) 
  		    {
  			    if(my_link.match("http://") == null)
			    {
				    my_link = "http://" + my_link;
			    }
    			
    		    var area = document.getElementById(this_field);
			    area.value = area.value.substr(0, area.selectionStart) + "[a href='" + my_link + "' id='link']" + str + "[/a]" + area.value.substr(area.selectionEnd);
  		    }
  		    return;
  	    }
  	    else
  	    {
  		    return alert('יש לסמן את הטקסט ממנו יבוצע הקישור ולהקיש על הכפתור');
  	    }
  	}
}	

function SearchMe(url, field, info) 
{
	if (document.getElementById(field).value.length <= 1) 
	{
		document.getElementById(info).innerHTML = "הכנס לפחות 2 תווים";
	} 
	else
	{
	    window.location = url + "?s=" + document.getElementById(field).value;
		//window.location = "SearchArticles.aspx?s=" + document.getElementById(field).value;		
	}	
}

function Open_Review(open_id){
	ReviewOpen = window.open('Open_ReviewsArticle.aspx?tgv=' + open_id,'ReviewOpenWin'  + open_id,'status=yes,menubar=yes, toolbar=no,location=no,scrollbars=yes,width=400,height=400');
};

function Add_Review(id){
	ReviewAdd = window.open('Add_ReviewsArticle.aspx?art=' + id,'ReviewAddWin','toolbar=no,location=no,scrollbars=no,width=400,height=480');
};

function Open_ReviewResearch(open_id){
	ReviewOpen = window.open('Open_ReviewsResearch.aspx?tgv=' + open_id,'ReviewResearchOpenWin'  + open_id,'status=yes,menubar=yes, toolbar=no,location=no,scrollbars=yes,width=400,height=400');
};

function openPicWithZoom(pic) 
{
	zoom = window.open(pic,'zoomWin',config='toolbar=no,location=yes,scrollbars=yes');
}

function Add_ReviewResearch(this_id) 
{
	ReviewAdd = window.open('Add_ReviewsResearch.aspx?res=' + this_id,'ReviewResearchAddWin',config='toolbar=no,location=no,scrollbars=no,width=400,height=480');
}

function getScroll(field)
{
	document.getElementById(field).value = document.body.scrollTop;
}
	
function scroll_Top(pixels)
{
	window.scrollBy(0,pixels); 
}

function scrollBottom(control)
{
    alert(control);
}
        
function scrollToBottom()
{
	document.getElementById("last_td").scrollIntoView(true);
}
  
function openWin(url,win,prop)
{
	window.open(url,win,prop);
}
    
function HandlerOnReadyStateChange()
{
    if (xhttp.readyState==4)
    {
        //alert(xhttp.readyState);
    }
}

function addFav(url,title)
{
    window.external.addFavorite(url, title); 
    return false;
}

function addHomePage(field)
{
    field.style.behavior='url(#default#homepage)';
    field.setHomePage(document.location.href); 
    return false;
}

function LargerFontClass()
{  
    if(document.styleSheets)
    { 
        if (document.styleSheets(1).href != null)
        { 
            if (document.styleSheets(1).href.slice(8,9) < 3)
            {
                var n = eval(document.styleSheets(1).href.slice(8,9)); 
                n = eval(n + 1);
                document.styleSheets(1).href = "fontsize" + n + ".css";
                var sss = document.styleSheets(1).href;
                SaveCookies(document.styleSheets(1).href);
            }
        }  
    }
}   
   
function Hide() 
{
    document.forms[0].print_top.style.visibility='hidden';
    document.forms[0].print_bottom.style.visibility='hidden';
    document.forms[0].back_top.style.visibility='hidden';
    document.forms[0].back_bottom.style.visibility='hidden';
}
 
function Show() 
{
    document.forms[0].print_top.style.visibility='visible';
    document.forms[0].print_bottom.style.visibility='visible';
    document.forms[0].back_top.style.visibility='visible';
    document.forms[0].back_bottom.style.visibility='visible';
}
                                                     
function SmallerFontClass()
{        
    if(document.styleSheets)
    { 
        if (document.styleSheets(1).href != null)
        { 
            if (document.styleSheets(1).href.slice(8,9) > 1)
            {
                var n = eval(document.styleSheets(1).href.slice(8,9));
                n = eval(n - 1);
                document.styleSheets(1).href = "fontsize" + n + ".css";
                SaveCookies(document.styleSheets(1).href);
            }
        }  
    }
}

function SaveCookies(value) 
{
    var name = 'beok1stylesheet';
    var tmp = value;
    expires = new Date(); 
    expires.setTime(expires.getTime() + (1000 * 86400 * 365)); 
    SetCookies(name, tmp, expires); 
}

function SetCookies(name, value, expires)
{
    if (!expires)
    {
        expires = new Date();
    }
    
    document.cookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString() + ";path=/";
}

function GetStyleCookies() 
{
    document.styleSheets(1).href = GetCookies('beokstylesheet');
}

function GetCookies(name) 
{
     var arg = name + "=";
     var alen = arg.length;
     var clen = document.cookie.length;
     var endstr = 0;
     var i = 0;
     
     while (i < clen) 
     {
        var j = i + alen;
        
        if (document.cookie.substring(i, j) == arg)
        {
            endstr = document.cookie.indexOf (";", j);
             
            if (endstr == -1)
            {
                endstr = document.cookie.length;
            }
             
            return unescape(document.cookie.substring(j, endstr));
        }
        
        i = document.cookie.indexOf(" ", i) + 1;
        
        if (i == 0) 
        { 
            break; 
        }
     }
     return 'fontsize1.css';
}

function openNews(ID) 
{
	NewsOpen = window.open('WinNews.aspx?new_id=' + ID,'WinNews',config='status=yes,menubar=no, toolbar=no,location=no,scrollbars=yes,width=400,height=275,top=100,left=100');
}

function AddReview(this_id) 
{
	ReviewAdd = window.open('AddReviewsArticle.aspx?art=' + this_id,'ReviewAddWin',config='toolbar=no,location=no,scrollbars=no,width=400,height=480');
}

function AddBlogReview(this_id) 
{
	ReviewAdd = window.open('AddReviewsBlog.aspx?blg=' + this_id,'ReviewBlogAddWin',config='toolbar=no,location=no,scrollbars=no,width=400,height=500');
}

function keyPress(textArea, maxLength) 
{
    if(textArea.value.length > maxLength) 
    {
      	textArea.value = textArea.value.substring(0,maxLength);
	}
}

function OpenReview(id,no) 
{
	ReviewOpen = window.open('OpenReviewsArticle.aspx?tgv=' + id + '&no=' + no,'ReviewOpenWin',config='status=yes,menubar=yes, toolbar=no,location=no,scrollbars=yes,width=400,height=400,top=100,left=100');
}	
	
function OpenBlogReview(id,no) 
{
	ReviewOpen = window.open('OpenReviewsBlog.aspx?tgv=' + id + '&no=' + no,'ReviewBlogOpenWin',config='status=yes,menubar=yes, toolbar=no,location=no,scrollbars=yes,width=400,height=400,top=100,left=100');
}	

function OpenMessage(id) 
{
	ReviewOpen = window.open('OpenUsersMessage.aspx?msgID=' + id,'OpenUsersMessage',config='status=yes,menubar=no, toolbar=no,location=no,scrollbars=yes,width=400,height=490,top=100,left=100');
}

function OpenSentMessage(id) 
{
	ReviewOpen = window.open('OpenSentUsersMessage.aspx?msgID=' + id,'OpenUsersMessage',config='status=yes,menubar=no, toolbar=no,location=no,scrollbars=yes,width=400,height=490,top=100,left=100');
}

function count_change(size,field,info) 
{
	MaxLen  = size; 
	Msg     = window.document.getElementById(field).value;
	Msglen  = Msg.length;

	if (Msglen > MaxLen) 
	{
		window.document.getElementById(info).innerHTML 	= "<span style='color:#ff0000;font-size:11px;font-weight:bold;'>נא לא להכניס יותר מ-" + MaxLen + " תווים</span>";
		window.document.getElementById(field).value = Msg.substring(0,MaxLen);
	}
	else if (Msglen <= MaxLen)
	{
		window.document.getElementById(info).innerHTML = MaxLen-Msglen + " תווים";
	}
}
	
function DisplayBody(elem)
{
	 if (document.all)
     {
        if (document.getElementById(elem).style.display == 'block')
	    {
		    document.getElementById(elem).style.display='none';
		    document.getElementById(elem).style.visibility='hidden';
	    }
	    else
	    {
		    document.getElementById(elem).style.display = 'block';
		    document.getElementById(elem).style.visibility='visible';
	    }
	 }
	 else
	 {
        if (document.getElementById(elem).style.display == 'table-row')
	    {
		    document.getElementById(elem).style.display='none';
		    document.getElementById(elem).style.visibility='hidden';
	    }
	    else
	    {
		    document.getElementById(elem).style.display = 'table-row';
		    document.getElementById(elem).style.visibility='visible';
	    }        
	}
}

function makeItalic() 
{
	var oSelection = document.selection.createRange();

	if(oSelection.text) 
	{
		oSelection.text = '[i]' + oSelection.text + '[/i]';
	}
}

function makeUnderline() 
{
	var oSelection = document.selection.createRange();

	if(oSelection.text) 
	{
		oSelection.text = '[u]' + oSelection.text + '[/u]';
	}
}

function makeBold() 
{
	var oSelection = document.selection.createRange();

	if(oSelection.text) 
	{
		oSelection.text = '[b]' + oSelection.text + '[/b]';
	}
}

function setColor(color){
    var oSelection = document.selection.createRange();
	if(oSelection.text){
		oSelection.text = "[color:" + color + " id='123']" + oSelection.text + "[/color]";
	}
};

function HidSpan(o){
	if (document.getElementById(o).style.display == 'none'){
		document.getElementById(o).style.display = 'block';
	}
	else{
		document.getElementById(o).style.display = 'none';
	}
};

function Replacer(val, control){
    document.getElementById(control).value = val.replace("", "");
    return val;
}

function checkEnter(e){ //e is event object passed from function invocation
    var characterCode; // literal character code will be stored in this variable;

    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        characterCode = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event;
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
    }

    if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
        //document.forms[0].submit(); //submit the form
        //window.location = "SearchArticles.aspx?s=Shimi" //+ document.getElementById('search').value;
    }
    else{
        return true;
    }
}

function doClick(buttonName, e){
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
    var key;
    if(window.event){
        key = window.event.keyCode; //IE
        
        if (key == 13){ //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null){ //If we find the button click it
                cancelEvent(e);
                Search('txtSearch','spnSearch');
                //btn.click();
                event.keyCode = 0;
            }
        }
    }
    else{
        key = e.which; //firefox
        
        if (key == 13){ //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null){ //If we find the button click it
                //btn.onclick();
                cancelEvent(e);
                Search('txtSearch','spnSearch');
                event.keyCode = 0;
            }
        }
    }
};
  
//Main search box
function Search(txtBox,resSpan){
    $(resSpan).innerHTML="";
    if($(txtBox).value.length<=1)
        $(resSpan).innerHTML="At least two characters required";
    else{
        window.open("http://www.mentormedic.com/Search/"+$(txtBox).value,"_self");
        //window.open("http://localhost/DIRECT_TRADE_PROJECTS/MENTORMEDIC/MentorMedic/Search/"+$(txtBox).value,"_self");
    }
};

this.cancelEvent=function(e){
	if(e){//Moz
		e.preventDefault();
		e.stopPropagation();
	}
	if(window.event){//IE
		window.event.returnValue = false;
	}
};

function getFocus(){
    document.getElementById('search').focus();
};

function loadjscssfile(filename, filetype){
    if(filetype=="js"){
      var fileref=document.createElement('script');
      fileref.setAttribute("type","text/javascript");
      fileref.setAttribute("src", filename);
    }
    else if(filetype=="css"){
      var fileref=document.createElement("link");
      fileref.setAttribute("rel", "stylesheet");
      fileref.setAttribute("type", "text/css");
      fileref.setAttribute("href", filename);
    }
    if(typeof fileref!="undefined")
    document.getElementsByTagName("head")[0].appendChild(fileref);
};

function AgentPage(){
    window.open('AgentInYourArea.aspx', '_self');
};

var win = null;
function OpenNewWin(mypage,myname,w,h,scroll,resizable,titlebar,toolbar){
    LeftPosition=(screen.width)?(screen.width-w)/2:0;
    TopPosition=80;//(screen.height)?(screen.height-h)/2:0;
    settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=' + resizable + ',titlebar=' + titlebar + ',toolbar=' + toolbar;
    win=window.open(mypage,myname,settings);
};

function GetFrame(L,w,h){
    document.getElementById(L).style.visibility='visible';
    document.getElementById(L).style.display='block';
//    alert(document.getElementById(L).style.visibility);
    LeftPosition=(screen.width)?(screen.width-w)/2:0;
    TopPosition=200;//(screen.height)?(screen.height-h)/2:0;
    document.getElementById(L).style.left=LeftPosition;
    document.getElementById(L).style.top=TopPosition;
};

function HideFrame(L){
    //alert(document.getElementById(L).style.visibilty);
    document.getElementById(L).style.visibility='hidden';
    document.getElementById(L).style.display='none';
};

function Rep(str){
    return str = str.replace(/\[/ig, "<").replace(/\]/ig, ">");
};
