//alert(navigator.appName+'--'+navigator.userAgent);
var br = navigator.userAgent;	
//if(br.match('Safari')) alert('1');

function goToUrl(id,type,url)
{
	window.open("http://www.yachtloop.com/ad_click_controller.php?id=YC-"+id+"&type="+type+"&lnk="+url);
}

function setFocusSearch()
{
	document.forms[0].textfield.focus();
}

function SearchRefresh(val,type)
{
	//alert(val);
	//alert(type);
	
	if(val===0)
	{
		document.frmsearchjob.searchCategory.value = "true";
	}
	
	if(type=="crew")
	{
		document.frmsearchjob.jobtype.value = "CREW";
		document.frmsearchjob.tech.value = "0";
		document.frmsearchjob.crew.value = val;
	}	
	
	else if(type=="tech")
	{
		document.frmsearchjob.jobtype.value = "TECH";
		document.frmsearchjob.crew.value = "0";
		document.frmsearchjob.tech.value = val;
	}
	// document.frmsearchjob.sayAlert.value = "NOSUBMIT";
	//document.frmsearchjob.textfield.value = "";
	document.frmsearchjob.action = "http://www.yachtloop.com/job_search.php";
	document.frmsearchjob.submit();
}
	
function checkLogin(jobId)
{
	document.frmsearchjob.appliedJobid.value=jobId;
	document.frmsearchjob.action = "http://www.yachtloop.com/job_search.php?startIndex=<?=$startIndex?>&textfield=<?=$originaltext?>&appliedJobid="+jobId;
	document.frmsearchjob.submit();				
}

function showApplied(ap_id)
{
	window.location.href='http://www.yachtloop.com/already_applied.php?appliedJobid='+ap_id;
}

function doSubmit()
{
	try
	{
		if(document.forms[0].textfield.value=='Search..') { document.forms[0].textfield.value=''; }
	}
	catch(e)
	{
	}	
}	
/////////////////////////////////////////////////
/////////////////////////////////////////////////

var isToolTipSet=false;
var id_to_show;
var td_to_show;
function hideElem(id)
{
	document.getElementById(id).style.display = 'none';
	document.getElementById(id_to_show).style.display = 'block';
	document.getElementById(td_to_show).style.display = 'block';
	isToolTipSet=false;
}

function opacity(id, millisec) 
{
	//speed for each frame
	var speed = Math.round(millisec / 50);
	var timer = 0;	
	for(i=0;i<=100;i++)
	{
		setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
		timer++;
	}	
}

function setOp(id)
{
	var object = document.getElementById(id).style;
	object.opacity = 0;
	object.MozOpacity = 0;
	object.KhtmlOpacity = 0;
	object.filter =0;
	opacity(id, 200);
}

function toggleOn(e, id, to_hide,td_hide)
{
	if(isToolTipSet===false) { isToolTipSet=true; }
	else { return 0; }
	
	//// Execute once on mouseover//
	var theBullet = document.getElementById(id);
	document.getElementById(to_hide).style.display='none';
	document.getElementById(td_hide).style.display='none';
	td_to_show = td_hide;
	id_to_show = to_hide;
	
	var posx = 0;
	var posy = 0;
	if (!e) { e = window.event; }
	if (e.pageX || e.pageY)
	{
		//posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		//posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}

  //posy=140; //fireox
  //posy=173; //fireox	  
  theBullet.style.top = posy + 'px'; // move into position
  //theBullet.style.left = posx + 'px';
  theBullet.style.top = '133px'; // move into position
  theBullet.style.left = '17px';
  theBullet.style.position = 'absolute'; 
  theBullet.style.display = 'block'; // make it appear
  
  setOp(id); // fading function call
}

//// fading effects functions ////





function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";	
}
//// fading effects functions : END////
function changeLIBg(id,classn)
{
	document.getElementById(id).className=classn+' show_pointer';
}
	
//
//
//
	
function changeImg(id,img)
{
	try
	{		
		document.getElementById(id).src=img;
	}
	catch(e)
	{}
}

function goTo(path)
{
	try
	{
		location.href=path;
	}
	catch(e)
	{}
}

function setImg(id,img)
{
	try
	{		
		document.getElementById(id).src= '<?=IMAGE_MAIN_PATH1?>menus/'+img;		
	}
	catch(e)
	{}
}

function inDefText(object)
{
	try
	{
		x=eval('document.forms[0].'+object);	
		if(x.value=='Search..') { x.value=''; }
	}
	catch(e)
	{		
	}	
}

function outDefText(object)
{
	
	try
	{
		x=eval('document.forms[0].'+object);	
		x.value=x.value.replace(/^([ ]+)$/,''); //remove blank spaces
		if(x.value=='') { x.value='Search..'; }
	}
	catch(e)
	{		
	}	
}

function checkKey(e)
{
	try
	{
		// IE 
		if(window.event) { keynum = e.keyCode; }
		else if(e.which) { keynum = e.which; }
		// Netscape/Firefox/Opera		
		if(keynum == 13) 
		{
			var x=eval('document.forms[0].textfield.value');
			x=x.replace(/^([ ]+)$/,''); //remove blank spaces
			try	{ document.forms[0].startIndex.value=0; } 
			catch(eee) { }
			if(x != '')
			{				
				document.forms[0].submit();
				return true;
			}
			else
			{
			return false;
			}
		}
		else { return false; }
	}
	catch(ee)
	{
	}
}

function doSubmit()
{
	
	try
	{
		var x=eval('document.forms[0].textfield.value');
		x=x.replace(/^([ ]+)$/,''); //remove blank spaces		
		if(x != '')
		{
			//document.forms[0].action='http://www.yachtloop.com/web_search_result.php?pr=webMetaSearch&query='+x;
			return true;
		}
		else 
		{
			document.forms[0].textfield.value='';
			alert('Please enter your search criteria !');
			return false;
		}
	}
	catch(e) { alert('Oops ! Sorry we are not able to process your request.\n Please try reloading the page.'); return false; }
	
}

function adjustTextBoxFocus(obj,mode){
		switch(mode){
			case"web":
				if(obj.value == 'Search the Web...'){
					obj.value='';
					//obj.className='srchboxfocus';
					obj.className='srch_box_bg_new';
				}
			break;

			case"dir":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;

				case"news":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;
			
			case"brok":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;

			case"job":
				if(obj.value == '' || obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;
			
			case"img":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;
		
		case"video":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;


		}
}

function adjustTextBoxBlur(obj,mode,searchMode){
		switch(mode){
			case"web":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;

			case"dir":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;

			case"news":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;
			
			case"brok":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;

			case"job":
				if(obj.value == ''){
					if(searchMode=='') { obj.value=''; }
					else { obj.value=''; }
					obj.className='srch_box_bg_new';
				}
			break;
			
			case"img":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;
			case"video":
				if(obj.value == ''){
					obj.value='';
					obj.className='srch_box_bg_new';
				}
			break;


		}
}

function slideSwitch() {
    var $active = $('#slideshow DIV.active');
    if ( $active.length === 0 ) { $active = $('#slideshow DIV:last'); }
    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});	
