/*
 * This file illustrates one way to customize floating popup portlets.  However, it is not enabled by default.
 * To enable this javascript functionality, uncomment the call to "initPortletFloatButtons()" in skin.js.
 */

function initPortletFloatButtons()
{
    var links = document.getElementsByTagName("a");

    for (var i = 0; i < links.length; i++)
    {
        if (links[i].className && links[i].className == "bea-portal-button-float")
        {
            initPortletFloatButton(links[i]);
        }
    }
}

function initPortletFloatButton(link)
{
    link.onclick = floatPortlet;
}

function floatPortlet(event)
{
    var href = getEventAnchorHref(getEvent(event));
    var target = getEventAnchorTarget(getEvent(event));
    // This is the interesting line for customization purposes:
    window.open(href, target, "toolbar = no, width = 320, height = 240, directories = no, status = no, scrollbars = yes, resize = yes, menubar = no");
    // Returning false keeps the browser from submitting this button click to the server.
    return false;
}

function getEventAnchorHref(event)
{
    var source = getEventSource(event);
    // Correct source for IE
    source = getClickableImageEventSource(source);
    return (source && source.href ? source.href : "about:blank");
}

function getEventAnchorTarget(event)
{
    var source = getEventSource(event);
    // Correct source for IE
    source = getClickableImageEventSource(source);
    return (source && source.target ? source.target : "_blank");
}

//Portal ITG 41872 Starts

////////////////////////////////////////////////////////////////////////////////////
//
//    ATTENTION NETSCAPE NAVIGATOR 3.0 USERS!!!
//
//    If you see this text while using the site and you did NOT click on
//    View -> Source, you're using a buggy browser.
//
//    FOLLOW THESE STEPS
//
//    Read through these two steps before doing them.
//    1. Press your BACK BUTTON.
//    2. Click on REFRESH or RELOAD.
//
//    You should now be able to use the site without seeing this message.
//    This problem can however return if your browser does not cache this
//    document correctly.
//
//    UPGRADE YOUR BROWSER
//
//    Upgrade your browser to Netscape's latest and you will not have this
//    problem any more.
//
//    Netscape browsers can be found at https://home.netscape.com/
//
////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////
//  overLIB 2.22  --  Please leave this notice.
//
//  By Erik Bosrup (erik@bosrup.com)  Last modified 1999-03-31
//  Portions by Dan Steinman, Landon Bradshaw and Gnowknayme.
//
//  Get the latest version at https://www.bosrup.com/web/overlib/
//
//  This script library was created for my personal usage from the start
//  but then it became so popular I made an easy to use version. It's that
//  version you're using now. Since this is free please don't try to sell
//  this solution to a company claiming it is yours. Give me credit where
//  credit is due and I'll be happy. And I'd love to see any changes you've
//  done to the code. Free to use - don't abuse.
////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

// Main background color (the large area)
// Usually a bright color (white, yellow etc)
	if (typeof fcolor == 'undefined') { var fcolor = "#EEEEEE";}

// Border color and color of caption
// Usually a dark color (black, brown etc)
	if (typeof backcolor == 'undefined') { var backcolor = "#333399";}


// Text color
// Usually a dark color
	if (typeof textcolor == 'undefined') { var textcolor = "#000000";}

// Color of the caption text
// Usually a bright color
	if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}

// Color of "Close" when using Sticky
// Usually a semi-bright color
	if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}


// Width of the popups in pixels
// 100-300 pixels is typical
	if (typeof width == 'undefined') { var width = "200";}

// How thick the border should be in pixels
// 1-3 pixels is typical
	if (typeof border == 'undefined') { var border = "1";}


// How many pixels to the right/left of the cursor to show the popup
// Values between 3 and 12 are best
	if (typeof offsetx == 'undefined') { var offsetx = 10;}

// How many pixels to the below the cursor to show the popup
// Values between 3 and 12 are best
	if (typeof offsety == 'undefined') { var offsety = 10;}

////////////////////////////////////////////////////////////////////////////////////
// END CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
mz5 = (document.getElementById && !document.all);


// Microsoft Stupidity Check.
if (ie4) {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	} else {
		ie5 = false; }
} else {
	ie5 = false;
}

var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr = 1;
var over = 0;

if ( (ns4) || mz5 || (ie4) ) {
//	if (ns4) over = document.overDiv
//	if (ie4) over = overDiv.style
	document.onmousemove = mouseMove
	if (ns4 || mz5) document.captureEvents(Event.MOUSEMOVE)
}

//initialise function for Netscape problem
function NSInit()
{
	//alert('NSInit');
	if ( (ns4) || (mz5) || (ie4) ) {
		if (ns4) over = document.overDiv;
		if (ie4 || mz5) {
			try{
				over = overDiv.style;
			}catch(err){//alert(err);
				over = document.getElementById("overDiv").style;
				//alert("overDiv"+over);
			}
		}			
		document.onmousemove = mouseMove;
		if (ns4 || mz5) document.captureEvents(Event.MOUSEMOVE);
	}
	//alert('Getobject:'+over);
}

// Public functions to be used on pages.

// Simple popup right
function drs(text) {
	dts(1,text);
}

// Caption popup right
function drc(text, title) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}

	dtc(1,text,title);
}

// Sticky caption right
function src(text,title) {
	stc(1,text,title);
}

// Simple popup left
function dls(text) {
	dts(0,text);
}

// Caption popup left
function dlc(text, title) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}

	dtc(0,text,title);
}

// Sticky caption left
function slc(text,title) {
	stc(0,text,title);
}

// Simple popup center
function dcs(text) {
	dts(2,text);
}

// Caption popup center
function dcc(text, title) {
	dtc(2,text,title);
}


// Sticky caption center
function scc(ship,survey) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	stc(2,ship,survey);
}

/*****************************************************************************
to be used when both Survey and Recommendations are to be shown in the pop-up

// Sticky caption center
function scc(ship,text1,link1,text2,link2) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	stc(2,ship,text1,link1,text2,link2);
}
******************************************************************************/

// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) || (mz5) ) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// Non public functions. These are called by other functions etc.

// Simple popup
function dts(d,text) {
	
	// Applying CSS Styles 6/9/2008 Bijesh
	//txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT FACE=\"Verdana\" COLOR=\""+textcolor+"\" SIZE=\"-2\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	//alert(1);
	txt = "<TABLE class='tableforms popup'><TR class='fieldcontent'><TD>"+text+"</TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Caption popup
function dtc(d,text, title) {
	// Applying CSS Styles 6/9/2008 Bijesh
	//alert(2);
	txt = "<TABLE class='tableforms popup'><TR class='tableheader'><TD style='text-align:left'><SPAN ID=\"PTT\" ALT=\""+ title +"\">"+title+"</SPAN></TD></TR><TR class='fieldcontent'><TD><SPAN ID=\"PST\" ALT=\""+ text +"\">"+ text +"<SPAN></TD></TR></TABLE>";
	//txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+ text +"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Sticky
function stc(d,ship,survey) {
	var width=250
	sw = 1;
	cnt = 0;
//	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><FONT COLOR=\""+capcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"

	//alert(3);
// Applying CSS Styles 6/9/2008 Bijesh
//	txt = "<A HREF=\"\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=javascript:onClick=openFromPopup()>"+survey+ "<A>" +"</FONT></SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	txt = "<A HREF=\"\" onMouseover=\"over.visibility='visible'\" onMouseout=\"over.visibility='hidden';\"><TABLE class='tableforms popup'><TR class='tableheader'><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\" title=\""+ ship +"\">"+ ship +"</SPAN></DIV></TD></TR><TR class='fieldcontent'><TD><DIV><SPAN ID=\"PTT\"><A HREF=javascript:onClick=openFromPopup() title=\""+ survey +"\">"+survey+ "<A></SPAN></DIV></TD></TR></TABLE></A>"

	layerWrite(txt);
	dir = d;
	//alert(24);
	disp();
	snow = 0;
	//alert(29);
}

//#41881
function stc_status(ship,survey) {
	if ( (ns4) || (mz5) || (ie4) ) 
	{
		NSInit();
	}
	var width=250
	sw = 1;
	cnt = 0;
	txt = "<TABLE class='tableforms popup'><TR class='tableheader'><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\" title=\""+ ship +"\">"+ ship +"</SPAN></DIV></TD></TR><TR class='fieldcontent'><TD><DIV><SPAN ID=\"PTT\">"+survey+ "</SPAN></DIV></TD></TR></TABLE>"

	layerWrite(txt);
	//alert('layerWrite');
	dir = 2;
	//alert(24);
	disp();
	snow = 0;
}

/*****************************************************************************
to be used when both Survey and Recommendations are to be shown in the pop-up

// Sticky
function stc(d,ship,text1,link1,text2,link2) {
	var width=250
	sw = 1;
	cnt = 0;
//	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><FONT COLOR=\""+capcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+E5E9ED+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	if(text1=='#')
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PST\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	else if(text2=='#')
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	else
	{
		txt = "<A HREF=\"#\" onMouseover=\"over.visibility='visible'\" onMouseOut=\"over.visibility='hidden'\">"+"<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+fcolor+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"#003366"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><DIV ALIGN=\"CENTER\"><SPAN ID=\"PTT\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+capcolor+"\">"+ ship +"</FONT></SPAN></DIV></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PTT\"><FONT FACE=\"Arial\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+ "<A HREF=" + link1 +">"+text1+ "<A>" +"</FONT></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+"E5E9ED"+"\" style=\"border-style: solid; border-width: 1\"><TR><TD><SPAN ID=\"PST\"><FONT FACE=\"Verdana\" SIZE=\"-1\" COLOR=\""+textcolor+"\">"+"<A HREF=" + link2 +">"+text2+ "<A>"+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"+"</A>"
	}
	layerWrite(txt);
	dir = d;
	disp();
	snow = 0;
}
*****************************************************************************/

// Common calls
function disp() {
			//alert('dir:2: x:'+x+' : scrollLeft: '+document.body.scrollLeft);
			//alert('dir:2: y:'+y+' : scrollTop: '+document.body.scrollTop);
			//alert('disp');
			//alert('mz5:'+mz5);
		//alert(document.body.scrollLeft);
		if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		    //IE6 standards compliant mode
		    scrollTop = document.documentElement.scrollTop;
		    scrollLeft = document.documentElement.scrollLeft;
			//alert('IE scrollLeft1: '+scrollLeft);
			//alert('IE scrollTop1: '+scrollLeft);
		  }
		else
		{
			scrollLeft = document.body.scrollLeft;
			scrollTop = document.body.scrollTop;
		}
		
		if(mz5)
		{
			scrollLeft = 0;
			scrollTop = 0;
		}
		
	if ( (ns4) || (mz5) || (ie4) ) {
			//alert('snow='+snow+' dir='+dir);
		if (snow == 0) 	{
			if (dir == 2) { // Center
				//moveTo(over,x+offsetx-(width/2),y+offsety);
				moveTo(over,x-10+ scrollLeft,y+ scrollTop);
				//moveTo(over,x-10,y);
			}
			if (dir == 1) { // Right
				moveTo(over,x+offsetx+ scrollLeft,y+offsety+ scrollTop);
			}
			if (dir == 0) { // Left
				moveTo(over,x-offsetx-width+ scrollLeft,y+offsety+ scrollTop);
			}
			//alert('moved');
			showObject(over);
			snow = 1;
		}
		//alert('show');
	}
// Here you can make the text goto the statusbar.
}

// Moves the layer
function mouseMove(e) {

	if (ns4 || mz5) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
//	if (mz5) {x=e.screenX; y=e.screenY;}
	
/*	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (snow) {
		if (dir == 2) { // Center
			//moveTo(over,x+offsetx-(width/2),y+offsety);
			moveTo(over,x+offsetx-(width/2),y);
		}
		if (dir == 1) { // Right
			moveTo(over,x+offsetx,y+offsety);
		}
		if (dir == 0) { // Left
			moveTo(over,x-offsetx-width,y+offsety);
		}
	}*/
}

// The Close onMouseOver function for Sticky
function cClick() {
	hideObject(over);
	sw=0;
}

// Writes to a layer
function layerWrite(txt){
		//alert('writing');
		if (ns4){
				var lyr = document.overDiv.document;
                lyr.write(txt);
                lyr.close();
                //alert('write:'+txt);
        }
        else if (ie4 || mz5) 
        {
        	try{
        		document.all["overDiv"].innerHTML = txt;
        		//alert("innerHTML"+document.all["overDiv"].innerHTML);
        	}catch(err)
        	{
        		//alert("Error:"+err);
        		document.getElementById("overDiv").innerHTML = txt;
        		//alert("document.overDiv:"+document.getElementById("overDiv").innerHTML);
        	}
        }
		if (tr) { trk(); }
		//alert('wrote');
}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4 || ie5) obj.visibility = "visible"
        else if ( mz5) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4 || ie5) obj.visibility = "hidden"
        else if (mz5) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
		//alert('moveto:'+obj);
		//alert('obj:'+obj);
		//alert('frmleft:'+obj.left);
		//alert('frmtop:'+obj.top);
		//alert('toleft:'+xL);
		//alert('totop:'+yL);
        obj.left = xL+'px';
        obj.top = yL+'px';
		//alert('currleft:'+obj.left);
		//alert('currleft:'+obj.top);
}



function trk() 
{
/*
	if ( (ns4) || (ie4) ) 
	{
		nt=new Image(32,32); nt.src="https://www.nedstat.nl/cgi-bin/nedstat.gif?name=ol2t";
		bt=new Image(1,1); bt.src="https://www.bosrup.com/web/overlib/o2/tr.gif";
		refnd=new Image(1,1); refnd.src="https://www.nedstat.nl/cgi-bin/referstat.gif?name=ol2t&refer="+escape(top.document.referrer);

	}
*/	
	tr = 0;
}

//added by Suvodip
function validDate(dd,mm,yy)
{
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  if(yy < year)
  {
    vd = false;
  }
  else if(yy == year)
  {
        if(mm < month)
        {
          vd = false;
        }
        else if(mm == month)
        {
		if(dd < day)
		{
		  vd = false;
		}
		else if(dd == day)
		{
		  vd = true;
		}
        }
  }
  return vd;
}

//This function checks if Start Date Year yy is less than or equal to current Year
function validIACSStartDate(dd,mm,yy)
{
  ////alert("Res-image-soverlib.js : validIACSStartDate");
  
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  
  if(yy > year)
  {
    vd = false;
  }
  
  return vd;

}

//This function checks if (Start Date)dd1,mm1,yy1 is less than (End Date)dd2,mm2,yy2
function compareDate(dd1,mm1,yy1,dd2,mm2,yy2)
{
  ////alert("Res-images-overlib.js : compareDate");

   var yearFlag = true;
   
   if(yy1 <= yy2)
   {
   	if(mm1 <= mm2)
   	{
   	      if(dd1 >= dd2)
   	      {
   	      	yearFlag = false;
   	      }
   	}
   	else
   	{
   	   yearFlag = false;
   	}
   }
   else
   {
   	yearFlag = false;
   }
   
   return yearFlag;
}

/*Date is less than equal to current date*/
function validDateBefore(dd,mm,yy)
{
  var Today = new Date();

  var year = Today.getYear();	    // Returns year
  var month = Today.getMonth();    // Returns month (0-11)
  month = month + 1;
  var day = Today.getDate();    // Returns day (1-31)

  var vd = true;
  if(yy > year)
  {
    vd = false;
  }
  else if(yy == year)
      {
        if(mm > month)
        {
          vd = false;
        }
        else if(mm == month)
              {
                if(dd > day)
                {
                  vd = false;
                }
                else if(dd == day)
                      {
                        vd = true;
                      }
                }
    }
    return vd;
}

/*Date is greater than current date*/
function validDateAfter(dd,mm,yy,sdd,smm,syy)
{
  var Today = new Date();

  var year = syy;	    // Returns year
  var month = smm;    // Returns month (0-11)
  //month = month + 1;
  var day = sdd;    // Returns day (1-31)

  var vd = true;
  if(yy < year)
  {
    vd = false;
  }
  else if(yy == year)
      {
        if(mm < month)
        {
          vd = false;
        }
        else if(mm == month)
              {
                if(dd < day)
                {
                  vd = false;
                }
                else if(dd == day)
                      {
                        vd = false;
                      }
                }
    }
    return vd;
}

/*Sorting code has been merged since the use of two SRC in Javascript
tag is creating problems in IE5.5*/

/*************Swapping starts***************/

Imagepath = "/common";
flag = new Array;
for(var i=0;i<12;i++)
{
  flag[i]=0;
}

imagename = new Array;
imagename[0]='randimg1';
imagename[1]='randimg2';
imagename[2]='randimg3';
imagename[3]='randimg4';
imagename[4]='randimg5';
imagename[5]='randimg6';
imagename[6]='randimg7';
imagename[7]='randimg8';
imagename[8]='randimg9';
imagename[9]='randimg10';
imagename[10]='randimg11';
imagename[11]='randimg12';

images = new Array;
images[0] = new Image();
images[0].src = Imagepath+"/images/down.gif";
images[1] = new Image();
images[1].src = Imagepath+"/images/up.gif";

calledFlag=0;

function changeFlag(index)
{
  if(calledFlag==0)
  {
    calledFlag=1;
    flag[index]=1;
  } 
 
}

function swapPic(picname)
{
  var loc;
  for(var i=0;i<12;i++)
  {
    if(picname.name==imagename[i])
    {
      if(flag[i]==0)
      {
        flag[i]=1;
        loc = flag[i];
        break;
      }
      else
      {
        flag[i]=0;
        loc = flag[i];
        break;
      }
    }
  }
  
  picname.src=images[loc].src;
}

/*************Swapping ends***************/

/*************Sorting starts***************/

function createRowsArray (table) {
  var rows = new Array();
  var r = 0;
  if (table.tHead == null)
    for (var r1 = 0; r1 < table.rows.length; r1++, r++)
      rows[r] = table.rows[r1];
  else
    for (var t = 0; t < table.tBodies.length; t++)
      for (var r1 = 0; r1 < table.tBodies[t].rows.length; r1++, r++)
        rows[r] = table.tBodies[t].rows[r1];


  return rows;
}

function insertSortedRows(table, rows) {
var rowcolorflag=0;
  if (document.all) var rowsCopy = new Array(rows.length)
  for (var r = 0; r < rows.length; r++) {
    if (document.all) rowsCopy[r] = rows[r].cloneNode(true);
    table.deleteRow(rows[r].rowIndex);
  }
  
  var tableSection = table.tBodies[table.tBodies.length - 1];
  for (var r = 0; r < rows.length; r++) {
    var row = document.all ? rowsCopy[r] : rows[r];
    if(rowcolorflag==0){  
          row.bgColor="e5e9ed";
          rowcolorflag=1;
        }else{
          row.bgColor="e5e9ed";
          rowcolorflag=0;
    }
    tableSection.appendChild(row);
    
}
      
}

function sortTable (table, sortFun) {


  var rows = createRowsArray(table);

  if (rows.length > 0) {
    rows.sort(sortFun);
    insertSortedRows(table, rows);
  }
}

function sortRowsAlphaDesc (row1 , row2) {
  var column = sortRowsAlphaDesc.col;
  var cell1 = row1.cells[column].firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.nodeValue;
  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}
function sortRowsAlphaAsc (row1 , row2) {
  var column = sortRowsAlphaAsc.col;
  var cell1 = row1.cells[column].firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.nodeValue;
  return cell1 < cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsNumber (row1 , row2) {
  var column = sortRowsNumber.col;
  var cell1 = parseFloat(row1.cells[column].firstChild.nodeValue);
  var cell2 = parseFloat(row2.cells[column].firstChild.nodeValue);
  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsLinkDesc (row1 , row2) {
  var column = sortRowsLinkDesc.col;
//var cell1 = findFirstLinkChild(row1.cells[column]).href;
//var cell2 = findFirstLinkChild(row2.cells[column]).href;
  var cell1 = row1.cells[column].firstChild.firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.firstChild.nodeValue;

  return cell1 > cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}

function sortRowsLinkAsc (row1 , row2) {
  var column = sortRowsLinkAsc.col;
//var cell1 = findFirstLinkChild(row1.cells[column]).href;
//var cell2 = findFirstLinkChild(row2.cells[column]).href;
  var cell1 = row1.cells[column].firstChild.firstChild.nodeValue;
  var cell2 = row2.cells[column].firstChild.firstChild.nodeValue;

  return cell1 < cell2 ? - 1 : (cell1 == cell2 ? 0 : 1);
}
function findFirstLinkChild (el) {
  var child = el.firstChild;
  while (child.tagName != 'A')
    child = child.nextSibling;
  return child;
}

function testSortTable(table, col) {
//    sortRowsAlphaDesc.col = col;
//    sortTable(table, sortRowsAlphaDesc);
    
if(flag[col]==0)
  {
    sortRowsAlphaDesc.col = col;
    sortTable(table, sortRowsAlphaDesc);
  }
  else
  {
    sortRowsAlphaAsc.col = col;
    sortTable(table, sortRowsAlphaAsc);
  }
}


function testSortTableNumerical (table, col) {
  sortRowsNumber.col = col;
  sortTable(table, sortRowsNumber);
}

function testSortTableLinks (table, col) {
//  sortRowsLinkDesc.col = col;
//  sortTable(table, sortRowsLinkDesc);

if(flag[col]==0)
{
  sortRowsLinkDesc.col = col;
  sortTable(table,sortRowsLinkDesc);
}
else
{
  sortRowsLinkAsc.col = col;
  sortTable(table,sortRowsLinkAsc);
 }
} 
 function findTableParent (node) {
  while (node.tagName.toUpperCase() != 'TABLE')
    node = node.parentNode;
  return node;
}

function openSurveyPopUp(hyperlink){
	var url = hyperlink.href;
	//hyperlink.href = "#";
	//alert(url);
	
}
//Portal ITG 41872 Ends

