// Bookmarker java load
function bookmark(){
    var title="Farah &amp; Farah - Protecting You and Your Family Since 1979"
    var url="http://www.farahandfarah.com/"
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }
    else if( document.all ) window.external.AddFavorite( url, title);

}

// Top Menu Dropdown/Flyout java load
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// Video Widget scrollable list java load
$(function()
{
	$('.scroll-pane').jScrollPane();
	
	$('.scroll-up').bind('click',function(){                        
		$('.scroll-pane')[0].scrollBy(-36);                        
		return false;                    
	});
	
	$('.scroll-down').bind('click',function(){                        
		$('.scroll-pane')[0].scrollBy(36);                        
		return false;                    
	});
	
	$('#promcomp').click(function() {
	  $('#personal-promise').animate({
		height: 285
	  }, 1000, function() {
		// after animation completes...
	  });
	  // Same time as animation start...
	  var promDisplay = document.getElementById('prom-expand');
	  promDisplay.style.display = 'block';
	  var linkDisplay = document.getElementById('promcomp');
	  linkDisplay.style.display = 'none';
	});
	
	$('#promexp').click(function() {
	  $('#personal-promise').animate({
		height: 78
	  }, 1000, function() {
		// after animation completes...
		  var promDisplay = document.getElementById('prom-expand');
		  promDisplay.style.display = 'none';
		  var linkDisplay = document.getElementById('promcomp');
		  linkDisplay.style.display = 'block';
	  });
	});

});

// Video Widget video ajax java load
function vidLd(vidLd){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('viDisplay');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?vidShow=" + vidLd;
	ajaxRequest.open("GET", "video-ld.php" + queryString, true);
	ajaxRequest.send(null); 
}

// Success Stories java load
function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
 
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Medical Alerts java load
function mycarousel2_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
 
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#mycarousel2-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('#mycarousel2-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Free Reports java load
function mycarousel3_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
 
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#mycarousel3-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('#mycarousel3-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// side bar carousel java initialization (3)
jQuery(document).ready(function() {
								
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
		wrap: 'circular',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
	jQuery("#mycarousel2").jcarousel({
        scroll: 1,
		wrap: 'circular',
        initCallback: mycarousel2_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
	jQuery("#mycarousel3").jcarousel({
        scroll: 1,
		wrap: 'circular',
        initCallback: mycarousel3_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
});

// Tabbed Content Slider java load
$(document).ready(function(){   
    $("#featured > ul").tabs({fx:{width: "toggle"}}).tabs("rotate", 5000, true);   
	$("#featured").hover(   
		function() {   
			$("#featured > ul").tabs("rotate",0,true);   
		},   
		function() {   
		}   
	); 
});  

// Shadowbox java load
Shadowbox.init();

//------------------- OPEN NEW WINDOW -------------------//
var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable=no,toolbar=no,location=no,scroll=yes,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function popUpSWF(url, type, Width, Height, arg1, arg2, arg3){
	closeWin();
	tools = "resizable=no,toolbar=no,location=no,directories=no,status=no,scroll=no,scrollbars=no,menubar=no,width="+Width+",height="+Height+",left=0,top=0";
	if(type == "mp"){
		newWindow = window.open(url+"?bandwidth="+arg1+"&video="+arg2+"&lan="+arg3, 'newWin', tools);
	}
	if(type == "mc"){
		newWindow = window.open(url+"?category="+arg1+"&videoNum="+arg2, 'newWin', tools);
	}
	if(type == "bna"){
		newWindow = window.open(url+"?procedure="+arg1+"&caseNum="+arg2, 'newWin', tools);
	}
	newWindow.focus();
}


