$(document).ready(function () {
	
	//default - textbox	
	$('form input.defaulttext').each(function() {
		this.value = $(this).attr('title');
		$(this).focus(function() {
			if(this.value == $(this).attr('title'))
				this.value = '';
		});		
		$(this).blur(function() {
			if(this.value == '')
				this.value = $(this).attr('title');
		});	
	});
	
});



function setHomePageKV(strSiteURL)
{
	if (document.all)
	{
	  document.body.style.behavior='url(#default#homepage)';
	  document.body.setHomePage(strSiteURL);
	}
	else if (window.sidebar)
	{
		if(window.netscape)
		{
			try
			{  
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
			}  
			catch(e)  
			 {  
				alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");  
			 }
		} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage',strSiteURL);
	 }

}

function addBookmark(booktitle, bookurl)
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(booktitle, bookurl, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',bookurl);
		elem.setAttribute('title',booktitle);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(bookurl, booktitle);
}

// share link
function shareLink(type)
{
	/*
	if (typeof PATH_KIEMVIEC != "undefined")
		$('#share_link_hidden').load(PATH_KIEMVIEC+'jobseekers/index/sharelink');
	*/
	switch(type)
	{
		case 'yume':
			window.open('http://yume.vn/share_partners/link?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title), 'yumeshare','toolbar=1,status=0,width=980,height=475,scrollbars=1,menubar=1,location=1,resizable=1','_blank');
			break;
		case 'facebook':
			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title),'sharer',',width=980,height=600');		
			break;
		case 'yahoo':
			document.getElementById('yahoo_share').href="ymsgr:im?msg="+document.title+' '+location.href;		
			break;
		case 'yahoo2':
			document.getElementById('yahoo_share2').href="ymsgr:im?msg="+document.title+' '+location.href;		
			break;
		case 'twitter':
			window.open('http://twitter.com/home?status=Reading:'+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title),'sharer',',width=980,height=600');		
			break;
		case 'linkedin':
			window.open('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title),'sharer',',width=980,height=600');
			break;
		case 'google':
			window.open('https://www.google.com/bookmarks/mark?op=edit&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&annotation='+encodeURIComponent(document.title),'sharer',',width=980,height=600');	
			break;
	}
	return false;
}

// quick search box
function doQuickSearchJob()
{
	
	var frm = document.frmQuickSearchJob;		
	var keyword =  $("#txtKeyword").val().replace(/^\s+|\s+$/g, '');
		
	industry_id = frm.industry_id.value;
	location_id = frm.location_id.value;	
	if(keyword =='' && industry_id=='' && location_id=='')
	{
		jAlert(TXT_INPUT_SEARCH_CONDITION,TXT_MESSAGE_TITLE);
		return false;
	}
	
	if(keyword)
	{
		keyword = keyword.replace(/["'"]/g,'');
		if(parseInt(keyword.length) < 2 || checkInputNormalText(keyword)==false)
		{
			jAlert(TXT_INVALID_KEYWORD,TXT_MESSAGE_TITLE);		
			return false;
		}
	}
			
	return true;
	
}


function isBlackListTag(strCheck)
{
	var arrList = new Array();
	arrList[0] = "<";
	arrList[1] = ">";
	arrList[2] = "=";
	arrList[3] = "#";
	arrList[4] = "[";
	arrList[5] = "]";
	arrList[6] = "{";
	arrList[7] = "}";
	arrList[8] = "*";
	arrList[9] = "^";
	arrList[10] = "~";
	arrList[11] = "\$";
	for(var i=0;i<arrList.length;i++)
	{
		if(strCheck.indexOf(arrList[i])>=0)	
			return true;	
	}
	return false;
}

function checkInputNormalText(strCheck)
{
	if(strCheck=="" || isBlackListTag(strCheck)) return false;
	return true;
}


function jb_active_tab(obj){
		var curentTab=obj.id;
		var curentContent=curentTab.replace("tab","cont");

		curentContent_1=curentTab.replace("tab","cont");
		var tabs=$('#' + curentTab).parent().children();
		var contents=$('#' + curentContent).parent().children();

		$(tabs).each( function(){
				$(this).attr('class','');
		});		
		
		$(contents).each( function(){
				$(this).hide();
		});	
		
		$('#' + curentTab).addClass('active');
		//$('#' + curentContent).fadeIn('show');	
		$('#' + curentContent).show();	
		var pos =0;
		
		switch (curentTab){
			case "tab1":
				pos='left top';
				break;
			case "tab2":
				pos='left center';
				break;
			case "tab3":
				pos='left bottom';
				break;
			case "tab7":
				pos='left top';
				break;
			case "tab8":
				pos='left center';
				break;
			case "tab9":
				pos='left bottom';
				break;	
			}
			
		$('#'+curentTab).parent().css({'backgroundPosition':pos});

}

function checkEmail(stringIn) 
{
		
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
    var sEMail = stringIn;
    if (sEMail=="")
	{
		return (false);
	}
	else if (sEMail.search(re) == -1)
	{
		return (false);
	}
	else
	{
		return (true);
    }
}


