	/***************************************************************************
	 * Cool DHTML tooltip script II- Dynamic Drive DHTML code library
	 * (www.dynamicdrive.com) This notice MUST stay intact for legal use Visit
	 * Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	 **************************************************************************/

	var offsetfromcursorX=12 // Customize x offset of tooltip
	var offsetfromcursorY=10 // Customize y offset of tooltip

	var offsetdivfrompointerX=10 // Customize x offset of tooltip DIV
									// relative to pointer image
	var offsetdivfrompointerY=14 // Customize y offset of tooltip DIV
									// relative to pointer image. Tip: Set it to
									// (height_of_pointer_image-1).

	document.write('<div id="dhtmltooltip"></div>') // write out tooltip DIV
	document.write('<img id="dhtmlpointer" src="/idlogik/img/tiparrow.gif" style="visibility:hidden">') // write
																					// out
																					// pointer
																					// image

	var ie=document.all
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

	var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

	function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
	tipobj.innerHTML=thetext
	enabletip=true
	return false
	}
	}

	function positiontip(e){
	if (enabletip){
	var nondefaultpos=false
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	// Find out how close the mouse is to the corner of the window
	var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
	var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

	var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
	var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

	var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

	// if the horizontal distance isn't enough to accomodate the width of the
	// context menu
	if (rightedge<tipobj.offsetWidth){
	// move the horizontal position of the menu to the left by it's width
	tipobj.style.left=curX-tipobj.offsetWidth+"px"
	nondefaultpos=true
	}
	else if (curX<leftedge)
	tipobj.style.left="5px"
	else{
	// position the horizontal position of the menu where the mouse is
	// positioned
	tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
	pointerobj.style.left=curX+offsetfromcursorX+"px"
	}

	// same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight){
	tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
	nondefaultpos=true
	}
	else{
	tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
	pointerobj.style.top=curY+offsetfromcursorY+"px"
	}
	tipobj.style.visibility="visible"
	if (!nondefaultpos)
	pointerobj.style.visibility="visible"
	else
	pointerobj.style.visibility="hidden"
	}
	}

	function hideddrivetip(){
	if (ns6||ie){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
	}
	}

	document.onmousemove=positiontip
	/* Flex Level Drop Down Menu v1.1
	* Created: Jan 5th, 2010 by DynamicDrive.com. This notice must stay intact for usage 
	* Author: Dynamic Drive at http://www.dynamicdrive.com/
	* Visit http://www.dynamicdrive.com/ for full source code
	*/

	//Version 1.1 (Feb 19th, 2010): Each flex menu (UL) can now be associated with a link dynamically, and/or defined using JavaScript instead of as markup.

	//Usage: $(elementselector).addflexmenu('menuid', options)
	//ie:
	//jQuery(document).ready(function($){
		//$('a.mylinks').addflexmenu('flexmenu1') //apply flex menu with ID "flexmenu1" to links with class="mylinks"
	//})

	//jQuery.noConflict()

	var flexdropdownmenu={
		arrowpath: 'arrow.gif', //full URL or path to arrow image
		animspeed: 200, //reveal animation speed (in milliseconds)
		showhidedelay: [150, 150], //delay before menu appears and disappears when mouse rolls over it, in milliseconds

		//***** NO NEED TO EDIT BEYOND HERE
		startzindex:1000,
		builtflexmenuids: [], //ids of flex menus already built (to prevent repeated building of same flex menu)

		positionul:function($, $ul, e, $anchor){
			var istoplevel=$ul.hasClass('jqflexmenu') //Bool indicating whether $ul is top level flex menu DIV
			var docrightedge=$(document).scrollLeft()+$(window).width()-40 //40 is to account for shadows in FF
			var docbottomedge=$(document).scrollTop()+$(window).height()-40
			if (istoplevel){ //if main flex menu DIV
				var offsets=$anchor.offset()
				var anchorsetting=$anchor.data('setting')
				var x=offsets.left+anchorsetting.useroffsets[0]+(anchorsetting.dir=="h"? $anchor.outerWidth() : 0) //x pos of main flex menu UL
				var y=offsets.top+anchorsetting.useroffsets[1]+(anchorsetting.dir=="h"? 0 : $anchor.outerHeight())
				x=(x+$ul.data('dimensions').w > docrightedge)? x-(anchorsetting.useroffsets[0]*2)-$ul.data('dimensions').w+$anchor.outerWidth()+(anchorsetting.dir=="h"? -($anchor.outerWidth()*2) : 0) : x //if not enough horizontal room to the ridge of the cursor
				y=(y+$ul.data('dimensions').h > docbottomedge)? y-(anchorsetting.useroffsets[1]*2)-$ul.data('dimensions').h-$anchor.outerHeight()+(anchorsetting.dir=="h"? ($anchor.outerHeight()*2) : 0) : y
			}
			else{ //if sub level flex menu UL
				var $parentli=$ul.data('$parentliref')
				var parentlioffset=$parentli.offset()
				var x=$ul.data('dimensions').parentliw //x pos of sub UL
				var y=0
				x=(parentlioffset.left+x+$ul.data('dimensions').w > docrightedge)? x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge parent LI
				y=(parentlioffset.top+$ul.data('dimensions').h > docbottomedge)? y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih : y
			}
			$ul.css({left:x, top:y})
		},
		
		showbox:function($, $flexmenu, e){
			clearTimeout($flexmenu.data('timers').hidetimer)
			$flexmenu.data('timers').showtimer=setTimeout(function(){$flexmenu.show(flexdropdownmenu.animspeed)}, this.showhidedelay[0])
		},

		hidebox:function($, $flexmenu){
			clearTimeout($flexmenu.data('timers').showtimer)
			$flexmenu.data('timers').hidetimer=setTimeout(function(){$flexmenu.hide(100)}, this.showhidedelay[1]) //hide flex menu plus all of its sub ULs
		},


		buildflexmenu:function($, $menu, $target){
			$menu.css({display:'block', visibility:'hidden', zIndex:this.startzindex}).addClass('jqflexmenu').appendTo(document.body)
			$menu.bind('mouseenter', function(){
				clearTimeout($menu.data('timers').hidetimer)
			})		
			$menu.bind('mouseleave', function(){ //hide menu when mouse moves out of it
				flexdropdownmenu.hidebox($, $menu)
			})
			$menu.data('dimensions', {w:$menu.outerWidth(), h:$menu.outerHeight()}) //remember main menu's dimensions
			$menu.data('timers', {})
			var $lis=$menu.find("ul").parent() //find all LIs within menu with a sub UL
			$lis.each(function(i){
				var $li=$(this).css({zIndex: 1000+i})
				var $subul=$li.find('ul:eq(0)').css({display:'block'}) //set sub UL to "block" so we can get dimensions
				$subul.data('dimensions', {w:$subul.outerWidth(), h:$subul.outerHeight(), parentliw:this.offsetWidth, parentlih:this.offsetHeight})
				$subul.data('$parentliref', $li) //cache parent LI of each sub UL
				$subul.data('timers', {})
				$li.data('$subulref', $subul) //cache sub UL of each parent LI
				$li.children("a:eq(0)").append( //add arrow images
					'<img src="'+flexdropdownmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />'
				)
				$li.bind('mouseenter', function(e){ //show sub UL when mouse moves over parent LI
					var $targetul=$(this).css('zIndex', ++flexdropdownmenu.startzindex).addClass("selected").data('$subulref')
					if ($targetul.queue().length<=1){ //if 1 or less queued animations
						clearTimeout($targetul.data('timers').hidetimer)
						$targetul.data('timers').showtimer=setTimeout(function(){
							flexdropdownmenu.positionul($, $targetul, e)
							$targetul.show(flexdropdownmenu.animspeed)
						}, flexdropdownmenu.showhidedelay[0])
					}
				})
				$li.bind('mouseleave', function(e){ //hide sub UL when mouse moves out of parent LI
					var $targetul=$(this).data('$subulref')
					clearTimeout($targetul.data('timers').showtimer)
					$targetul.data('timers').hidetimer=setTimeout(function(){$targetul.hide(100).data('$parentliref').removeClass('selected')}, flexdropdownmenu.showhidedelay[1])
				})
			})
			$menu.find('ul').andSelf().css({display:'none', visibility:'visible'}) //collapse all ULs again
			this.builtflexmenuids.push($menu.get(0).id) //remember id of flex menu that was just built
		},

		

		init:function($, $target, $flexmenu){
			if (this.builtflexmenuids.length==0){ //only bind click event to document once
				$(document).bind("click", function(e){
					if (e.button==0){ //hide all flex menus (and their sub ULs) when left mouse button is clicked
						$('.jqflexmenu').find('ul').andSelf().hide()
					}
				})
			}
			/**delete this line by simon
			if (jQuery.inArray($flexmenu.get(0).id, this.builtflexmenuids)==-1) //if this flex menu hasn't been built yet
			**/
				this.buildflexmenu($, $flexmenu, $target)
			if ($target.parents().filter('ul.jqflexmenu').length>0) //if $target matches an element within the flex menu markup, don't bind onflexmenu to that element
				return
			var useroffsets=$target.attr('data-offsets')? $target.attr('data-offsets').split(',') : [0,0] //get additional user offsets of menu
			useroffsets=[parseInt(useroffsets[0]), parseInt(useroffsets[1])]
			$target.data('setting', {dir: $target.attr('data-dir'), useroffsets: useroffsets}) //store direction (drop right or down) of menu plus user offsets
			$target.bind("mouseenter", function(e){
				$flexmenu.css('zIndex', ++flexdropdownmenu.startzindex)
				flexdropdownmenu.positionul($, $flexmenu, e, $target)
				flexdropdownmenu.showbox($, $flexmenu, e)
			})
			$target.bind("mouseleave", function(e){
				flexdropdownmenu.hidebox($, $flexmenu)
			})
		}
	}

	jQuery.fn.addflexmenu=function(flexmenuid, options){
		var $=jQuery
		return this.each(function(){ //return jQuery obj
			var $target=$(this)
			if (typeof options=="object"){ //if options parameter defined
				if (options.dir)
					$target.attr('data-dir', options.dir) //set/overwrite data-dir attr with defined value
				if (options.offsets)
					$target.attr('data-offsets', options.offsets) //set/overwrite data-offsets attr with defined value
			}
			if ($('#'+flexmenuid).length==1) //check flex menu is defined
				flexdropdownmenu.init($, $target, $('#'+flexmenuid))
		})
	};

	//By default, add flex menu to anchor links with attribute "data-flexmenu"
	jQuery(document).ready(function($){
		var $anchors=$('*[data-flexmenu]')
		$anchors.each(function(){
			$(this).addflexmenu(this.getAttribute('data-flexmenu'))
		})
	})


	//ddlistmenu: Function to define a UL list menu dynamically

	function ddlistmenu(id, className){
		var menu=document.createElement('ul')
		if (id)
			menu.id=id
		if (className)
			menu.className=className
		this.menu=menu
	}

	ddlistmenu.prototype={
		addItem:function(url, text, target){
			var li=document.createElement('li')
			li.innerHTML='<a href="'+url+'" target="'+target+'">'+text+'</a>'
			this.menu.appendChild(li)
			this.li=li
			return this
		},
		addSubMenu:function(){
			var s=new ddlistmenu(null, null)
			this.li.appendChild(s.menu)
			return s

		}
	}
/************global variable***************************/
var gloadingDiv;
$(
function(){
	gloadingDiv=$('#gloadingDiv').html();
    if (getCookie('idlogikPageTips')==""){
    	$(".page-tips").show('fast');
		$("#show-page-tips-button").css({'visibility':'hidden'});
		gtipsIsOpen='true';
    }else{
    	$(".page-tips").hide('fast');
		$("#show-page-tips-button").css({'visibility':'visible'});
		gtipsIsOpen='false';
    }

}
);

$.ajaxSetup({
	  data: {'ajaxCall':'true'},
});

/** *************** */

	function eraseText(elem){
		elem.value = "";
	}
	
	var eraseCount = 0;
	function eraseTextOnce(elem){
		if(eraseCount>0) return;
		
		elem.value = "";
		eraseCount++;		
	}
	
	function link(str){
		location.href=str;
	}
	
	function openCloseDisplay(id){
		
		var elem = document.getElementById(id);
		if(elem.style.display=='block'){
			elem.style.display='none';
		} else {
			elem.style.display='block';
		}	
	}
	function openCloseDisplayForce(id,action){
		var elem = document.getElementById(id);
		if(action=="open"){
			elem.style.display='block';
		} else {
			elem.style.display='none';
		}
	
	}
	
	
	function checkValidEmail2(str){
		
		if(str!=null){
			if(str.indexOf("@")!=-1 && str.length>5 && str.indexOf(".")!=-1){
				return true;
			} else {
				return false;
			}
		}	
	}
	
	function checkValidEmail(id){
		var elem = document.getElementById(id);
		if(elem!=null){
			if(elem.value.indexOf("@")!=-1 && elem.value.length>5 && elem.value.indexOf(".")!=-1){
				return true;
			} else {
				return setErrorBlock("<li>You have entered an invalid email address");
			}
		}	
	}
	
	function isFormEmpty(elem,id,name){
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.value==null || elem.value.length==0){
				if(name!=null){
					alert("The " + name + " field must contain a value");
				} else {
					alert("The field must contain a value");
				}
				elem.focus();
				return false;
			}
		}
		return true;		
	}
	
	function isFormSelected(elem,id,name){
		
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.options.selectedIndex==null || elem.options[elem.options.selectedIndex].value.length==0){
				if(name!=null){
					alert("Please select an option from the " + name + " field before continuing");
				} else {
					alert("Please select an option before continuing");
				}
				elem.focus();
				return false;
			} 			
		}
		return true;
	}
	var futureDateLabelArr;
	var pastDateLabelArr;
	var compareDateLabelArr
	
	function formErrorCheck(f){		
	
		var errorStr = "";
		var elem;
		var formVal;
		var radioErrorStr = "";
		
		// check alert string
		var anotherFunc = document.getElementById("anotherFunc");
		
		if(anotherFunc!=null && anotherFunc.value.length>0){
			if(!eval(anotherFunc.value)){
				return false;
			}
		}
	
		for(i=0;i<formElemArr.length;i++){
			
			elem = f[formElemArr[i]];
			
			if(elem!=null){	
				radioErrorStr = "";				
				if(elem.length>0){	
					var radioName = new Array();
							
					for(j=0;j<elem.length;j++){		
					// alert(elem[j]);
						if(elem[j]!=null && elem[j].type=="radio"){
							radioErrorStr = "<li>" + labelArr[i] + " must be checked";
							if(elem[j].checked==true){
								radioErrorStr="";
								break;
							}
						}
					}
					
				}
				errorStr+=radioErrorStr;
				if(elem.type == "text" || elem.type == "textarea" || elem.type == "button"){
     				formVal = elem.value;
     				formVal = formVal.replace(/\s+/g,"");     				
					if(formVal==null || formVal.length==0){						
						errorStr += "<li>" + labelArr[i] + " is empty";
					} 
				} else if(elem.type=="select-one" && elem.options.selectedIndex!=null && elem.options.selectedIndex >= 0 && elem.options.selectedIndex < elem.options.length){
				
					formVal = elem.options[elem.options.selectedIndex].value;
					if(formVal==null || formVal.length==0 || formVal=="null"){
						errorStr += "<li>" + labelArr[i] + " must be selected";
					}
				} else if(elem.type=="checkbox"){
					if(elem.checked==false){
						errorStr+="<li>" + labelArr[i] + " must be checked";
					}
				} 
				
			}
		}
		
		if(futureDateLabelArr!=null && futureDateLabelArr.length>0){
			errorStr+=testFutureDate();
		}
		if(pastDateLabelArr!=null && pastDateLabelArr.length>0){
		
		}
		if(compareDateLabelArr!=null && compareDateLabelArr.length>0){
			errorStr+=testEndAfterStartDate();
		}
		
		if(errorStr.length>0){
			return setErrorBlock(errorStr);
		}
		
		return true;	
	}
	
	function setErrorBlock(errorStr){
		
		var errorBlk = document.getElementById("jsErrorDiv");
			errorBlk.style.display="block";
			errorBlk.innerHTML="<div class=\"alert-red\">"+errorStr+"</div>";
			
			document.location='#';
			return false;
	}
	
	function makeDate(day,month,year){
		var date = new Date();
			date.setDate(day);
			date.setMonth(month);
			date.setYear(year);
		return date;
	}
	function testEndAfterStartDate(){
		var errorStr = "";
		var start = new Date();
			// today.setDate(today.getDay());
		var end = new Date();
		for(i=0;i<compareDateId.length;i++){
			var x = compareDateId[i].split("-");			
			var day1 = document.getElementById("day" + x[0]);
			var month1 = document.getElementById("month" + x[0]);			
			var year1 = document.getElementById("year" + x[0]);
			var day2 = document.getElementById("day" + x[1]);
			var month2 = document.getElementById("month" + x[1]);
			var year2 = document.getElementById("year" + x[1]);
			if(day1!=null){
				day1 = day1.options[day.selectedIndex].value;
			}
			if(day2!=null){
				day2 = day2.options[day2.selectedIndex].value;
			}
			
			month1 = month1.options[month1.selectedIndex].value;
			year1 = year1.options[year1.selectedIndex].value;
			month2 = month2.options[month2.selectedIndex].value;
			year2 = year2.options[year2.selectedIndex].value;
			if(day1==null){
				day1=2;				
			} 
			if(day2==null){
				day2=2;
			}			
			if(month2!=null && month2.length>0){
				start = makeDate(parseInt(day1),(parseInt(month1)),parseInt(year1));	
				end = makeDate(parseInt(day2),(parseInt(month2)),parseInt(year2));
				if(start.getTime()>end.getTime()){				
					errorStr+= "<li>" +  compareDateLabelArr[i];
				}
			} else {
				
				return "";
			}
			
		}
		return errorStr;
	}
	
	function testFutureDate(){
		var errorStr = "";
		var today = new Date();
			// today.setDate(today.getDay());
		var compare = new Date();
		for(i=0;i<futureDateId.length;i++){
			var day = document.getElementById("day" + futureDateId[i]);
			var month = document.getElementById("month" + futureDateId[i]);
			var year = document.getElementById("year" + futureDateId[i]);
			if(day!=null){
				day = day.options[day.selectedIndex].value;
			}
			month = month.options[month.selectedIndex].value;
			year = year.options[year.selectedIndex].value;
			if(day==null){
				today.setDate(2);
				day = 1;
			}			
			
			compare = makeDate(parseInt(day),(parseInt(month)),parseInt(year));
			if(compare.getTime()>today.getTime()){				
				errorStr+= "<li>" +  futureDateLabelArr[i] + " cannot be in the future";
			}
			
		}
		return errorStr;
	}
	
	function isFormMinLength(elem,id,minLength,name){
		if(elem==null && id!=null){
			elem = document.getElementById(id);
		}
		if(elem!=null){
			if(elem.value!=null && elem.value.length<minLength){
				if(name!=null){
					alert("The " + name + " field must be at least " + minLength + " characters long");
				} else {
					alert("The field must be at least " + minLength + " characters long");
				}
				elem.focus();
				return false;
			}
		}
		return true;		
	}
	
	function setStates(elem, elemId, option){
		var val = elem.options[elem.options.selectedIndex].value;
		var frame = document.getElementById("genericFrame");		
		frame.src="/Utility.do?stage=states&countryId="+val+"&option=" + option + "&elementName=" + elemId;		
	}
	
	function imageSwap(img){
		if(img!=null){
			var imgName = img.src;
			if(imgName.match("_off.gif")!=null){
				imgName = imgName.replace(/\_off\.gif/,"_on.gif");				
			}
			else if(imgName.match("_on.gif")!=null)
				imgName=imgName.replace(/\_on\.gif/,"_off.gif");
			if(imgName.match("-off.png")!=null){
				imgName = imgName.replace(/\-off\.png/,"-on.png");				
			}
			else if(imgName.match("-on.png")!=null)
				imgName=imgName.replace(/\-on\.png/,"-off.png");
				
			img.src=imgName;
		}
	}
	
	function openCloseDiv(elemId){
		
		var elem = document.getElementById(elemId);
		var elemFrame = document.getElementById(elemId + "_iframe");
		if(elem.style.display=="block"){
			elem.style.display="none";
			if(elemFrame!=null){
				elemFrame.style.display="none";
			}
		} else {
			
			elem.style.display="block";
			if(elemFrame!=null){
				elemFrame.style.display="block";
			}
		}
	}

	var Cookie = {
  		set: function(name, value, daysToExpire) {
    		var expire = '';
    		if (daysToExpire != undefined) {
      			var d = new Date();
      			d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      			expire = '; expires=' + d.toGMTString();
    		}
    		document.cookie = name + "=" +escape( value ) + expire;
    	},
  		get: function(name) {
    		var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    		return (cookie ? unescape(cookie[2]) : null);
  		},
  		erase: function(name) {
    		var cookie = Cookie.get(name) || true;
    		Cookie.set(name, '', -1);
    		return cookie;
  		},
  		accept: function() {
    		if (typeof navigator.cookieEnabled == 'boolean') {
      		return navigator.cookieEnabled;
    		}
    		Cookie.set('_test', '1');
    		return (Cookie.erase('_test') === '1');
  		}
  
	};
	
	function fldToLowerCase(field) {
	    if (field != null && field.value != null) {
            field.value = field.value.toLowerCase();
        }
    }

	function fillinFUsername() {
         var username = Cookie.get('idlogikrememberme');
         if (!username) {
             return;
         }
         var usernameElem = document.getElementById("j_username");
         usernameElem.value = username;
         var el = document.getElementById("inputRemember");
         if (el) {
         el.checked=true;
         }
    }
 
 
    function rememberFUsername(form) {
         var el = document.getElementById("inputRemember");
         if (el) {
              if (el.checked) {
                        var username = document.getElementById("j_username").value;
                        Cookie.set('idlogikrememberme', username, 31);
                        return;
               }
          }
                        Cookie.erase('idlogikrememberme');
    }

function printTextArea(elem){
	
	var str="#"+elem;
	
	w=window.open();
	w.document.write($(str).html());
	w.print();
	w.close();

	// window.open(print_text.jsp,"newwin2","width=720,height=600,resizable=yes,scrollbars=yes");
}
function gprintResume(){
	
	//var str="#resumeWrapperDiv";
	var iconText=$("#viewIconDiv").html();
	var html=$("#resumeWrapperDiv").html();
	html=html.replace(iconText,"");
	w=window.open();
	w.document.write(html);
	w.print();
	w.close();

	// window.open(print_text.jsp,"newwin2","width=720,height=600,resizable=yes,scrollbars=yes");
}

function printIframeTextArea(iframeName,elem){
	var elem="#"+elem;
	var iframeName="#"+iframeName;
	
	w=window.open();
	w.document.write($(iframeName).contents().find(elem).html());
	w.print();
	w.close();
	// window.open(print_text.jsp,"newwin2","width=720,height=600,resizable=yes,scrollbars=yes");
}



function gupdatePrivacy(privacyId,prId){	

	 $.post("/registered/resumeList.do", {stage:'updatePrivacy',prId:prId,privacyId:privacyId},
			 function(data){
		          var returnMap=new Array();
		          returnMap=data.split(',');
		         
		          //alert(returnMap[0]);
		          if (returnMap[1]=="true"){
		        	  alert("Your resume will be removed from any Industry, Career or Company Networks while it is set to Private.  When you change the Privacy Setting back to Networked or Broadcast, your resume will be restored to any linked networks.");
			     
		          }
		          var spanId="#privacyImg"+prId;
				  $(spanId).attr("src","/idlogik/img/icons/"+returnMap[0]);
	 });	
}

function gdeleteResume(prid,redir){
	
	if(confirm("Are you sure you want to permanently delete this resume?")){
		if (redir=="home"){
		location.href="/registered/resumeList.do?&redir=idhome&stage=deleteResume&personResumeId=" + prid;
	    }else{
		location.href="/registered/resumeList.do?stage=deleteResume&personResumeId=" + prid;
		}
	}
}


function gviewResume(prId){
	location.href="/registered/ResumeRegisteredView.do?stage=view&personResumeId="+prId+"&catId=null";
}

function gshowPopup(url,width,height) {
	$(document).ready(function(){   	
     $.fn.colorbox({scrolling:false,href:url,width:width, height:height});
	});
}	
	 
function checkBlocked2(){
	$.post("/registered/resumeList.do",{stage:'resumeSize'},
			function(data){
		if (data>=5){
			alert("The maximum number of the resumes allowed is five.");
		}else{
			location.href="/registered/createNewResume.do";	
		}	
	});
}
function checkBlocked2WithParam(param){
	$.post("/registered/resumeList.do",{stage:'resumeSize'},
			function(data){
		if (data>5){
			alert("The maximum number of the resumes allowed is five.");
		}else{
			location.href="/registered/createNewResume.do?"+param;	
		}	
	});
}

function gdeleteJobHistory(id,reDir){
	if(confirm("Are you sure you want to delete this job application histroy?")){
		if (reDir=="home"){
		location.href="/registered/ApplyJob.do?stage=deleteJobHistory&reDir=home&jobHistoryId=" + id ;
		}else {
			location.href="/registered/ApplyJob.do?stage=deleteJobHistory&jobHistoryId=" + id ;
		}
	}
}

function gshowResumeToLibrary(libCatId,libId){
	 var url="/operator/ResumeLibrary.do?stage=showSaveToLibPopup&libCatId="+libCatId+"&libIdStr="+libId+"-";
	 $.fn.colorbox({href:url,width:'300px',height:'200px'});		
 }
function gsaveResumeToLibrary(field,libCatId,libIdStr){
	var val=$(field).val();
	var text=$(field+' :selected').text();
	$.post("/operator/ResumeLibrary.do",{stage:'moveLibItems',cf:libCatId,ct:val,ci:libIdStr},
		function(data){
		alert('The resume(s) have been copied to '+text);
		$.fn.colorbox.close();
		
	 });		
}

function gshowResumeToLibraryForSearch(prId,personName){
	 var url="/operator/ResumeLibrary.do?stage=showSaveToAllLibPopup&prId="+prId;
	 if (personName!=""){
	    document.getElementById("selectedPersonName").value=personName;
	 }
	 $.fn.colorbox({href:url,width:'300px',height:'200px'});	
}



function gdownloadPDFWithPref(resId,prefId){
	
	if (resId == null) {
		alert("Resume not recognized");
		return false;
	}
	var pageType = "A4";
	var fileType = "PDF";
	document.location="/resumePopup.do?stage=makeDoc&prefId=" + prefId + "&resId=" + resId + "&fileType=" + fileType + "&pageType=" + pageType;
}

function gdownloadPDF(resId){
	var fileType = "PDF";
	var pageType = "a4";
    document.location="/resumePopup.do?stage=makeDoc&resId=" + resId + "&fileType=" + fileType + "&pageType=" + pageType;
}
function gdownloadDOC(resId){
	var fileType = "DOC";
	var pageType = "a4";
    document.location="/resumePopup.do?stage=makeDoc&resId=" + resId + "&fileType=" + fileType + "&pageType=" + pageType;
}
function gselectUnselectAll(mainElem,elem){
	var id="input#"+elem;
	var checked_status = mainElem.checked;
	$(id).each(function()
     {
		this.checked=checked_status;
	 });		  
}
function gcheckboxShowHide(checkbox, divid) {
	var div = document.getElementById(divid);
	if(checkbox.checked==true) {
		$(div).show('fast');
	} else {
		$(div).hide('fast');

	}
}

function gbuildLibrary(libraryType){
	 var url="/operator/ResumeLibrary.do?stage=showCreateNewLibraryForm&libraryType="+libraryType;
	 $.fn.colorbox({href:url,width:'400px',height:'200px'});
}
function gcreateNewCategory(){
	var catName = document.getElementById("catName").value;
	if (gcheckLibraryName(catName)==true){		   
			$.post('/operator/ResumeLibrary.do',$("#createNewLibForm").serialize(),
					function(data){
				location.href="/operator/ResumeLibrary.do?stage=libraryView&libCatId="+data+"&activeTab=1";
			});
		}else{
			alert(gcheckLibraryName(catName));
		}
	return false;
}

function gcheckLibraryName(catName){
    catName=$.trim(catName);
    if (catName==""){
		return "Please enter an library name first";
    }else if(catName=="General Candidates"){
		return "This name is not allowed. Please choose another name";
	}else{
		return true;
	}
}

function gloadFlexmenu(id){
	var $ul=$("ul[id*='"+id+"']");//important to delete existing jqflexmenu file at bottom
	$ul.each(function(){
		if ($(this).hasClass('jqflexmenu')){
			$(this).remove();
		}
	});
	var $anchors=$('*[data-flexmenu]');
	$anchors.each(function(){
		var dataflex=this.getAttribute('data-flexmenu');
		if (dataflex.indexOf(id)!=-1){
		$(this).addflexmenu(dataflex);
		}
	})
}


function gcloseColorBox(){
	$.fn.colorbox.close();
}
function gresumePrintView(resId){
	var url="/ResumeView.do?stage=printView&resId="+resId;
	window.open (url,"mywindow","resizable=1,width=800,scrollbars=1"); 
}

function gresumePreview(resId){
	var url="/ResumeView.do?stage=preview&resId="+resId;
	window.open (url,"mywindow","resizable=1,width=800,scrollbars=1"); 
}

function gresumePrintViewWithPref(resId,pref){
	var url="/ResumeView.do?stage=printView&resId="+resId+"&preferenceId="+pref;
	window.open (url,"mywindow","resizable=1,width=800,scrollbars=1"); 
}

function gcoverLetterPreview(CLId){
	var url="/registered/CoverLetter.do?stage=preview&coverLetterId="+CLId;
	window.open (url,"mywindow","resizable=1,width=800,scrollbars=1"); 
}

function gshowQuestionnaire(id){
	var url="/referenceQuestions.do?stage=refDetail&refId=" + id ;
	$.fn.colorbox({href:url,width:"500px"});
}

function gshowVerifyDetails(section,id){
	var url="/resumeVerify.do?stage=viewVerifyDetails&section="+section +"&verificationId="+ id ;
	$.fn.colorbox({href:url,width:"455px"});
}

function gshowEcertificate(smallImageId,imageId){
	var url="/resumeVerify.do?stage=viewEcertificate"+"&certSmallImageId="+ smallImageId+"&certImageId="+imageId ;
	$.fn.colorbox({href:url,width:"452px",height:"450px"});
}

function gtoggleTips(){
	if (getCookie('idlogikPageTips')=="") {
		$(".page-tips").hide('fast');
		$("#show-page-tips-button").css({'visibility':'visible'});
		setCookie('idlogikPageTips','close',365);
	} else {
		$(".page-tips").show('fast');
		$("#show-page-tips-button").css({'visibility':'hidden'});
		setCookie('idlogikPageTips','',365);
	}
}

function gcancelResumeLink(){
	 $.post("/registered/ApplyJob.do", {stage:'cancelResumeLink'},
			  function(data){
			    var pos=data.indexOf('true');
			     if (pos!=-1){
				   $('#page-alert-reminder').html("");
			    }
	 });	
}
function gshareResume(webLinkURL) {
	$(document).ready(function(){
    var url="/popups/idlogikEmail.jsp?stage=shareResume&webLinkUrl="+webLinkURL;
    $.fn.colorbox({scrolling:false,href:url,width:'592px',height:'430px'});
	});
}
function gprintDocument(){
	  var elem = document.getElementById("printarea");
    if (elem)
    {
        elem.style.display = "none";
        window.setTimeout("window.print();",1)
        window.setTimeout("document.getElementById('printarea').style.display = 'block';",1)
    }	
}

function gmodalPrompt(header,inputLabel,inputName,functionName){
	var url="/modalPopup.do?stage=prompt&header="+header+"&inputLabel="+inputLabel+"&inputName="+inputName+"&function="+functionName;
	url=url.replace(/\s+/g, "+");
	$.fn.colorbox({ href:url,width:'300px',height:'200px'
	  });
}
function gmodalConfirm(header,text,functionName){
	var url="/modalPopup.do?stage=confirm&header="+header+"&text="+text+"&function="+functionName;
	url=url.replace(/\s+/g, "+");
	$.fn.colorbox({ href:url,width:'300px',height:'200px'
	  });
}
function gmodalArticle(header,includePath){
	var url="/modalPopup.do?stage=article&header="+header+"&includePath="+includePath;
	url=url.replace(/\s+/g, "+");
	$.fn.colorbox({ href:url,width:'600px',height:'500px'
	  });
}

function ggotoPreviousPageInit(result,flexmenu,data){
		$("#rightIndicator").css({'display':'inline'});
		if (startrecords==1){
			$("#leftIndicator").css({'display':'none'});
		}
		$("#leftRecords").html(startrecords);
		$("#rightRecords").html(startrecords+9);		
		$("#"+result).html(data);
		if (flexmenu!=""){
		gloadFlexmenu(flexmenu);
		}
		return startrecords;
}
function ggotoNextPageInit(result,flexmenu,data){
		$("#leftIndicator").css({'display':'inline'});
		$("#rightRecords").html(startrecords+9);
		if (totalrecords-startrecords<10){
			$("#rightIndicator").css({'display':'none'});
			$("#rightRecords").html(totalrecords);
		}
		$("#leftRecords").html(startrecords);
		$("#"+result).html(data);
		if (flexmenu!=""){
		gloadFlexmenu(flexmenu);
		}
		return startrecords;
}

function gresetRecordsAfterDelete(deleteAmount){
	totalrecords=totalrecords-deleteAmount;
	if (totalrecords-startrecords<10){
		$("#rightRecords").html(totalrecords);
	}else{
	}
	$("#totalRecords").html(totalrecords);
}		


