/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by ----- filename.js -----
 */

/* ----- site_functions.js ----- */
var textObj, picObj;
var scrollText = new scrollControl();
var numPics = 2;
var picCounter = 0;

function scrollControl() {
	this.counter = 1;
	this.text ="";
	
	this.theText = function() {
		switch(this.counter) {
			case 1:
				this.text= "The specialized physician JOB SITE with jobs for Orthopedists and every sub-specialty of Orthopedic Surgery.";
				this.upCounter();
				break;
			case 2:
				this.text= "The leading physician job site dedicated to connecting Orthopedists to jobs.";
				this.upCounter();
				break;
			case 3:
				this.text= "Becoming a household name for jobs in Orthopedics throughout the United States.";
				this.resetCounter();				
				break;

		}
		return this.text;
	}
			
	this.upCounter = function() {
		this.counter = this.counter+1;
	}
	
	this.resetCounter = function() {
		this.counter = 1;
	}

}

function menuOn(m)
{
	m.className = 'menuItemCurrent';
}

function menuOff(m)
{
	if(m != currentMenuObj) {
		m.className = 'menuItem';
	}
}
	
function setSlogon() {
	textObj.innerHTML = scrollText.theText();
}	

function setPic() {
	if(picCounter < numPics) {
		picCounter++;
	} else {
		picCounter = 1;
	}

	picObj.src = '/images/pic' + picCounter + '.jpg';

}

function initPage()
{
	if(document.getElementById("indexPic")) {		
		initFadeIn();
	}
	

        if(document.getElementById("PCR")) {
                resizeIFrame();
        }

	if(document.getElementById("portal-column-one")) {
		setContentHeight();
	}

	currentMenuObj = document.getElementById(currentMenu);
	currentMenuObj.className = 'menuItemCurrent';
	
}

function initFadeIn()
{
	if(document.getElementById("indexPic")) {		
		//textObj = document.getElementById('indexText');
		picObj = document.getElementById('indexPic');

		//setSlogon();
		setPic();
		
		for (var i=0;i<10;i++) {
			setTimeout('setOpacity('+i+')',100*i);
		}
	
		setTimeout("initFadeOut()",5000);
	}
}

function initFadeOut()
{
	for (var i=0;i<10;i++) {			
		setTimeout('setOpacity('+(10-i)+')',100*i);
	}

	setTimeout("initFadeIn()",1000);	
}

function setOpacity(value)
{
	//textObj.style.opacity = value/10;
	//textObj.style.filter = 'alpha(opacity=' + value*10 + ')';
	picObj.style.opacity = value/10;
	picObj.style.filter = 'alpha(opacity=' + value*10 + ')';
}


function sideMenuOver(div) {
	div.className = 'sideMenuItemOver';
}

function sideMenuOut(div) {
	div.className = 'sideMenuItem';
}


function setContentHeight() {
	var contentDiv = document.getElementById("portal-column-content");
	var cHeight;
	var leftDiv = document.getElementById("portal-column-one");
	var lHeight;
			
	if(contentDiv.offsetHeight){
		cHeight=contentDiv.offsetHeight;
		lHeight=leftDiv.offsetHeight;
	}
	else if(contentDiv.style.pixelHeight){
		 cHeight=contentDiv.style.pixelHeight;
		 lHeight=leftDiv.style.pixelHeight;
	}
	
	if(lHeight < cHeight) {
		if(cHeight < 500) { 
			cHeight=500;
			contentDiv.style.height = cHeight + 'px';
		}	
		leftDiv.style.height = cHeight + 'px';
	} else {
		contentDiv.style.height = lHeight + 'px';
	}
}

function resizeIFrame() {

var browseWidth, browseHeight;
var PCR = document.getElementById('PCR');

if (self.innerHeight) // all except Explorer
{
	browseHeight= self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
        browseHeight= document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
        browseHeight= document.body.clientHeight;
}

//alert(browseHeight);
PCR.style.height = (browseHeight *.65) + 'px';

}

/* ----- popup_menu.js ----- */
var menuwidth='165px' //default menu width
var menubgcolor='#3a7bb0'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (menuwidth!=""){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
		obj.visibility=visible
	else if (e.type=="click")
		obj.visibility=hidden
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
}

function populatemenu(menucontents,linkid){
	if (ie4||ns6)
	var html = "";
		if(menucontents == "about") {
			html = html + '<a target="_top" href="/about/about-us">Our&nbsp;Orthopedist&nbsp;Focus</a>';
			html = html + '<a href="#">Testimonials</a>';
			html = html + '<a target="_top" href="/about/research">Recruitment&nbsp;Research</a>';
		} else if (menucontents == "contact") {
			html = html + '<a target="_top" href="/contact">Contact&nbsp;Us</a>';
			html = html + '<a target="_top" href="/contact/terms-of-use">Terms&nbsp;of&nbsp;Use</a>';
			html = html + '<a target="_top" href="/contact/privacy">Privacy&nbsp;Policy</a>';
		} else if (menucontents == "faq") {
			html = html + '<a target="_top" href="/faq/seeker">Job&nbsp;Seeker&nbsp;FAQ</a>';
			html = html + '<a target="_top" href="/faq/employer">Employer&nbsp;FAQ</a>';
		} else if (menucontents == "physicians") {
			html = html + '<a target="_top" href="/physicians/login">Login</a>';
			html = html + '<a target="_top" href="/physicians/register">Register</a>';
			html = html + '<a target="_top" href="/physicians/why-register">Why&nbsp;Register?</a>';
			html = html + '<a target="_top" href="/cc">Career&nbsp;Center</a>';
		} else if (menucontents == "employers") {
			html = html + '<a target="_top" href="/employers/rates">Rate&nbsp;Information</a>';
			html = html + '<a target="_top" href="/employers/rates">View&nbsp;Sample&nbsp;Job</a>';
			html = html + '<a target="_top" href="/employers/why-register">Why&nbsp;Register?</a>';
			html = html + '<a target="_top" href="/employers/register">Register</a>';
			html = html + '<a target="_top" href="/employers/login">Login</a>';
		}
		dropmenuobj.innerHTML=html;
}


function dropdownmenu(obj, e, menucontents, linkid, menuwidth){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
		clearhidemenu()
	
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;

	populatemenu(menucontents,linkid)

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

	dropmenuobj.x=getposOffset(obj, "left")
	dropmenuobj.y=getposOffset(obj, "top")
	dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

