var TotalNavPages;
var NavLinksToDisplay;
var CurrentPage;
var prevIndex;
var nextIndex;
var maxRowsForJScrollPane=100;
var customScrollMarginLeft=8;
var customScrollArrowSize=16;
var customScrollDragMinHeight=25;
var jScrollPaneSettings={showArrows:true,scrollbarWidth:12,arrowSize:customScrollArrowSize,scrollbarMargin:0,dragMinHeight:customScrollDragMinHeight};
var jScrollPaneSettings_h={showArrows:true,scrollbarHeight:12,arrowSize:customScrollArrowSize,scrollbarMargin:0,dragMinWidth:customScrollDragMinHeight};
var spacerForCombo=null;
var curObjCombo=null;
var isMouseDown=false;
var OdrUSWin=null;
var mouseX=0;
var mouseY=0;
var EC_TBD='TBD';

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e)
{
	if ($.browser.msie) // grab the x-y pos.s if browser is IE
	{
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	}
	else  // grab the x-y pos.s if browser is NS
	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}  
	// catch possible negative values in NS4
	if ( mouseX < 0 ) mouseX = 0;
	if ( mouseY < 0 ) mouseY = 0;
	
	return true;
}
window.onresize = winResizeFuncs;
function winResizeFuncs(e)
{
	makeMsgDivCenterAlign();
}
document.onkeyup = docOnKeyUpFuncs;
function docOnKeyUpFuncs(e)
{
	var kC = (window.event) ? event.keyCode : e.keyCode; // MSIE or Firefox?
	var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE; // MSIE : Firefox
	if (kC == Esc)
		escapeKeyFuncs();
}
function escapeKeyFuncs()
{
	hideMsg(true);
}
function isInt(value)
{
	var re = new RegExp(/^\d+$/);
	if (re.test(value))
		return true;
	else
		return false;
}
function isZero(value)
{
	var re = new RegExp(/^[0\.]+$/g);
	if (re.test(value))
		return true;
	else
		return false;
}
function isFloat(value)
{

	var re = new RegExp(/^[0-9\.]+$/);
	if (re.test(value))
		return true;
	else
		return false;
}
function isValidEmail( str )
{
	var at = '@';
	var dot = '.';
	var lat = str.indexOf( at );
	var lstr = str.length;
	var ldot = str.indexOf( dot );

	if ( str.indexOf( at ) == -1 )
		return false;
	
	if ( str.indexOf( at ) == -1 || str.indexOf( at ) == 0 || str.indexOf( at ) == lstr )
		return false;
	
	if ( str.indexOf( dot ) == -1 || str.indexOf( dot ) == 0 || str.indexOf( dot ) == lstr )
		return false;
	
	if ( str.indexOf( at , ( lat + 1 ) ) != -1 )
		return false;
	
	if ( str.substring( lat - 1 , lat ) == dot || str.substring( lat + 1 , lat + 2 ) == dot )
		return false;
	
	if ( str.indexOf( dot , ( lat + 2 ) ) == -1 )
		return false;
	
	if ( str.indexOf(" ") != -1 )
		return false;
	
	return true;
}
function lenBetween( ctrl , min , max )
{
	len = ctrl.length;
	if ( len >= min && len <= max)
		return true;
	else
		return false;
}
/*function Trim( string )
{
	string = LTrim( string );
	return RTrim( string );
}
function RTrim( string )
{
	while( string.charAt(( string.length -1 ) ) ==" ")
		string = string.substring( 0 , string.length -1 );
	return string;
}
function LTrim( string )
{
	while ( string.charAt( 0 ) == " " )
		string = string.replace( string.charAt(0) , "" );
	return string;
}*/
function strComp( string1 , string2 , caseCompare )
{
	if( IsNull( caseCompare ) )
		caseCompare = 0;

	if( !CBool( caseCompare ) )
	{
		string1 = string1.toLowerCase();
		string2 = string2.toLowerCase();
	}

	if( string1 == string2 )
		return true;
	else
		return false;
}
function toUpper( string )
{
	return string.toUpperCase();
}
function toLower( string )
{
	return string.toLowerCase();
}
function explode( string , character )
{
	return string.split( character );
}
function FormatDate( DateToFormat , FormatAs )
{
	if( DateToFormat == "" )
		return "";

	if( !FormatAs )
		FormatAs="dd/mm/yyyy";

	var strReturnDate;
	FormatAs = FormatAs.toLowerCase();
	DateToFormat = DateToFormat.toLowerCase();
	var arrDate
	var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var strMONTH;
	var Separator;

	while( DateToFormat.indexOf( "st" ) > -1 )
		DateToFormat = DateToFormat.replace("st","");

	while( DateToFormat.indexOf( "nd" ) > -1 )
		DateToFormat = DateToFormat.replace("nd","");

	while( DateToFormat.indexOf( "rd" ) > -1 )
		DateToFormat = DateToFormat.replace("rd","");

	while( DateToFormat.indexOf( "th" ) > -1)
		DateToFormat = DateToFormat.replace("th","");

	if ( DateToFormat.indexOf( "." ) > -1 )
		Separator = ".";

	if( DateToFormat.indexOf( "-" ) > -1 )
		Separator = "-";

	if( DateToFormat.indexOf( "/" ) > -1 )
		Separator = "/";

	if( DateToFormat.indexOf( " " ) > -1 )
		Separator = " ";

	arrDate = DateToFormat.split( Separator );
	DateToFormat = "";

	for( var iSD = 0; iSD < arrDate.length; iSD++ )
	{
		if( arrDate[iSD] != "" )
			DateToFormat += arrDate[iSD] + Separator;
	}

	DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
	arrDate = DateToFormat.split(Separator);

	if( arrDate.length < 3 )
		return "";

	var DAY = arrDate[0];
	var MONTH = arrDate[1];
	var YEAR = arrDate[2];

	if( parseFloat( arrDate[1] ) > 12 )
	{
		DAY = arrDate[1];
		MONTH = arrDate[0];
	}

	if( parseFloat( DAY ) && DAY.toString().length == 4 )
	{
		YEAR = arrDate[0];
		DAY = arrDate[2];
		MONTH = arrDate[1];
	}

	for( var iSD = 0; iSD < arrMonths.length; iSD++ )
	{
		var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
		var MonthPosition = DateToFormat.indexOf(ShortMonth);
		if( MonthPosition > -1 )
		{
			MONTH = iSD + 1;
			if( MonthPosition == 0 )
			{
				DAY = arrDate[1];
				YEAR = arrDate[2];
			}
			break;
		}
	}

	var strTemp = YEAR.toString();
	if ( strTemp.length==2 )
	{
		if( parseFloat( YEAR ) > 40 )
			YEAR = "19" + YEAR;
		else
			YEAR = "20" + YEAR;
	}

	if ( parseInt( MONTH ) < 10 && MONTH.toString().length < 2 )
		MONTH = "0" + MONTH;

	if ( parseInt( DAY ) < 10 && DAY.toString().length < 2 )
		DAY = "0" + DAY;

	switch (FormatAs)
	{
		case "dd/mm/yyyy":
			return DAY + "/" + MONTH + "/" + YEAR;
		case "mm/dd/yyyy":
			return MONTH + "/" + DAY + "/" + YEAR;
		case "dd/mmm/yyyy":
			return DAY + " " + arrMonths[ MONTH - 1 ].substring( 0 , 3 ) + " " + YEAR;
		case "mmm/dd/yyyy":
			return arrMonths[ MONTH - 1 ].substring( 0 , 3 ) + " " + DAY + " " + YEAR;
		case "dd/mmmm/yyyy":
			return DAY + " " + arrMonths[ MONTH - 1 ] + " " + YEAR;
		case "mmmm/dd/yyyy":
			return arrMonths[ MONTH - 1 ] + " " + DAY + " " + YEAR;
	}

	return DAY + "/" + strMONTH + "/" + YEAR;
}
function IsDate( DateToCheck )
{
	if( DateToCheck == "" )
		return false;

	var m_strDate = FormatDate(DateToCheck);

	if (m_strDate == "")
		return false;

	var m_arrDate = m_strDate.split("/");
	var m_DAY = m_arrDate[0];
	var m_MONTH = m_arrDate[1];
	var m_YEAR = m_arrDate[2];

	if( m_YEAR.length > 4 )
		return false;

	m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;

	var testDate=new Date(m_strDate);

	if( testDate.getMonth() + 1 == m_MONTH )
		return true;
	else
		return false;
}
function GetDate( format )
{
	var m_TODAY = new Date();
	var m_Day = m_TODAY.getDate();
	var m_Month = (m_TODAY.getMonth()+1)
	var MY_DATE = m_Day + "/" + m_Month + "/" + m_TODAY.getYear();

	if( !format )
	{
		format = "mm/dd/yyyy";
		MY_DATE = m_Month + "/" + m_Day + "/" + m_TODAY.getYear();
	}

	MY_DATE = FormatDate( MY_DATE , format );
	return MY_DATE;
}
function IsNull(item)
{
	if (item == null || item == undefined)
		return true;

	return false;
}
function CBool( value ) {

	value = new String(value);
	value = value.toLowerCase();

	if (value == "1" || value == "-1" || value == "true" || value == "yes")
		return true;
	else
		return false;
}
/**
 * Called to add an event to the body onload trigger.
 */
function addLoadEvent(func)
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
function formCtrlsToString( frm , replaceValuePlusSign , url_encode)
{
	var formData = "";
	for ( i = 0; i < frm.length; i++ )
	{
		if ( $.trim( frm.elements[i].name ) != "" )
		{
			if ( frm.elements[i].type == "checkbox" || frm.elements[i].type == "radio" )
			{
				if ( frm.elements[i].checked )
				{
					frmVal = $.trim( frm.elements[i].value );
					
					if (replaceValuePlusSign)
						frmVal = replacePlusSignPN( frmVal );
					
					if (url_encode)
						frmVal = urlEncode( frmVal );
					
					formData = formData + $.trim( frm.elements[i].name ) + "=" + frmVal + "&";
				}
			}
			else if ( frm.elements[i].type == 'select-multiple' )
			{
				for ( var innerCount = 0; innerCount < frm.elements[i].length; innerCount++ )
				{
					if ( frm.elements[i][innerCount].selected )
					{
						frmVal = $.trim( frm.elements[i][innerCount].value );
						
						if (replaceValuePlusSign)
							frmVal = replacePlusSignPN( frmVal );
							
						if (url_encode)
							frmVal = urlEncode( frmVal );
							
						formData = formData + $.trim( frm.elements[i].name ) + "=" + frmVal + "&";
					}
				}
			}
			else
			{
				frmVal = $.trim( frm.elements[i].value );
				
				if (replaceValuePlusSign)
					frmVal = replacePlusSignPN( frmVal );
					
				if (url_encode)
						frmVal = urlEncode( frmVal );
				formData = formData + $.trim( frm.elements[i].name ) + "=" + frmVal + "&";
			}
		}
	}

	formData = formData.substring( 0 , formData.length - 1 );
	
	if (replaceValuePlusSign)
		formData += '&plussign_encode=true';
	
	if (url_encode)
		formData += '&js_encode=true';

	return formData;
}
function GetObject(obj)
{
	return document.getElementById(obj);
}
function checkbox_select_all( form , field, value)
{
	if ( typeof(document.forms[form]) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field] ) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field].length ) == 'undefined' )
	{
		if ( value == 1 )
			document.forms[form].elements[field].checked = true;
		else
			document.forms[form].elements[field].checked = false;
		return;
	}

	len = document.forms[form].elements[field].length;

	for (var i=0; i < len; i++ )
	{
		if ( value == 1 )
			document.forms[form].elements[field][i].checked = true;
		else
			document.forms[form].elements[field][i].checked = false;
	}
}
function checkbox_check_selected( form , field , min_selected , max_selected )
{
	if ( typeof(document.forms[form]) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field] ) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field].length ) == 'undefined' )
		return document.forms[form].elements[field].checked;

	min_selected = min_selected == null ? 1 : min_selected;

	len = document.forms[form].elements[field].length;

	max_selected = max_selected == null ? len : max_selected;

	selected_count = 0;

	for (var i=0; i < len; i++ )
	{
		if ( document.forms[form].elements[field][i].checked )
			selected_count++;
	}

	if ( selected_count < min_selected || selected_count > max_selected )
		return false;

	return true;
}
function checkbox_count_selected( form , field )
{
	if ( typeof(document.forms[form]) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field] ) == "undefined" )
		return false;

	if ( typeof( document.forms[form].elements[field].length ) == 'undefined' )
		return document.forms[form].elements[field].checked;

	len = document.forms[form].elements[field].length;

	selected_count = 0;

	for (var i=0; i < len; i++ )
	{
		if ( document.forms[form].elements[field][i].checked )
			selected_count++;
	}

	return selected_count;
}
function getTargetElement( e )
{
	if (typeof(e) == 'undefined') return null;
	
	var targ;
	
	if (!e) var e = window.event;
	
	if (e.target)
		targ = e.target;
	else if (e.srcElement)
		targ = e.srcElement;
	
	if ( targ.nodeType == 3 ) // defeat Safari bug
		targ = targ.parentNode;
	
	return targ;
}
function swapCSS(theRow, cssDefault , cssClick, e)
{
	if (typeof( e ) != 'undefined')
	{
		var targ = getTargetElement( e );
		
		if (targ.nodeName.toUpperCase() != 'TD') return false;
	}
		
    var theCells = null;

    if (typeof(theRow.style) == 'undefined')
        return false;
	
    // get all Cells
	if (typeof(document.getElementsByTagName) != 'undefined')
        theCells = theRow.getElementsByTagName('td');
    else if (typeof(theRow.cells) != 'undefined')
        theCells = theRow.cells;
    else
        return false;
	
	var rowCellsCnt  = theCells.length;
	var oldCSS = theCells[0].className;
	var newCSS = '';

	if (oldCSS.toLowerCase() == cssClick.toLowerCase())
		newCSS = cssDefault;
	else
		newCSS = cssClick;

	for (c = 0; c < rowCellsCnt; c++)
		theCells[c].className = newCSS;

    return true;
}
function swapCSSOnMOverNOut(theRow, cssToImplement, cssClick, theAction)
{
    var theCells = null;

    if (typeof(theRow.style) == 'undefined') return false;

    // get all Cells
	if (typeof(document.getElementsByTagName) != 'undefined')
        theCells = theRow.getElementsByTagName('td');
    else if (typeof(theRow.cells) != 'undefined')
        theCells = theRow.cells;
    else
        return false;

	var rowCellsCnt  = theCells.length;
	var oldCSS = theCells[0].className;
	if (oldCSS == cssClick) return false;

	for (var c = 0; c < rowCellsCnt; c++)
	{
		if ( typeof( theAction ) == 'undefined' || theAction == null || theAction == '' )
			theCells[c].className = cssToImplement;
		else if ( theAction == 'over' )
			$( theCells[c] ).addClass(cssToImplement);	
		else if ( theAction == 'out' )
			$( theCells[c] ).removeClass(cssToImplement);	
	}

    return true;
}
function chgCSS(obj, theAction, e)
{
	if ( theAction == 'click' )
	{
		if ( typeof( e ) != 'undefined' )
		{
			var targ = getTargetElement( e );
			
			if (targ.nodeName.toUpperCase() != 'TD') return false;
		}

		$( obj ).removeClass( 'sample_mouseover' );
		
		if ( $( obj ).hasClass( 'sample_clicked' ) )
			$( obj ).removeClass( 'sample_clicked' );
		else
			$( obj ).addClass( 'sample_clicked' );
	}
	if ( theAction == 'over' && !( $( obj ).hasClass( 'sample_clicked' ) || $( obj ).children( 'td:eq( 0 )' ).hasClass( 'sample_clicked' ) ) )
		$( obj ).addClass( 'sample_mouseover' );
	else if ( theAction == 'out' && !$( obj ).hasClass( 'sample_clicked' ) )
		$( obj ).removeClass( 'sample_mouseover' );
}

/**
 * htmlEntities
 *
 * Convert all applicable characters to HTML entities
 *
 * object string
 * return string
 *
 * example:
 *   test = 'äöü'
 *   test.htmlEntities() //returns '&auml;&ouml;&uuml;'
 */

function htmlEntities( newString )
{
  var chars = new Array ('&','à','á','â','ã','ä','å','æ','ç','è','é',
                         'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',
                         'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',
                         'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
                         'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
                         'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','\"','ß','<',
                         '>','¢','£','¤','¥','¦','§','¨','©','ª','«',
                         '¬','­','®','¯','°','±','²','³','´','µ','¶',
                         '·','¸','¹','º','»','¼','½','¾');

  var entities = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
                            'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
                            'iacute','icirc','iuml','eth','ntilde','ograve','oacute',
                            'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',
                            'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',
                            'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',
                            'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
                            'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',
                            'Uacute','Ucirc','Uuml','Yacute','THORN','euro','quot','szlig',
                            'lt','gt','cent','pound','curren','yen','brvbar','sect','uml',
                            'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',
                            'sup2','sup3','acute','micro','para','middot','cedil','sup1',
                            'ordm','raquo','frac14','frac12','frac34');

  for (var i = 0; i < chars.length; i++)
  {
    myRegExp = new RegExp();
    myRegExp.compile(chars[i],'g')
    newString = newString.replace (myRegExp, '&' + entities[i] + ';');
  }
  return newString;
}

function winOpen_Full( url , name , channelmode , directories , fullscreen , height , left , location , menubar , resizable , scrollbars , status , titlebar , toolbar , top , width ) {

	channelmode = channelmode? channelmode : 'no';
	directories = directories? directories : 'yes';
	fullscreen = fullscreen? fullscreen : 'no';
	height = height? height : '100';
	left = left? left : '0';
	location = location? location : 'yes';
	menubar = menubar? menubar : 'yes';
	resizable = resizable? resizable : 'yes';
	scrollbars = scrollbars? scrollbars : 'yes';
	status = status? status : 'yes';
	titlebar = titlebar? titlebar : 'yes';
	toolbar = toolbar? toolbar : 'yes';
	top = top? top : '0';
	width = width? width : 100;
	
	var win = window.open( url , name , 'channelmode='+ channelmode +',directories='+ directories +' , fullscreen='+ fullscreen +' , height='+ height +' , left='+ left +' , location='+ location +' , menubar='+ menubar +' , resizable='+ resizable +' , scrollbars='+ scrollbars +' , status='+ status +' , titlebar='+ titlebar +' , toolbar='+ toolbar +' , top='+ top +' , width='+ width );

	return win;

}

function winOpen( url , name , fullscreen , height , width , left , top , resizable , scrollbars ) {

	return winOpen_Full( url , name , 'no' , 'no' , fullscreen , height , left , 'no' , 'no' , resizable , scrollbars , 'no' , 'yes' , 'no' , top , width )
}

// firefox converts HEX color to RGB string
function FF_rgbTOhex( color ) {

	if ( color.indexOf('rgb') != -1) {

		color = color.replace( 'rgb(' , '' );
		color = color.replace( ')' , '' );

		arrRGB = explode( color , ',' );

		arrRGB[0] = $.trim( arrRGB[0] );
		arrRGB[1] = $.trim( arrRGB[1] );
		arrRGB[2] = $.trim( arrRGB[2] );

		color = '#' + toHex( arrRGB[0] ) + toHex( arrRGB[1] ) + toHex( arrRGB[2] );

	}

	color = toUpper( color );

	return color;

}

function toHex(c) {

	c= parseInt(c).toString(16);
	return c.length < 2? "0" + c : c;

}

function rgbTOhex( red , green , blue ) {

	return '#' + toHex( red ) + toHex( green ) + toHex( blue );

}

function hexTOrgb( color ) {

	color = color.replace( '#' , '' );

	red		= parseInt( color.substring( 0 , 2 ) , 16 );
	green	= parseInt( color.substring( 2 , 4 ) , 16 );
	blue	= parseInt( color.substring( 4 , 6 ) , 16 );

	return red + ',' + green + ',' + blue;
}

function cutToloop( color ) {

	color = hexTOrgb( color );
	arrRGB = explode( color , ',' );

	arrRGB[0] = parseInt(arrRGB[0]);
	arrRGB[1] = parseInt(arrRGB[1]);
	arrRGB[2] = parseInt(arrRGB[2]);

	if ( arrRGB[0] >= 100 && arrRGB[1] >= 100 && arrRGB[2] >= 100 ) {

		arrRGB[0] = arrRGB[0] - ( arrRGB[0] * 0.1 );
		arrRGB[1] = arrRGB[1] - ( arrRGB[1] * 0.1 );
		arrRGB[2] = arrRGB[2] - ( arrRGB[2] * 0.1 );

	} else {

		arrRGB[0] = arrRGB[0] - ( arrRGB[0] * 0.15 );
		arrRGB[1] = arrRGB[1] - ( arrRGB[1] * 0.15 );
		arrRGB[2] = arrRGB[2] - ( arrRGB[2] * 0.15 );

	}


	arrRGB[0] = arrRGB[0] < 0? 0 : arrRGB[0];
	arrRGB[1] = arrRGB[1] < 0? 0 : arrRGB[1];
	arrRGB[2] = arrRGB[2] < 0? 0 : arrRGB[2];

	return arrRGB;

}

function loopTocut( color ) {

	color = hexTOrgb( color );
	arrRGB = explode( color , ',' );

	arrRGB[0] = parseInt(arrRGB[0]);
	arrRGB[1] = parseInt(arrRGB[1]);
	arrRGB[2] = parseInt(arrRGB[2]);

	if ( arrRGB[0] <= 100 && arrRGB[1] <= 100 && arrRGB[2] <= 100 ) {

		arrRGB[0] = arrRGB[0] + ( arrRGB[0] * 0.1 );
		arrRGB[1] = arrRGB[1] + ( arrRGB[1] * 0.1 );
		arrRGB[2] = arrRGB[2] + ( arrRGB[2] * 0.1 );

	} else {

		arrRGB[0] = arrRGB[0] + ( arrRGB[0] * 0.15 );
		arrRGB[1] = arrRGB[1] + ( arrRGB[1] * 0.15 );
		arrRGB[2] = arrRGB[2] + ( arrRGB[2] * 0.15 );

	}

	arrRGB[0] = arrRGB[0] > 255? 255 : arrRGB[0];
	arrRGB[1] = arrRGB[1] > 255? 255 : arrRGB[1];
	arrRGB[2] = arrRGB[2] > 255? 255 : arrRGB[2];

	return arrRGB;

}

function partNumberArrayPrint( partNumberArray ) {

	len = partNumberArray.length;
	var data = '';
	for (count =0; count< len;count++ )	{
		data = data + "partNumberArray["+(count)+"][partnumber]="+partNumberArray[count]['partnumber'];
		data = data + "\n";
		data = data + "partNumberArray["+(count)+"][loop]="+partNumberArray[count]['loop'];
		data = data + "\n";
		data = data + "partNumberArray["+(count)+"][cut]="+partNumberArray[count]['cut'];
		data = data + "\n";
	}

	showMsg(data);
}

function updatePageNavLinks( pageNo )
{
	var tmpPageNo = parseInt( pageNo );
	var mod = NavLinksToDisplay % 2;
	var mid = ( NavLinksToDisplay - mod )/ 2;
	var cssClass = '';
	if (arguments.length > 1) cssClass = 'class="' + arguments[1] + '"';;


	var LinksStart = tmpPageNo - mid;
	var LinksEnd = tmpPageNo + mid;

	if ( mod == 0) {

		LinksStart = LinksStart + 1;

		if ( LinksEnd - LinksStart < NavLinksToDisplay - 1 ) {
			LinksEnd = LinksEnd + ( NavLinksToDisplay - ( LinksEnd - LinksStart ) );
		}
	}

	if ( LinksStart < 1) { LinksStart = 1; LinksEnd = NavLinksToDisplay; }
	if ( LinksEnd > TotalNavPages ) { LinksEnd = TotalNavPages; LinksStart = LinksEnd - NavLinksToDisplay + 1; }

	if ( tmpPageNo == 1 ) { LinksStart = 1; LinksEnd = NavLinksToDisplay; }
	if ( tmpPageNo == TotalNavPages ) { LinksEnd = TotalNavPages; LinksStart = LinksEnd - NavLinksToDisplay + 1; }

	var strLink;

	tmpCnt = 0;

	for ( count = LinksStart; count <= LinksEnd; count++ )
	{
		if ( document.getElementById('navTD' + tmpCnt ) )
		{
			if ( count == pageNo )
				strLink = "<b>[ " + count + " ]</b>";
			else
				strLink = "<a href=\"javascript:showPage(" + count + ");\" " + cssClass + ">" + count + "<\/a>";
			document.getElementById('navTD' + tmpCnt ).innerHTML = strLink;
		}
		tmpCnt++;
	}

}

function updatePageNavLinksNew( pageNo , nomalpageimage , funcToCall, PagesToDisplay  )
{
	if ( PagesToDisplay != null && PagesToDisplay != '' )
		NavLinksToDisplay  = PagesToDisplay;
	
	var tmpPageNo = parseInt( pageNo );
	var mod = NavLinksToDisplay % 2;
	var mid = ( NavLinksToDisplay - mod )/ 2;


	var LinksStart = tmpPageNo - mid;
	var LinksEnd = tmpPageNo + mid;

	if ( mod == 0) {

		LinksStart = LinksStart + 1;

		if ( LinksEnd - LinksStart < NavLinksToDisplay - 1 ) {
			LinksEnd = LinksEnd + ( NavLinksToDisplay - ( LinksEnd - LinksStart ) );
		}
	}

	if ( LinksStart < 1) { LinksStart = 1; LinksEnd = NavLinksToDisplay; }
	if ( LinksEnd > TotalNavPages ) { LinksEnd = TotalNavPages; LinksStart = LinksEnd - NavLinksToDisplay + 1; }

	if ( tmpPageNo == 1 ) { LinksStart = 1; LinksEnd = NavLinksToDisplay; }
	if ( tmpPageNo == TotalNavPages ) { LinksEnd = TotalNavPages; LinksStart = LinksEnd - NavLinksToDisplay + 1; }

	var strLink;

	var tmpCnt = 0;
	
	var cntLinks = 0;
	
	if ( funcToCall == null || funcToCall == '' )
		funcToCall = 'showPage';



	for ( count = LinksStart; count <= LinksEnd; count++ )
	{
		if ( document.getElementById('navTD' + tmpCnt ) )
		{
			if ( cntLinks == 0 )
				$( '#navTD' + tmpCnt ).css( { 'padding-left' : 0 } );
				
			if ( count == pageNo )
			{
				//strLink = '<img src="../images/whatsinstock/selectedpage.png" border="0" alt="" />';		// Commented by Mubashir Ali
				strLink = '<img src="../images/whatsinstock/selectedpage_lir.png" border="0" alt="" />';	// Image path changed by Mubashir Ali	[11-02-2009]
			}
			else
			{
				//strLink = '<a href="javascript:;" onclick="' + funcToCall + '( ' + count + ' );"><img src="../images/whatsinstock/' + ( nomalpageimage == 'page' ? 'page.png' : 'page_lir.png' ) + '" border="0" alt="" /><\/a>';
				strLink = '<a href="#page'+count+'" onclick="' + funcToCall + '( ' + count + ' );"><img src="../images/whatsinstock/' + ( nomalpageimage == 'page' ? 'page.png' : 'page_lir.png' ) + '" border="0" alt="" /><\/a>';
			}
			
			$( '#navTD' + tmpCnt ).html( strLink );
			
			cntLinks++;
		}
		
		tmpCnt++;
	}
	
	$('#pageNumbersPagination').html('Page ' + CurrentPage + ' of ' + TotalNavPages);

}

function getPageNo()
{
	var retVal = location.href.replace(/^.*#page/, '');
	if ( !isInt( retVal ) )
		retVal = 1;
	return retVal;
}

function truncatePageNo()
{
	var retVal = location.href.replace(/#page*.*/, '');
	return retVal;
}

function getVar(name)
{
	get_string = document.location.search;
	return_value = '';

	do {
		//This loop is made to catch all instances of any get variable.
		name_index = get_string.indexOf(name + '=');

		if( name_index != -1 )
		{
			get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);

			end_of_value = get_string.indexOf('&');

			if( end_of_value != -1 )
				value = get_string.substr(0, end_of_value);
			else
				value = get_string;

			if( return_value == '' || value == '' )
				return_value += value;
			else
			return_value += ', ' + value;
		}

	} while( name_index != -1 )

	//Restores all the blank spaces.
	space = return_value.indexOf('+');

	while(space != -1) {

		return_value = return_value.substr(0, space) + ' ' +
		return_value.substr(space + 1, return_value.length);

		space = return_value.indexOf('+');
	}

	return( return_value );
}

function number_format(number, decimals, comma, formatSeparator)
{
	number = floatPrice(number);
	// number_format(number, decimals, comma, formatSeparator)
	if ( isNaN( number ) ) number = 0;

	number = Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
	e = number + '';
	f = e.split('.');
	if(!f[0]) f[0] = '0';
	if(!f[1]) f[1] = '';
	if(f[1].length < decimals)
	{
		g = f[1];
		for(i = f[1].length + 1; i <= decimals; i++)
		{
			g += '0';
		}
		f[1] = g;
	}
	if(formatSeparator != '' && f[0].length > 3)
	{
		h = f[0];
		f[0] = '';
		for(j = 3; j < h.length; j += 3)
		{
			i = h.slice(h.length - j, h.length - j + 3);
			f[0] = formatSeparator + i +  f[0] + '';
		}
		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
		f[0] = j + f[0];
	}
	comma = (decimals <= 0) ? '': comma;
	return f[0] + comma + f[1];
}

// Added by Mubashir and enhanced by Jamshed on 25-May-10.
function numberFormat(number, decimals, comma, formatSeparator)
{
	if (decimals == null)
		decimals = 0;
	
	if (comma == null)
		comma = '.';
	
	if (formatSeparator == null)
		formatSeparator = ',';
	
	number = floatPrice(number);
	
	number = Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
	
	var e = number + '';
	
	var num_part = e.split('.');
	
	if (!num_part[0]) num_part[0] = '0';
	if (!num_part[1]) num_part[1] = '';
	
	if (num_part[1].length < decimals)
	{
		var g = num_part[1];
		
		for (i = num_part[1].length + 1; i <= decimals; i++)
			g += '0';
		
		num_part[1] = g;
	}
	
	var str_len = num_part[0].length;
	
	if (formatSeparator != '' && str_len > 3)
	{
		var new_val = '';
		
		new_val = formatSeparator + num_part[0][str_len-3] + num_part[0][str_len-2] + num_part[0][str_len-1];
		
		var o_cnt = 0;
		
		for (var ctr = str_len-4; ctr >= 0; ctr--)
		{
			new_val = num_part[0][ctr] + new_val;
			
			if (o_cnt%2 == 1)
				new_val = formatSeparator + new_val;
	
			o_cnt++;
		}
		
		new_len = new_val.length;
		
		if (new_val[0] == formatSeparator)
			new_val = new_val.substring(1, new_len);
		
		num_part[0] = new_val;
	}
	
	comma = (decimals <= 0) ? '' : comma;
	
	return num_part[0] + comma + num_part[1];
}
function addCurrencySign( value )
{
	return value = "$" + value;
}
function floatPrice( value ) {

	/*value = value.replace( '$' , '' );
	value = $.trim( value.replace( ',' , '' ) );*/
	value = stripformat(value);
	value = parseFloat( value );
	if ( isNaN( value ) ) value = 0;

	return value;
}
// Made by Jamshed [09-July-10]
function calcSqFt(arrSize, roundMe)
{
	var width_feet = parseInt(arrSize[0]);
	var width_inch = parseInt(arrSize[1]);
	var length_feet = parseInt(arrSize[2]);
	var length_inch = parseInt(arrSize[3]);
	
	if (isNaN(width_feet)) width_feet = 0;
	if (isNaN(width_inch)) width_inch = 0;
	if (isNaN(length_feet)) length_feet = 0;
	if (isNaN(length_inch)) length_inch = 0;
	
	var sqFt = (width_feet + (width_inch / 12)) * (length_feet + (length_inch / 12));
	
	if (roundMe)
		sqFt = Math.round(sqFt * 100) / 100;
	
	return sqFt;
}
function calc_SqFt( width_feet , width_inch , length_feet , length_inch ) {

	sqFeet = ( parseInt( width_feet ) + ( parseInt( width_inch ) / 12 ) ) * ( parseInt( length_feet ) + ( parseInt( length_inch ) / 12 ) );
	return Math.round( sqFeet * 100 ) / 100;
}

function formatFiled( field ) {

	field.value = formatValue(field.value);
}
function formatValue(val)
{
	val = val+'';
	return number_format(val , 2 , '.' , ',' );
}
function stripformat(value)
{
	value = value+'';
	value = value.replace( /\$/g , '' );
	return $.trim(value.replace( /,/g , '' ));
}

function showResaleNumExpiryErr(type, days)
{
	var msgType;
	if (type == 'expired')
		msgType = 'has already expired';
	else if (type == 'expiring')
		msgType = 'is expiring in ' + days + ' days';
	else
		msgType = 'is expiring today';
	showMsg('Note: The resale number of this client '+msgType+'. Please edit this client\'s profile to update the resale number information.');
}

function openCombo( obj )
{
      if ( spacerForCombo ) return;
      spacerForCombo = document.createElement("span");
      spacerForCombo.style.width = obj.offsetWidth;
      spacerForCombo.style.height = obj.offsetHeight;
      spacerForCombo.style.display = "none";
      obj.parentNode.insertBefore(spacerForCombo, obj);

      obj.style.left  = getAbsPos(obj, "Left");
      obj.style.top  = getAbsPos(obj, "Top");
      obj.style.position  = "absolute";
      obj.style.width = obj.scrollWidth;
      obj.focus();
      spacerForCombo.style.display = "inline";
      curObjCombo = obj;
}

function closeCombo()
{
      if ( spacerForCombo )
      {
            spacerForCombo.parentNode.removeChild(spacerForCombo);
            spacerForCombo = null;
      }
      if ( curObjCombo )
      {
            curObjCombo.style.width = "100px";
            curObjCombo.style.position  = "static";
      }
}

function getAbsPos( o , p )
{
	var i = 0;
	while ( o != null )
	{
		i += o["offset"+p];
		o = o.offsetParent;
	}
	return i;
}

function numericFormat( fld , e , checkInch , extraStrCheck )
{
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	if ( extraStrCheck )
		strCheck += extraStrCheck;
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter
	if (whichCode == 8) return true;  // Backspace
	if (whichCode == 0) return true;  // Null
	if (whichCode == 9) return true;  // Tab

	key = String.fromCharCode(whichCode);  // Get key value from key code
	if ( strCheck.indexOf(key) == -1 ) return false;  // Not a valid key
	var x = new String(fld.value);
	if ( key == '.' )
	{
		var exp = /\./;
		var a = x.search(exp);
		if ( a != -1 ) return false;
	}
	
	if ( checkInch )
	{
		var val = parseInt( fld.value + key );
		if ( val > 11 ) return false;
	}
}

function floatFormat( fld , e )
{
	var key = '';
	var strCheck = '0123456789.';
	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter
	if (whichCode == 8) return true;  // Backspace
	if (whichCode == 0) return true;  // Null
	if (whichCode == 9) return true;  // Tab

	key = String.fromCharCode(whichCode);  // Get key value from key code
	if ( strCheck.indexOf(key) == -1 ) return false;  // Not a valid key
	var x = new String(fld.value);
	if ( key == '.' )
	{
		var exp = /\./;
		var a = x.search(exp);
		if ( a != -1 ) return false;
	}
}

//From Mubashir Ali
function curToFloat(obj)
{	
	anschk = replaceSubstring(obj.value, ",", "");
	anschk1 = replaceSubstring(anschk, "$", "");
	obj.value = anschk1;
}

//Mubashir Ali added this function here...
function replaceSubstring(inputString, fromString, toString) 
{
	// Goes through the inputString and replaces every occurrence of fromString with toString

	var temp = inputString;
	if (fromString == "") 
	{
		return inputString;
	}

	if (toString.indexOf(fromString) == -1) 
	{ 
		// If the string being replaced is not a part of the replacement string (normal situation)
		
		while (temp.indexOf(fromString) != -1) 
		{
			var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
			temp = toTheLeft + toString + toTheRight;
		}
	} 
	else 
	{ 
		// String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop

		var midStrings = new Array("~", "`", "_", "^", "#");
		var midStringLen = 1;
		var midString = "";

		// Find a string that doesn't exist in the inputString to be used
		// as an "inbetween" string

		while (midString == "") 
		{
			for (var i=0; i < midStrings.length; i++) 
			{
				var tempMidString = "";
				for (var j=0; j < midStringLen; j++) 
				{ 
					tempMidString += midStrings[i]; 
				}

				if (fromString.indexOf(tempMidString) == -1) 
				{
					midString = tempMidString;
					i = midStrings.length + 1;
				}
			}
		} // Keep on going until we build an "inbetween" string that doesn't exist

		// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
		while (temp.indexOf(fromString) != -1) 
		{
			var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
			temp = toTheLeft + midString + toTheRight;
		}

		// Next, replace the "inbetween" string with the "toString"
		while (temp.indexOf(midString) != -1) 
		{
			var toTheLeft = temp.substring(0, temp.indexOf(midString));
			var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
			temp = toTheLeft + toString + toTheRight;
		}
	} // Ends the check to see if the string being replaced is part of the replacement string or not

	return temp; // Send the updated string back to the user

} // Ends the "replaceSubstring" function

function in_array(value, array)
{
	for (var x in array)
	{
		if (array[x] == value)
			return true;
	}
	return false;
}

function minInArray( array )
{
	return Math.min.apply( Math , array );
}

function maxInArray( array )
{
	return Math.max.apply( Math , array );
}

function sortArray( array )
{
	return array.sort();
}

function isValidFloat( val )
{
	var strCheck = '0123456789.';
	
	var k = -1;
	
	var len = val.length;
	
	for ( var i = 0; i < len; i++ )
	{
		if ( strCheck.indexOf( val[i] ) == -1 )
			return false;

		if ( val[i] == '.' )
		{
			if ( ( i + 1 ) == len )
				return false;
			k++;
		}
	}
	
	if ( k > 0 )
		return false;
	
	return true;
}

function zxcPos( zxcobj )
{
	if ( !zxcobj )
		return [ 0 , 0 ];

	zxclft = zxcobj.offsetLeft;
	zxctop = zxcobj.offsetTop;
	while ( zxcobj.offsetParent != null )
	{
		zxcpar = zxcobj.offsetParent;
		zxclft += zxcpar.offsetLeft;
		zxctop += zxcpar.offsetTop;
		zxcobj = zxcpar;
	}
	return [ zxclft , zxctop ];
}

function getFileExt( fileName )
{
	var dot = fileName.lastIndexOf( '.' );
	if ( dot == -1 ) return '';
	var ext = fileName.substr( dot , fileName.length );
	ext = ext.toLowerCase();
	return ext;
}

function removeDiv( divId )
{
	var objDiv = GetObject( divId );
	
	emptyObject( objDiv );
	
	objDiv.style.display = 'none';
}

function compareDates( date1 , date2 , dateFormat )
{

	if ( dateFormat == null )
		dateFormat = 'dd/mm/yyyy';

	var day1;
		
	var mon1;
		
	var yr1;
		
	var day2;
		
	var mon2;
	
	var yr2;

	var arrDate1 = date1.split( '/' );

	var arrDate2 = date2.split( '/' );
	
	if ( dateFormat == 'dd/mm/yyyy' )
	{
		day1 = arrDate1[ 0 ];
		
		mon1 = arrDate1[ 1 ];
		
		yr1 = arrDate1[ 2 ];
		
		day2 = arrDate2[ 0 ];
		
		mon2 = arrDate2[ 1 ];
		
		yr2 = arrDate2[ 2 ];
	}
	else if ( dateFormat == 'mm/dd/yyyy' )
	{
		day1 = arrDate1[ 1 ];
		
		mon1 = arrDate1[ 0 ];
		
		yr1 = arrDate1[ 2 ];
		
		day2 = arrDate2[ 1 ];
		
		mon2 = arrDate2[ 0 ];
		
		yr2 = arrDate2[ 2 ];
	}
	else if ( dateFormat == 'mm/yyyy/dd' )
	{
		day1 = arrDate1[ 2 ];
		
		mon1 = arrDate1[ 0 ];
		
		yr1 = arrDate1[ 1 ];
		
		day2 = arrDate2[ 2 ];
		
		mon2 = arrDate2[ 0 ];
		
		yr2 = arrDate2[ 1 ];
	}
	else if ( dateFormat == 'yyyy/mm/dd' )
	{
		day1 = arrDate1[ 2 ];
		
		mon1 = arrDate1[ 1 ];
		
		yr1 = arrDate1[ 0 ];
		
		day2 = arrDate2[ 2 ];
		
		mon2 = arrDate2[ 1 ];
		
		yr2 = arrDate2[ 0 ];
	}
	
	/***********************************
	
		Condition 1 === if ( date1 is equal to date2 )
		Condition 2 === if ( date1 is greater than date2 )
		Condition 3 === if ( date1 is less than date2 )

	**********************************/
	
	// Condition 1, Check...
	if ( day1 == day2 && mon1 == mon2 && yr1 == yr2 )
		return 1;
	
	// Condition 2, Check...
	if ( yr1 > yr2 )
		return 2;
	else if ( yr1 == yr2 )
	{
		if ( mon1 > mon2 )
			return 2;
		else if ( mon1 == mon2 )
		{
			if ( day1 > day2 )
				return 2;
		}
	}

	// Condition 3, Check...
	if ( yr2 > yr1 )
		return 3;
	else if ( yr2 == yr1 )
	{
		if ( mon2 > mon1 )
			return 3;
		else if ( mon2 == mon1 )
		{
			if ( day2 > day1 )
				return 3;
		}
	}
}

function replacePlusSignPN(str)
{
	str = str.replace(/\+/gi, 'PLUSSIGN');
	
	return str;
}

function array_search( value , array )
{
	for ( var x in array )
	{
		if ( array[ x ] == value )
			return x;
	}
	return false;
}

var myTextExtraction = function(node)
{
    // extract data from markup and return it
	var objSpan = node.getElementsByTagName('span');
	if (typeof(objSpan[1]) != 'undefined')
		return objSpan[1].innerHTML;
	else
		return node.innerHTML;
}

function resetTableRowsCSS( objTbl )
{
	if ( objTbl == null )
		return false;

	var objTRs = objTbl.getElementsByTagName( 'tr' );
	
	for ( var i = 0; i < objTRs.length; i++ )
	{
		if ( typeof( objTRs[ i ].onmouseover ) == 'function' )
		{
			if ( String( $( objTRs[ i ] ).attr( 'onClick' ) ).indexOf( 'swapCSS' ) != -1 )
				swapCSS( objTRs[ i ] , 'sample' , 'sample' );
		}
	}
}

function closeMe()
{
	if ( window.opener )
	{
		window.opener.focus();
		self.close();
	}
	else
		window.location= "index.php5";
}

function getscr_w_h()
{
	 var viewportwidth;
	 var viewportheight;
	 
	 if ( typeof window.innerWidth != 'undefined' )
	 {
		  viewportwidth = window.innerWidth;
		  viewportheight = window.innerHeight;
	 }
	 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	 {
		  viewportwidth = document.documentElement.clientWidth;
		  viewportheight = document.documentElement.clientHeight;
	 }
	 
	 else
	 {
		  viewportwidth = document.getElementsByTagName( 'body' )[ 0 ].clientWidth;
  	      viewportheight = document.getElementsByTagName( 'body' )[ 0 ].clientHeight;
	 }

	return [ parseInt( viewportwidth ) , parseInt( viewportheight ) ];
}

function getNewWidth( oheight , owidth , nheight )
{
	var percentIncDec = ( ( nheight - oheight ) / oheight ) * 100;
	var nwidth = Math.ceil( ( owidth * percentIncDec / 100 ) + owidth );
	
	return nwidth;
}

function getNewHeight( oheight , owidth , nwidth )
{
	var percentIncDec = ( ( nwidth - owidth ) / owidth ) * 100;
	var nheight = Math.ceil( ( oheight * percentIncDec / 100 ) + oheight );
	
	return nheight;
}

function resizeOuterTo( w , h )
{
	if ( parseInt( navigator.appVersion ) > 3 )
	{
		if ( navigator.appName == "Netscape" )
		{
			if ( navigator.userAgent.indexOf( 'Safari' ) != -1 )
				self.resizeTo( w , h );
			else
			{
				top.outerWidth = w;
				top.outerHeight = h;
			}
		}
		else
			top.resizeTo( w , h );
	}
}

function emptyObject( obj )
{
	if ( typeof obj == 'undefined' )
		obj = document.getElementById( obj ); // If parameter is an object id.

	if ( typeof obj == 'undefined' )
		return false;

	while ( obj.firstChild )
		obj.removeChild( obj.firstChild );
}
function moveWin( x , y )
{
	window.moveTo( x , y );
}
function parseMsg(msg){
	if ( msg != '' && $('#gmsg').length > 0 )
		$('#gmsg').html(msg).show().fadeOut(4000);	
}

var msgFirstTime = true;
var animMsgSpeed = 600;
var objMsgTimeout = null;
var objToFocus = null;
var globalCallbackFunc = null;
function hideMsg(fromEscapeKey)
{
	if ( window != top )
	{
		self.parent.hideMsg(fromEscapeKey);
		return false;
	}
	
	if ( document.getElementById( 'msgThickbox' ) )
	{
		clearTimeout( objMsgTimeout );
		
		$( '#msgOuterDiv' ).hide();
			
		if ( $.browser.msie )
		{
			$( '#msgThickbox' ).fadeOut( animMsgSpeed );
		}
		else
		{
			var wThickbox = $('#msgThickbox').width();
			var hThickbox = $('#msgThickbox').height();
			var wHalf = Math.round( wThickbox / 2 );
			var hHalf = Math.round( hThickbox / 2 );
	
			$( '#msgThickbox' ).stop().animate( { 'clip':'rect('+hHalf+'px '+wHalf+'px '+hHalf+'px '+wHalf+'px)' } , animMsgSpeed );
		}
		
		if ( !fromEscapeKey && objToFocus && objToFocus != undefined )
		{
			var objFocusFuncs = 'objToFocus.focus();';
			
			var nodeName = objToFocus.nodeName.toUpperCase();
			var nodeType = objToFocus.type.toUpperCase();

			if ( nodeName == 'INPUT' && nodeType == 'TEXT' )
				objFocusFuncs += 'objToFocus.select();';
			
			setTimeout( objFocusFuncs , animMsgSpeed );
		}
		
	
		if ( globalCallbackFunc != null && globalCallbackFunc != '' && globalCallbackFunc != undefined )
			setTimeout( "eval( globalCallbackFunc );" , animMsgSpeed );
	}
}

function showMsg( msg , focusObj , callbackfunc , arrButtons , btnFocusId )
{

	if ( window != top )
	{
		if ( callbackfunc )
		{
			var frameId = self.parent.getActiveFrameId();
			if ( arrButtons == null || !arrButtons.length )
				callbackfunc = "window.frames['"+frameId+"']." + callbackfunc;
			else
				callbackfunc = "window.frames[\\\'"+frameId+"\\\']." + callbackfunc;
		}
		
		self.parent.showMsg( msg , focusObj , callbackfunc , arrButtons , btnFocusId );
		return false;
	}
	
	if ( msgFirstTime )
	{
		var includeJQCenter = true;
		var includeJQEventDrag = true;
		var includeJQClip = true;
		var includeMsgBoxCSS = true;

		for ( var i = 0; i < $( 'head' ).children().length; i++ )
		{
			var nodeName = $( 'head' ).children().get( i ).nodeName.toUpperCase();

			if ( nodeName == 'SCRIPT' )
			{
				var theSrc = $( 'head' ).children().get( i ).src;
				
				if ( theSrc.indexOf( 'javascript/jquery.center.js' ) != -1 )
					includeJQCenter = false;
				else if ( theSrc.indexOf( 'javascript/jquery.event.drag.js' ) != -1 )
					includeJQEventDrag = false;
				else if ( theSrc.indexOf( 'javascript/jquery.animate.clip.js' ) != -1 )
					includeJQClip = false;
			}
			else if ( nodeName == 'LINK' )
			{
				var theHref = $( 'head' ).children().get( i ).href;
				
				if ( theHref.indexOf( 'css/msgbox.css' ) != -1 )
					includeMsgBoxCSS = false;
			}
		}
		
		if ( includeJQCenter )
			$( 'head' ).append( '<script type="text/javascript" src="../javascript/jquery.center.js"></script>' );
		if ( includeJQEventDrag )
			$( 'head' ).append( '<script type="text/javascript" src="../javascript/jquery.event.drag.js"></script>' );
		if ( includeJQClip )
			$( 'head' ).append( '<script type="text/javascript" src="../javascript/jquery.animate.clip.js"></script>' );
		if ( includeMsgBoxCSS )
			$( 'head' ).append( '<link rel="stylesheet" type="text/css" href="../css/msgbox.css">' );
		
		$( 'body' ).append( '<div id="msgThickbox"></div>' );

		$( 'body' ).append( '<div id="msgOuterDiv" style="display:none;"><div style="float:left;"><div class="msgTopLeft bgPos msgThickboxHandle"></div><div class="msgLeftRight msgThickboxHandle"></div><div class="msgBottomLeft msgThickboxHandle"></div></div><div style="float:left;"><div class="msgTopBottom bgPos msgThickboxHandle"></div><div id="msgInnerDiv"></div><div class="msgTopBottom msgThickboxHandle" id="msgBottom"></div></div><div style="float:left;"><div class="msgTopRight bgPos msgThickboxHandle"></div><div class="msgLeftRight msgThickboxHandle"></div><div class="msgBottomRight msgThickboxHandle"></div></div><div style="clear:both;"></div></div>' );
		
		if ( $.browser.msie )
			$( '#msgBottom' ).css( { marginTop: '-4px' } );
		
		var flashMsgBox = function(){
			var i = 0;
			$('#msgOuterDiv').addClass('flashAlertBox');
			var intervalid = setInterval(function(){ 
				$('#msgOuterDiv').toggleClass('flashAlertBox');
				if(i++ > 1){
					clearInterval(intervalid);
					$('#msgOuterDiv').removeClass('flashAlertBox');
				}
			}, 100);			
		};
		
		$( '#msgThickbox' ).click( flashMsgBox );
		
		if ( $.browser.mozilla )
		{
			$( '#msgOuterDiv' ).keypress(function( event )
			{
				var code = (event.keyCode ? event.keyCode : event.which);
				
				if ( code != 13 && code != 32 && code != 37 && code != 39 )
				{
					flashMsgBox();
					return false;
				}
				
				if ( $( '#msgButtonsDiv input' ).length <= 1 && code != 13 && code != 32 )
				{
					flashMsgBox();
					return false;
				}
				
				var buttonFocusedId;
				$( '#msgButtonsDiv input' ).each( function()
				{
					if ( $( this ).hasClass( 'imfocused' ) )
						buttonFocusedId = this.id;
				});
				
				var btnIndex = buttonFocusedId.split( '_' );
				
				btnIndex = parseInt( btnIndex[ 1 ] );
					
				if ( code == 37  ) 
				{
					var newBtnIndex = btnIndex - 1;
					
					if ( newBtnIndex < 0 )
						newBtnIndex = $( '#msgButtonsDiv input' ).length - 1;
	
					$( '#msgButtonsDiv input' ).removeClass( 'imfocused' );
					$('#btnMsg_' + newBtnIndex).addClass( 'imfocused' );
					$('#btnMsg_' + newBtnIndex).focus();
				}
				else if ( code == 39  ) 
				{
					var newBtnIndex = btnIndex + 1;
					
					if ( newBtnIndex >= $( '#msgButtonsDiv input' ).length )
						newBtnIndex = 0;
					
					$( '#msgButtonsDiv input' ).removeClass( 'imfocused' );
					$('#btnMsg_' + newBtnIndex).addClass( 'imfocused' );
					$('#btnMsg_' + newBtnIndex).focus();
				}
			});
		}
		
		if ( !$.browser.msie )
		{
			var minTopPos = 3;
			var minLeftPos = 3;
			
			// Added this function by Jamshed [ 25-Mar-09 ]
			function getMaxLeftTopPos()
			{
				var totalWidth;
				
				totalWidth = $( '#msgThickbox' ).width();
					
				var totalHeight = $( document.body ).height() > $( '#msgThickbox' ).height() ? $( document.body ).height() : $( '#msgThickbox' ).height();

				var maxLeftPos = totalWidth - $( '#msgOuterDiv' ).width() - 6;
				
				var maxTopPos = totalHeight - $( '#msgOuterDiv' ).height() - 6;
				
				return [ maxLeftPos , maxTopPos ];
			}
			
			$('#msgOuterDiv').css( { cursor: 'move' } )
				.bind('dragstart',function( event )
				{
					return $( this ).css('opacity',.5)
						.clone().addClass('activeMoveMsgDiv')
						.insertAfter( this )
						//.css( { 'width' : $( '#msgOuterDiv' ).width() } ); // Added by Jamshed [ 25-Mar-09 ]
				})
				.bind('drag',function( event )
				{
					var maxLeftPos = getMaxLeftTopPos()[ 0 ];
	 
					var maxTopPos = getMaxLeftTopPos()[ 1 ];
	 
					var dragTopPos = event.offsetY < minTopPos ? minTopPos : event.offsetY;
	
					if ( dragTopPos > maxTopPos )
						dragTopPos = maxTopPos;
	
					var dragLeftPos = event.offsetX < minLeftPos ? minLeftPos : event.offsetX;
	
					if ( dragLeftPos > maxLeftPos )
						dragLeftPos = maxLeftPos;
						
					$( event.dragProxy ).css({
						top: dragTopPos,
						left: dragLeftPos
						});
				})
				.bind('dragend',function( event )
				{
					$( event.dragProxy ).remove();
					
					var maxLeftPos = getMaxLeftTopPos()[ 0 ];
	 
					var maxTopPos = getMaxLeftTopPos()[ 1 ];
	 
					var dragTopPos = event.offsetY < minTopPos ? minTopPos : event.offsetY;
	
					if ( dragTopPos > maxTopPos )
						dragTopPos = maxTopPos;
	
					var dragLeftPos = event.offsetX < minLeftPos ? minLeftPos : event.offsetX;
					
					if ( dragLeftPos > maxLeftPos )
						dragLeftPos = maxLeftPos;
						
					$( this ).animate({
							top: dragTopPos,
							left: dragLeftPos,
							opacity: 1
							})
						//	.css( { 'width' : $( '#msgOuterDiv' ).width() } ); // Added by Jamshed [ 25-Mar-09 ]
				});
		}
		
		msgFirstTime = false;
	}
	
	objToFocus = focusObj;
	
	$( '#msgInnerDiv' ).html( msg );
	$( '#msgInnerDiv' ).append( '<div id="msgButtonsDiv"></div>' );

	var buttons = '';
	
	if ( arrButtons == null || !arrButtons.length )
	{
		globalCallbackFunc = callbackfunc;
		
		var btnToFucusId = 'btnMsgOK';

		buttons += '<input type="button" value="  OK  " onclick="hideMsg();" id="btnMsgOK" />';
	}
	else
	{	
		var buttonsLen = arrButtons.length;
		
		var btnMarginLeft = 0;
		
		var myCallbackFunc = '';
		
		for ( var i = 0; i < buttonsLen; i++ )
		{
			if ( callbackfunc == null || $.trim( callbackfunc ) == '' || callbackfunc.indexOf( '(' ) != -1 )
				myCallbackFunc = '';
			else
			{
				
				var val = arrButtons[ i ][ 1 ];
				
				if ( val != null && !isInt( val ) )
					val = "\\'" + val + "\\'";
	
				myCallbackFunc = "globalCallbackFunc = '" + callbackfunc + "( " + val + " );'; ";
			}
			
			if ( i != 0 )
				btnMarginLeft = 7;
			
			buttons += '<input type="button" value="' + arrButtons[ i ][ 0 ] + '" onclick="'+myCallbackFunc+'hideMsg();" id="btnMsg_' + i + '" style="margin-left:'+btnMarginLeft+'px;" />';
		}
		
		if ( btnFocusId == null || btnFocusId > buttonsLen || btnFocusId < 1 || !isInt( btnFocusId ) )
			var focusId = i;
		else
			var focusId = btnFocusId;
		
		focusId -= 1;
		
		if ( myCallbackFunc == '' )
			globalCallbackFunc = callbackfunc;
		else
			globalCallbackFunc = null;

		var btnToFucusId = 'btnMsg_' + focusId;
	}
	
	$( '#msgButtonsDiv' ).html( buttons );
	
	$( '#msgButtonsDiv input' ).addClass( 'msgButtons' );
	
	$( '#msgButtonsDiv input' ).mouseover(function(){
		$( this ).addClass( 'btnMouseOver' )
	}).mouseout(function(){
		$( this ).removeClass( 'btnMouseOver' )
	});
	
	setMsgThickboxDiv();
	
	if ( !$.browser.msie )
		$( '#msgOuterDiv' ).hCenter().vCenter();
	
	if ( $.browser.msie )
	{
		$( '#msgThickbox' ).fadeIn(animMsgSpeed);
	}
	else
	{
		var wThickbox = $('#msgThickbox').width();
		var hThickbox = $('#msgThickbox').height();
		var wHalf = Math.round( wThickbox / 2 );
		var hHalf = Math.round( hThickbox / 2 );
	
		$( '#msgThickbox' ).css( { clip: 'rect( '+hHalf+'px '+wHalf+'px '+hHalf+'px '+wHalf+'px )' } );
		$( '#msgThickbox' ).stop().animate( { 'clip':'rect(0px '+wThickbox+'px '+hThickbox+'px 0px)' } , animMsgSpeed );
	}
	
	clearTimeout( objMsgTimeout );
	
	$( '#' + btnToFucusId ).addClass( 'imfocused' );
	
	objMsgTimeout = setTimeout( "$( '#msgOuterDiv' ).show(); GetObject( '"+btnToFucusId+"' ).focus(); setMsgDivSize(); makeMsgDivCenterAlign();" , animMsgSpeed + 10 );
	
	return false;
}
/*End Show Message Function*/

function setMsgDivSize()
{
	/*
	if ( $( '#msgContentsDiv' ).width() > $( '#msgButtonsDiv' ).width() )
		$( '#msgButtonsDiv' ).css( { width: $( '#msgContentsDiv' ).width() < msgInnerDivMinWidth ? msgInnerDivMinWidth : $( '#msgContentsDiv' ).width() } );
	else
		$( '#msgContentsDiv' ).css( { width: $( '#msgButtonsDiv' ).width() < msgInnerDivMinWidth ? msgInnerDivMinWidth : $( '#msgButtonsDiv' ).width() } );
	
	$( '#msgInnerDiv' ).css( { width: $( '#msgContentsDiv' ).width() } );
	*/
}

function setMsgThickboxDiv()
{
	if ( !$.browser.msie )
		return false;
	
	var thickboxHeight = document.body.scrollHeight > getscr_w_h()[ 1 ] ? document.body.scrollHeight : getscr_w_h()[ 1 ];
	
	//var thickboxWidth = document.body.scrollWidth > getscr_w_h()[ 0 ] ? document.body.scrollWidth : getscr_w_h()[ 0 ];
	
	thickboxWidth = '100%';
	
	$( '#msgThickbox' ).css( { 'position' : 'absolute' , height: thickboxHeight , width: thickboxWidth } );
}

function makeMsgDivCenterAlign()
{
	if ( document.getElementById( 'msgThickbox' ) == null || document.getElementById( 'msgThickbox' ).style.display == 'none' )
		return false;
	
	setMsgThickboxDiv();
	
	if ( $.browser.msie && $.browser.version <= 7 )
	{
		$( '.bgPos' ).css( { backgroundPosition: '0px 4px' } );
		
		$( '#msgInnerDiv' ).css( { position: 'absolute' } );

		$( '#msgBottom' ).css( { position: 'absolute' , top: $( '#msgInnerDiv' ).get( 0 ).offsetHeight + 14 } );
	}
	
	$( '.msgTopBottom' ).css( { width: $( '#msgInnerDiv' ).get( 0 ).offsetWidth } );
	
	$( '.msgLeftRight' ).css( { height: $( '#msgInnerDiv' ).get( 0 ).offsetHeight } );
	
	$( '#msgOuterDiv' ).hCenter().vCenter();
	
	if ( $.browser.msie && arguments.length == 0 )
		makeMsgDivCenterAlign( true );
}

function createChkboxRange( fld )
{
	$( fld ).createCheckboxRange(function( bChecked )
	{
		var tdElements = $( this ).parents( 'tr:eq(0)' ).children( 'td' );
		
		if ( bChecked )
			$( tdElements ).removeClass( 'sample' ).addClass( 'sample_clicked' );
		else
		{
			// This line added by Jamshed [ 23-Mar-09 ]
			$( this ).parents( 'tr:eq(0)' ).removeClass( 'sample_clicked' );
			
			$( tdElements ).removeClass( 'sample_clicked' ).addClass( 'sample' );
		}
	});
	
	//$.Field.setProperty('checkboxRangeKeyBinding', 'ctrlKey');
}

function checkThisBox( objBox )
{
	objBox.checked = !objBox.checked;
}


// This function is developed by JAMSHED [ 31-DEC-2008 ]
function radio_chkbox_CaptionClick( vAlign )
{
	if ( vAlign == null )
	{
		if ( $.browser.msie )
			vAlign = 'middle';
		else if ( $.browser.safari )
			vAlign = '';
		else
			vAlign = 'middle';
	}

	$('input[@type="radio"] , input[@type="checkbox"]' ).css( { verticalAlign: vAlign } );

	$( '.radio_chkbox_caption' ).click(
		function()
		{
			var inputs = $( this ).prevAll( 'input:eq(0)' );
			if ( inputs.length == 1 && typeof inputs.get( 0 ).type != 'undefined' )
			{
				if ( inputs.get( 0 ).type == 'radio' || inputs.get( 0 ).type == 'checkbox' )
					inputs.click();
			}		
		}
	);
}

function alignDivsToTable( tblId )
{
	if ( !tblId )
		return;
	
	if ( $( '#' + tblId ).length > 0 )
	{
		var leftPos = $( '#' + tblId ).offset().left;
		
		$( '.alignWithTable' ).css( { position: 'absolute' , left: leftPos } );
	}
}

function handleAjaxResponse( responseText )
{
	var jsExec = '';
	
	if ( responseText.indexOf("<jsExec>") != -1 )
	{
		var rawjsExec = responseText.substr(
									responseText.indexOf("<jsExec>") ,
									responseText.indexOf("</jsExec>") + 9
									);
		jsExec = rawjsExec.substr(
									rawjsExec.indexOf("<jsExec>") + 8 ,
									rawjsExec.indexOf("</jsExec>") - 8
									);

		responseText = responseText.replace( rawjsExec , '' );
	}

	responseText = $.trim( responseText );

	if ( responseText.indexOf("|END_AJAX_OUTPUT|") != -1 )
	{
		var rawdata = responseText.split("|END_AJAX_OUTPUT|");

		for ( var i = 0; i < rawdata.length; i++ )
		{
			if ( (rawdata[i]).indexOf("=>") != -1 )
			{
				var item = (rawdata[i]).split("=>");
				if ( item.length > 1 )
				{
					if ( $.trim( item[0] ) != "")
					{
						if (document.getElementById('tempControl'))
						{
							document.getElementById('tempControl').value = item[0];
							item[0] = document.getElementById('tempControl').value;
						}

						$( '#' + $.trim( item[ 0 ] ) ).html( $.trim( item[ 1 ] ) );
					}
				}
			}
			if ( (rawdata[i]).indexOf("~g~o~o~g~") != -1 ) // For appending purpose, Added by Jamshed [17-08-09]
			{
				var item = (rawdata[i]).split("~g~o~o~g~");
				if ( item.length > 1 )
				{
					if ( $.trim(item[0]) != "")
						$( '#' + $.trim( item[ 0 ] ) ).append( $.trim( item[ 1 ] ) );
				}
			}
		}
	}

	if ( jsExec != '' )
		eval( jsExec );
}

function callAjax(data, startFunc, endFunc , type , url , async)
{
	if (data == null)
		data = '';

	if (type == null || type == '')
		type = 'POST';
	
	if (url == null)
		url = 'ajax_index.php5';

	if (async == null)
	{
		//async = false;
		async = true;
	}
	
	if (async === false && $.browser.msie)
		async = true;
	
	$.ajax(
	{
		beforeSend: function()
		{
			if (startFunc)
				eval(startFunc);
		},
		type:type,
		url:url,
		data:data,
		async:async,
		success:function(data)
		{
			handleAjaxResponse(data);
			if (endFunc)
				eval(endFunc);
		}
	});
	
	return false;
}

function getExportContentsHeader( obj )
{
	var exportContents = '';
	if ( !$( obj ).hasClass( 'exportas_noexport' ) )
		exportContents += '<td style="font-family:verdana; font-size:12px; font-weight:bold;" class="do_export_true" nowrap>' + $( obj ).text() + '</td>';
	return exportContents;
}

function getExportContentsData( obj )
{
	var exportContents = '<tr>';
	$( obj ).children().each( function( j )
	{
		if ( !$( this ).hasClass( 'exportas_noexport' ) )
		{
			var innerText = '';
			
			if ($(this).find('.exportas_data_field:eq(0)').length > 0)
			{
				var elem = $(this).find('.exportas_data_field:eq(0)').get(0);
				
				if ((elem.type == "checkbox" || elem.type == "radio" ) && elem.checked)
					var frmVal = elem.value;
				else if (elem.type == 'select-one')
					var frmVal = elem.options[elem.selectedIndex].text;
				else
					var frmVal = elem.value;
				
				innerText = $.trim(frmVal);
			}
			else if ( $.trim( $( this ).attr( 'title' ) ) != '' )
				innerText = $( this ).attr( 'title' );
			else if ( $( this ).children( 'span' ).length > 1 )
			{
				if ( !$( this ).children( 'span:hidden' ).hasClass( 'exportas_noexport' ) )
					innerText = $( this ).children( 'span:hidden' ).text();
				else
					innerText = $( this ).children( 'span:visible' ).text();
			}
			else
				innerText = $( this ).text();
			
			exportContents += '<td style="font-family:verdana; font-size:12px; font-weight:normal;" class="do_export_true" nowrap>' + innerText + '</td>';
		}
	});
	exportContents += '</tr>';
	return exportContents;
}

function saveAsExcelFile( frameId )
{
	var exportContents = '<table cellpadding="2" cellspacing="0" border="1" style="color:#000000; width:100%;"><tr>';
	
	if ( frameId != null )
	{
		window.frames[ frameId ].$( '.exportas_header' ).children().each( function( i )
		{
			exportContents += getExportContentsHeader( this );
		});
	}
	else
	{
		$( '.exportas_header' ).children().each( function( i )
		{
			exportContents += getExportContentsHeader( this );
		});
	}
	
	exportContents += '</tr>';
	
	if ( frameId != null )
	{
		window.frames[ frameId ].$( '.exportas_data' ).each( function( i )
		{
			exportContents += getExportContentsData( this );
		});
	}
	else
	{
		$( '.exportas_data' ).each( function( i )
		{
			exportContents += getExportContentsData( this );
		});
	}
	
	exportContents += '</table>';
	
	if ( exportContents.indexOf( 'do_export_true' ) == -1 )
		doExport = false;
	else
		doExport = true;
	
	if ( doExport )
	{
		var frm = document.getElementById( 'frmSaveAsExcel' );
		frm.pagetitle.value = document.title;
		frm.contents.value = urlEncode(exportContents);
		frm.submit();
	}
	
	return false;
}
/*function tb_position2(TB_WIDTH,TB_HEIGHT) {
parent.$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		parent.$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}
function tb_remove2() {
 	parent.$("#TB_imageOff").unbind("click");
	parent.$("#TB_closeWindowButton").unbind("click");
	parent.$("#TB_window").fadeOut("fast",function(){parent.$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	parent.$("#TB_load").remove();
	parent.document.onkeydown = "";
	parent.document.onkeyup = "";
	return false;
}*/
var winOrderDoc = null;
function openWinOrderDocs(obj)
{
	if(winOrderDoc && !winOrderDoc.closed) winOrderDoc.close();var orderDocW=510;var orderDocH=400;var orderDocL=(screen.availWidth-orderDocW)/2;var orderDocT=(screen.availHeight-orderDocH)/2;winOrderDoc=window.open(obj.href,'','left='+orderDocL+',top='+orderDocT+',width='+orderDocW+',height='+orderDocH+',fullscreen=yes,scrollbars=yes');
	/*var t = obj.title || obj.name || null;
	var a = obj.href || obj.alt;
	var g = obj.rel || false;
	a += '&remitems_iframe_no_remove=yes';
	//tb_show(t,a,g);
	parent.$("body").append("<div id='TB_overlay'></div><div id='TB_window' style='display:none;'></div>");
	if(tb_detectMacXFF()){
		parent.$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		parent.$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
	}
	parent.$("body").append("<div id='TB_load'><img src='../images/loadingAnimation.gif' /></div>");//add loader to the page
	TB_WIDTH = (471*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
	TB_HEIGHT = (400*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
	ajaxContentW = TB_WIDTH - 30;
	ajaxContentH = TB_HEIGHT - 45;
	//parent.$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+a+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe();' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
	parent.$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+a+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='parent.tb_showIframe();' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
	tb_position2(TB_WIDTH,TB_HEIGHT);
	if($.browser.safari){//safari needs help because it will not fire iframe onload
		parent.$("#TB_load").remove();
		parent.$("#TB_window").css({display:"block"});
	}
	//tb_showIframe();
	//callNewWinFuncs(true);*/
}

function showUptStatusPage(orderid)
{
	if ( OdrUSWin && !OdrUSWin.closed )
		OdrUSWin.close();

	OdrUSWin = winOpen('index.php5?module=carpetorder&action=orderstatusupdate&orderid=' + orderid , 'OdrUSWin' , 'no' , screen.availHeight , screen.availWidth , '0' , '0' , 'no' , 'yes');
}

var lastIndexCrpt = null;

var globcallback_showRow=null;

function showRow(currIndex, clickEvent, objRow, callForAjax, callback, showTrackingLink, extraparams)
{
	globcallback_showRow = callback;
	//if ( clickEvent && $( clickEvent.target ).get( 0 ).nodeName.toUpperCase() == 'INPUT' )
	if ( clickEvent && ( $( clickEvent.target ).get( 0 ).nodeName.toUpperCase() == 'INPUT' || $( clickEvent.target ).get( 0 ).nodeName.toUpperCase() == 'SELECT' || $( clickEvent.target ).get( 0 ).nodeName.toUpperCase() == 'A' ) )		//Changed by Mubashir Ali	[24-08-2009]
		return false;
		
	var objDiv = GetObject( 'crpt_detail_' + currIndex );
	
	if ( objDiv == null )
	{
		if ( callForAjax )
		{
			if (!showTrackingLink)
				showTrackingLink = 0;
			if (!extraparams)
				extraparams = '';
			else
				extraparams = urlEncode(extraparams);
			$( GetObject( 'td_' + currIndex ) ).parent().after( '<tr class="tempCrptAccordionRow"><td colspan="999" style="height:66px;"><div class="dv_crpt_detail dv_crpt_detail_temp"><img src="../images/lightbox/lightbox-ico-loading-transbg.gif" alt="" border="0" /></div></td></tr>' );
			var frmData = 'module=carpetorder&action=makecrptaccordion&orderid=' + currIndex + '&showTrackingLink=' + showTrackingLink + '&extraparams=' + extraparams;
			callAjax( frmData );
		}
		
		return false;
	}
	
	var arrowImgSrc = null;
	
	var arrowImgPath = '../images/whatsinstock/';
	
	if ( objRow )
		$( '.table_row' ).removeClass( 'sample_clicked' );

	if ( lastIndexCrpt == currIndex || lastIndexCrpt == null )
	{
		if ( objDiv.style.display == '' )
		{
			hideCrptDiv( currIndex );
			
			arrowImgSrc = arrowImgPath + 'browse_right.png';
		}
		else
		{
			showCrptDiv( GetObject( 'td_' + currIndex ) , objDiv );
			
			arrowImgSrc = arrowImgPath + 'browse_down.png';
			
			if ( objRow )
				$( objRow ).addClass( 'sample_clicked' );
		}
	}
	else
	{
		hideCrptDiv( lastIndexCrpt );
		
		$( '#row_id_'  + lastIndexCrpt ).children( 'img' ).attr( 'src' , arrowImgPath + 'browse_right.png' );
		
		showCrptDiv( GetObject( 'td_' + currIndex ) , objDiv );

		arrowImgSrc = arrowImgPath + 'browse_down.png';
		
		if ( objRow )
			$( objRow ).addClass( 'sample_clicked' );
	}
	
	if ( arrowImgSrc )
		$( '#row_id_'  + currIndex ).children( 'img' ).attr( 'src' , arrowImgSrc );
	
	lastIndexCrpt = currIndex;
	
	if ( globcallback_showRow && typeof(globcallback_showRow) != 'undefined')
		eval(globcallback_showRow);
}

function showCrptDiv( objTD , objDiv )
{
	//objTD.style.display = '';
	
	$( '.tempCrptAccordionRow' ).remove();
	
	$( objTD ).parent().after( '<tr class="tempCrptAccordionRow"><td colspan="999"><div class="dv_crpt_detail dv_crpt_detail_temp">' + $( objDiv ).html() + '</div></td></tr>' );
	
	objDiv.style.top = '-5000px';
	
	/*
	var arrPos = new Array();
	
	arrPos = zxcPos( objTD );
	
	objDiv.style.left = ( arrPos[0] + 5 ) + 'px';

	if ( navigator.appName == 'Netscape' && navigator.appVersion.indexOf( 'Apple' ) == -1 ) // For firefox only
		objDiv.style.top = ( arrPos[1] + 4 ) + 'px';
	else
		objDiv.style.top = ( arrPos[1] + 5 ) + 'px';
	
	if ( document.getElementById( 'tempControl' ) )
	{
		if ( navigator.appName == 'Netscape' )
			objTD.style.height = '96px';
		else
			objTD.style.height = '100px';
	}
	else
	{
		if ( navigator.appName == 'Netscape' )
			objTD.style.height = '78px';
		else
			objTD.style.height = '82px';
	}
	*/
	
	objDiv.style.display = '';
}

function hideCrptDiv()
{
	if ( arguments.length > 0 )
	{
		currIndex = arguments[ 0 ];
		
		if ( document.getElementById( 'crpt_detail_' + currIndex ) )
		{
			GetObject( 'crpt_detail_' + currIndex ).style.display = 'none';
				
			GetObject( 'td_' + currIndex ).style.height = '';
			
			GetObject( 'td_' + currIndex ).style.display = 'none';
			
			$( '.tempCrptAccordionRow' ).remove();
			
			// Added by Jamshed [24-Feb-10]
			$('#rowClickShowRow_' + lastIndexCrpt).removeClass('sample_clicked');
		}
	}
	else
	{
		if ( lastIndexCrpt )
		{
			GetObject( 'crpt_detail_' + lastIndexCrpt ).style.display = 'none';
		
			GetObject( 'td_' + lastIndexCrpt ).style.height = '';
		
			GetObject( 'td_' + lastIndexCrpt ).style.display = 'none';
			
			$( '.table_row' ).removeClass( 'sample_clicked' );
			
			$( '#row_id_'  + lastIndexCrpt ).children( 'img' ).attr( 'src' , '../images/whatsinstock/browse_right.png' );
			
			$( '.tempCrptAccordionRow' ).remove();
			
			if ( typeof( makeScrollbarDataDiv ) == 'function' )
				makeScrollbarDataDiv();
		}
		
		resetTableRowsCSS( GetObject( 'crptsTable' ) );
	}
}

function showPrevPage( obj )
{
	if ( CurrentPage <= 1 )
	{
		$( '#prevIndex' ).css({'visibility':'hidden'});
	}
	else
	{
		if ( obj )
		{
			if ( !$( obj ).hasClass( 'linkNavigation_mainWindow' ) )
				$( obj ).attr( 'href' , '#page' + prevIndex );
			else
				window.location = truncatePageNo() + '#page' + prevIndex;
		}
		else
			$( '#prevIndexLink' ).attr( 'href' , '#page' + prevIndex );
		
		showPage(prevIndex);
		
		$( '#prevIndex' ).css({'visibility':'visible'});
	}
}

function showNextPage( obj )
{
	if(CurrentPage >= TotalNavPages)
	{
		$( '#nextIndex' ).css({'visibility':'hidden'});
	}
	else
	{
		if ( obj )
		{
			if ( !$( obj ).hasClass( 'linkNavigation_mainWindow' ) )
				$( obj ).attr( 'href' , '#page' + nextIndex );
			else
				window.location = truncatePageNo() + '#page' + nextIndex;
		}
		else
			$( '#nextIndexLink' ).attr( 'href' , '#page' + nextIndex );
		
		showPage(nextIndex);
		
		$( '#nextIndex' ).css({'visibility':'visible'});
	}
}

function LinksHideAndShow()
{
	if (CurrentPage == 1)
	{
		$( '#prevIndex' ).css({'visibility':'hidden'});
	}
	if (CurrentPage == TotalNavPages)
	{
		$( '#nextIndex' ).css({'visibility':'hidden'});
	}
}

var sorterTableId = 'crptsTable';

var sorterCloneTableId = 'cloneCrptsTable';

function checkForHeaderCSS_spec(cloneTableId, tableId)
{
	$( '#' + cloneTableId + ' th' ).removeClass( 'header headerSortDown headerSortUp' );
	
	$( '#' + tableId + ' th' ).each( function( i )
	{
		if ( $( this ).hasClass( 'header' ) )
		{
			$( '#' + cloneTableId + ' th:eq( ' + i + ' )' ).addClass( 'header' );
		}

		if ( $( this ).hasClass( 'headerSortDown' ) )
		{
			$( '#' + cloneTableId + ' th:eq( ' + i + ' )' ).addClass( 'headerSortDown' );
		}
		
		if ( $( this ).hasClass( 'headerSortUp' ) )
		{
			$( '#' + cloneTableId + ' th:eq( ' + i + ' )' ).addClass( 'headerSortUp' );
		}
	});
}

function checkForHeaderCSS()
{
	if (typeof(sorterCloneTableId) == 'object' && sorterCloneTableId.length)
	{
		for (var i = 0; i < sorterCloneTableId.length; i++)
			checkForHeaderCSS_spec(sorterCloneTableId[i], sorterTableId[i]);
	}
	else
		checkForHeaderCSS_spec(sorterCloneTableId, sorterTableId);
}

function sortByColumn(objCell, tableId)
{
	var columnId = objCell.cellIndex;
	
	if (tableId == null)
	{
		if (typeof(sorterTableId) == 'object')
			tableId = sorterTableId[0];
		else
			tableId = sorterTableId;
	}
	
	$('#' + tableId + ' th').eq(columnId).click();
}

function getRandomNum( randPrec )
{
	if ( randPrec == null || randPrec == '' )
		randPrec = 101;
	return Math.floor( Math.random() * randPrec );
}

/*
	input: 
		Date Format: dd/mm/yyyy
		Mask Format: 1: dd-mm-yyyy (default)
					 2: mmm-dd-yyyy
	output: dd-Three letters of months-yy

*/
function formatDateNew(date, dateMask)
{
	if ( date == '' )
		return '';
	else if (date == EC_TBD)
		return EC_TBD;
	
	if(dateMask);
	else
		dateMask	=	 "dd-mmm-yy";
	
	var monthNames = [
							"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
					 ];	
	
	var aryparts	=	date.split('/');
	
	var dd		=	aryparts[0];
	var mm		=	aryparts[1];

	if(mm <= 9)
		mm =  (monthNames[(mm.slice(1)) -1]);
	else
		mm = (monthNames[mm-1]);

	var yy	=	aryparts[2].slice(2);
	
	if(dateMask == "dd-mmm-yy")
		return (dd + "-" + mm + "-" + yy);
	else if(dateMask == "mmm-dd-yyyy")
		return (mm + "-" + dd + "-" + aryparts[2]);
}

function sort_list(sortBy,sortDir,pageNo,tblId,colIdx,addSortClass,headerSorterFalseArray)
{ 
	//alert(colIdx);
	if ( typeof( oldSortBy ) == 'undefined' )
		return false;	
	if ( typeof( ajaxSorting ) == 'undefined' || ajaxSorting == 0 )
		return false;

	if ( addSortClass )
	{

		$('#' + tblId + ' th').removeClass( 'header headerSortDown headerSortUp' );
		$('#' + tblId + ' th').each( function( i ){
			if ( !in_array( i , headerSorterFalseArray ) )
				$( this ).addClass('header');
		});
			
		
		if (colIdx != null)
		{

			if (typeof(colIdx) == 'object') // This condition is to manipulate array of columns to be sorted. Added by Jamshed [13-Mar-10]
			{
				for (var i = 0; i < colIdx.length; i++)
				{
					$('#' + tblId + ' th:eq('+colIdx[i]+')').addClass( oldSortDir == 'DESC' ?  'headerSortUp' : 'headerSortDown' );
				}
			}
			else
			{
				$('#' + tblId + ' th:eq('+colIdx+')').addClass( oldSortDir == 'DESC' ?  'headerSortUp' : 'headerSortDown' );
			
			}
			
		}
	}
	else
	{
		if (oldSortBy != sortBy)
		{
			oldSortBy = sortBy;
			if ( sortDir == null )
				oldSortDir = 'ASC';
			else
				oldSortDir = sortDir;
		}
		else
		{
			if ( sortDir == null )
			{
				if (oldSortDir == 'DESC')
					oldSortDir = 'ASC';
				else
					oldSortDir = 'DESC';
			}
			else
				oldSortDir = sortDir;
		}
		if ( pageNo == null )
			pageNo = getPageNo();
		showPage(pageNo);
	}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	/*
		Remove the selected value if any
		Inputs: 1: Selected Value
		Output: Nothing, It just removes the selected value from the array of values.
	*/
	function removeSelected(selectedDivl)
	{
		var arrayVal	=	$(selectedDivl).attr("id").split("_");
		
		// Remove a hidden field within the Unselected Value		
		// $("#"+ arrayVal[0] + "_sel" + arrayVal[1]).find("input[type='hidden']").remove();
		
		$(selectedDivl).removeClass("clsSelected");
		$(selectedDivl).addClass("clsUnSelected");		
		//.............................................................................	
		for(var i=0; i <	selectedValues.length;i++ )
		{ 
			if(selectedValues[i]== arrayVal[1])
				selectedValues.splice(i,1); 
		} 
		//.............................................................................	
		// Also remove from selected box
		$("#"+ arrayVal[0] + "_sel_"+ arrayVal[1]).remove();
	}// Closing of function removeSelected(...)
	//-------------------------------------------------------------------------------
	/*
		Just to display the selected values .
		Inputs: 1: selected Div Obj
				2: Array containing Id and name
				3: is2ShowValuesOnLoad	as bool added 0n 14/01/2010
		Output:  Selected values wrapped in div 
	*/	
	function displaySelected(objSelDiv, arrayVal, is2ShowValuesOnLoad)
	{
		var txtLinkName		=	$(objSelDiv).text();
		var containerName	=	"#" + arrayVal[0]+ "_sel";

		showSelectedValueBox(containerName);
		
		if(is2ShowValuesOnLoad)
		{
			$(containerName).append(
							"<div class=\"clsSelectedLink\" id=\""+ arrayVal[0] + "_sel_"+ arrayVal[1] + "\">"+ txtLinkName +"</div>"
					);
			
			$("#" + arrayVal[0] + "_sel_"+ arrayVal[1]).append("<input type=\"hidden\" value=\"" + arrayVal[1] + "\" name=\""+  arrayVal[0] +"[]\" id=\"" +  arrayVal[0] +"[]\" />");
		}
		
		// Attach Click Event with Selected Link
		$("#" + arrayVal[0] + "_sel_"+ arrayVal[1]).dblclick
					(	
						function()
						{
							removeSelected(objSelDiv);
						}
					);
		
		$("#" + arrayVal[0] + "_sel_"+ arrayVal[1]).hover(
								function()
								{
									$(this).removeClass("clsOnMouseOut");
									$(this).addClass("clsOnMouseOver");
								},
								
								function()
								{
									$(this).removeClass("clsOnMouseOver");
									$(this).addClass("clsOnMouseOut");
								}
							);	
		
	}// Closing of function displaySelected(...)

	//-------------------------------------------------------------------------------			
	/*
		This method displays or hide Selected Container
		
		Inputs: 
				1: The name of the container which will contain the selected values.
		Output: Shows selected Box.
		
		It requires Jquery in order to manipulate it. 
	
	*/
	function showSelectedValueBox(containerName)
	{
		if(containerName != "undefined" && containerName != null)
			$(containerName+":hidden").show(2000);
		else
			$(".clsPageLinksContainer:hidden").show(2000);
		
		
	}// Closing of function showSelectedValueBox()

	//-------------------------------------------------------------------------------			
	/*
		This method is to attach the click events with the divs which contain the groups name. It will attach
		events with only those which have clsUnSelected.
		Inputs: None
				
		Input:	@param (bool): isSortable	[OPTIONAL]	
		Output: none.
		
		It requires Jquery in order to manipulate it. 
	
	*/
	
	function attachEventWithDivs(isSortable)
	{
		//.............................................................................
		if(isSortable == null && typeof isSortable == "undefined")
			isSortable	=	true;
		//.............................................................................
		$("div")
		 .each
		 (
			 function( intIndex )
			 {
				 if ( $(this).hasClass("clsSelected"))
				 {
					// add the Selected Values to the Selected Box
					var arrayVal	=	$(this).attr("id").split("_");	

					displaySelected(this, arrayVal, false);
					
					//If the selected contents are sortable, apply sortable on them
						
					if(isSortable)
						$("#" + arrayVal[0]+ "_sel").sortable({ opacity: 0.6, cursor: 'move' });
					
					isAtleastOneSel	=	true;
				 }// Closing of  if ( $(this).hasClass("clsSelected"))
				 //.............................................................................	
				 $( this ).bind (
					"click",
					function(){
								if ( $(this).hasClass("clsUnSelected") && !$(this).hasClass("clsSelected") )
			  					{
									$(this).removeClass("clsUnSelected").addClass("clsSelected");
									// Split the selected Div Id into array and use that to construct a hidden array value
									var objSelDiv	=	this;
									var arrayVal	=	$(objSelDiv).attr("id").split("_");
									// Append a hidden field with the selected Value		
									//$(this).append("<input type=\"hidden\" value=\"" + arrayVal[1] + "\" name=\""+  arrayVal[0] +"[]\" id=\"" +  arrayVal[0] +"[]\" />");
									
									// Store Selected Value to an Array
									selectedValues[inc] = arrayVal[1];	
									//.............................................................................	
									displaySelected(objSelDiv, arrayVal, true);
									
									//If the selected contents are sortable, apply sortable on the newly created node.
									
									if(isSortable)
										$("#" + arrayVal[0]+ "_sel").sortable({ opacity: 0.6, cursor: 'move' });
									//.............................................................................	
									inc++;
							  }// Closing of   if ( $(this).hasClass("clsUnSelected") && !$(this).hasClass("clsSelected") )	 
							  else if ( $(this).hasClass("clsSelected") )
							  {	
								// Remove Selected Value from an Array
								removeSelected(this);
								inc--;
							  }		
			 				 //.............................................................................		
						  }// Closing of function()
						);			 
				 //.............................................................................
			 } // Closing of function( intIndex )				 	
		 );
		//.............................................................................
		// If there is nothing which has been selected, hide the selected box. Put your code here.
					
	}// Closing of function attachEventWithDivs()
function callNewWinFuncs(isWinOpener)
{
	//$('.remitems_iframe').show();
	$('.remitems_iframe').removeClass('hide');
	if (isWinOpener)
		$('#closeWinLink').show();
	//$('#pagetitle_div').text(document.title);
	$('#pagetitle_div').html( '<img src="index.php5?module=textgradient&action=show&text='+urlEncode(document.title)+'" border="0" alt="" />');
	$('.makeMeOnTop').show();
	$('#wrapper').addClass('workingAreaCSS');
	
	if ($('.pdfthispage').length > 0)
	{
		$('#lnkSaveAsPDF_cool').hide();
		$('#lnkSaveAsPDF_hot').show();
	}
	else
	{
		$('#lnkSaveAsPDF_hot').hide();
		$('#lnkSaveAsPDF_cool').show();
	}
	
	if ($('.printthispage').length == 1)
	{
		$('.printthispage').hide();
		$('#lnkPrint_cool').hide();
		$('#lnkPrint_hot').show();
	}
	else
	{
		$('#lnkPrint_hot').hide();
		$('#lnkPrint_cool').show();
	}
	
	if ($('.excelthispage').length == 1)
	{
		$('.excelthispage').hide();
		enableExcelLink(true);
	}
	else
	{
		$('#lnkSaveAsExcel_hot').hide();
		enableExcelLink(false);
	}
	
	if ( typeof( bodyOnLoadIframe ) == 'function' )
		bodyOnLoadIframe();
	if ( typeof( bodyOnLoadIframeLast ) == 'function' )
		bodyOnLoadIframeLast();
}
function enableExcelLink(enable)
{
	if (enable)
	{
		$('#lnkSaveAsExcel_cool').hide();
		$('#lnkSaveAsExcel_hot').show();
	}
	else
	{
		$('#lnkSaveAsExcel_hot').hide();
		$('#lnkSaveAsExcel_cool').show();
	}
}
function printMe()
{
	if ($('.printthispage_bypost').length > 0)
	{
		var oldAction = $('#action').val();
		var oldTarget = $('.dataform').attr('target');
		$('#action').val(printaction);
		$('.dataform').attr('target', printtarget);
		$('.dataform').submit();
		$('#action').val(oldAction);
		if (oldTarget == '')
			$('.dataform').removeAttr('target');
		else
			$('.dataform').attr('target', oldTarget);
		return false;
	}
	window.print();	
}
function cancelPDF()
{
	if (window==top)
		$('#pdfInAction').hide();
	else
		getParentObj().$('#pdfInAction').hide();
	$('#pdfInAction').hide();
	if ($('#mainframe_space').length == 0)
		$('#'+pdftarget).attr('src', '');
	else
	{
		var frameId = getActiveFrameId();
		if (frameId)
			window.frames[frameId].cancelPDF();
	}
	return false;
}
function saveAsPDF()
{
	if ($('#mainframe_space').length > 0)
	{
		var frameId = getActiveFrameId();
		if (frameId)
			window.frames[frameId].saveAsPDF();
		return false;
	}
	if ($('.pdfthispage_bypost').length > 0)
	{
		var oldAction = $('#action').val();
		var oldTarget = $('.dataform').attr('target');
		$('#action').val(pdfaction);
		if (pdftarget != '' && pdftarget != '_blank' && pdftarget != '_parent' && pdftarget != '_self' && pdftarget != '_top')
		{
			if (window==top)
				$('#pdfInAction').show();
			else
				getParentObj().$('#pdfInAction').show();
		}
		$('.dataform').attr('target', pdftarget);
		$('.dataform').submit();
		$('#action').val(oldAction);
		if (oldTarget == '')
			$('.dataform').removeAttr('target');
		else
			$('.dataform').attr('target', oldTarget);
		return false;
	}
	var pagetitle = document.title;
	$('body').append('<form id="frmSaveAsPDF" method="post" class="printfriendly" target="_blank" action="index.php5?module=pdf&action=generatehtmlpdf"><input type="hidden" name="htmltopdfcontents" id="htmltopdfcontents" /><input type="hidden" name="htmltopdfpagetitle" value="'+pagetitle+'" /></form>');
	var linkCSS = '';
	$('head').children('link').each(function()
	{
		var thisHref = $(this).attr('href');
		linkCSS += '<link rel="stylesheet" type="text/css" href="'+thisHref+'" />';
	});
	var innerCSS = '';
	$('head').children('style').each(function()
	{
		var thisHtml = $(this).html();
		innerCSS += '<style type="text/css">'+thisHtml+'</style>';
	});
	innerCSS = innerCSS.replace(/<!--@VARIABLE=CUSTOM_CSS-->/g, '');
	var htmltopdfcontents = escape('<html><head><title>'+pagetitle+'</title>'+linkCSS+innerCSS+'<style type="text/css">.printfriendly{display:none;}</style></head><body style="background-color:#ffffff;">'+$('body').html()+'</body></html>');

	$('#htmltopdfcontents').val(htmltopdfcontents);
	$('#frmSaveAsPDF').submit();
	$('#frmSaveAsPDF').remove();
}
function saveAsExcel()
{
	if ($('#mainframe_space').length > 0)
	{
		var frameId = getActiveFrameId();
		if (frameId)
			window.frames[frameId].saveAsExcel();
		return false;
	}
	
	if ($('#frmExportToExcel').length > 0)
		$('#frmExportToExcel').submit();
	else
		saveAsExcelFile();
}
// Added by Jamshed [08-Dec-09]. It can be altered again if needed. This function returns an array containing pageWidth,pageHeight,windowWidth,windowHeight...
function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) { // all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	var arrayPageSize=new Array();
	arrayPageSize['PAGE_WIDTH']=pageWidth;
	arrayPageSize['PAGE_HEIGHT']=pageHeight;
	arrayPageSize['WINDOW_WIDTH']=windowWidth;
	arrayPageSize['WINDOW_HEIGHT']=windowHeight;
	return arrayPageSize;
}
function getParentObj()
{
	return window.parent;	
}
function urlEncode(str)
{
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}




function openDropDownlinks()
{
	var pageUrl = $( '#pageUrl' ).val();
	if ( pageUrl == undefined )
		pageUrl = $( '.pageUrl:visible' ).val();
	if ( pageUrl == '' )
		return false;
	window.location = pageUrl;
}

function valToShow(str, defLen, dots)
{
	if (dots == null)
		dots = '...';
	if (str.length > defLen)
		str = str.substring(0, (defLen - dots.length)) + dots;
	
	return str;
}
// This function will check if title is applicable or not to show
function checkTitle(str, defLen, dots)
{
	if (dots == null)
		dots = '...';
	if (str.length > defLen)
		return str;
	else
		return '';
}
function redirect(url)
{
	window.location = url;
}
// These two functions added by Jamshed [12-Apr-10]
function showLoading()
{
	hideLoading();
	//$('body').append('<div class="gloading">Loading...</div>');
	$('body').append('<div class="gloading">Please wait...</div>');
	$('.gloading').show();
}
function hideLoading()
{
	$('.gloading').remove();
}

function toggleText()
{
	var totalChkBox = $('input:checkbox').length;
	if($(':checked').length < totalChkBox)
	{
		$('#btnChkAll').attr('value','Select All');
	}
	else if ($(':checked').length == totalChkBox)
	{
		$('#btnChkAll').attr('value','Unselect All');		
	}
}
function roundReportVal(num)
{
	num = Math.round(num);
	return num;
}

function changeSpecChars(str)
{
	var replaceWith='_';
	var newStr = str.replace(/\(/g, replaceWith);
	newStr = newStr.replace(/\)/g, replaceWith);
	newStr = newStr.replace(/ /g, replaceWith);
	newStr = newStr.replace(/\+/g, replaceWith);
	newStr = newStr.replace(/\//g, replaceWith); // Added by Jamshed [21-Apr-10]
	newStr = newStr.replace(/%/g, replaceWith); // Added by Jamshed [13-May-10]
	newStr = newStr.replace(/'/g, replaceWith); // Added by Jamshed [19-Jul-10]
	newStr = newStr.replace(/"/g, replaceWith); // Added by Jamshed [19-Jul-10]
	return newStr;
}
function getColorwayName(colorway, colorwayNameSep)
{
	var arrC = colorway.split(colorwayNameSep);
	
	return $.trim(arrC[0]);
}

function hideMeInFramesIf(hide)
{
	if (hide)
	{
		parent.$('.hidemeinframesif').hide();
		parent.$('#wrapper').css({'padding-top':106});
		parent.$('.central_iframe').css({height:706, marginTop:-106});
		parent.$('#iframe_space').css({'padding':0});
	}
	else
	{
		parent.$('.hidemeinframesif').show();
		parent.$('#wrapper').css({'padding-top':''});
		parent.$('.central_iframe').css({height:'', marginTop:''});
		parent.$('#iframe_space').css({'padding':''});
	}
}
function generatePassword()
{
	var alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	
	var pass = '';
	
	for (var i = 1; i <= 4; i++)
	{
		var rand = parseInt(Math.random()*51);
		
		if (rand > 51)
			rand = 51;
		
		pass += alphabets.charAt(rand);
	}
	
	var nums = parseInt(Math.random()*1000001);
	
	nums = nums + '';
	
	nums = nums.substr(0, 3);
	
	pass += nums;
	
	return pass;
}
// This function returns the new value which is nearest divisible by nearestBy for val...
function getNearestDivBy(val, nearestBy)
{
	if (nearestBy === null || nearestBy === undefined)
		nearestBy = 5;
		
	val = parseInt(val);
	
	if (isNaN(val))
		val = 0;
	
	return (Math.round(val/nearestBy) * nearestBy);
}
var ac_formatItem = function(row)
{
	if (row[0].indexOf("jsExec") != -1)
	{
		handleAjaxResponse(row[0]);

		return false;
	}
	
	return '<span title="'+row[0]+'">' + row[1] + '</span>';
};
var ac_highlight = function(value, term)
{
	return value;
};
function isChromeBrowser()
{
	if ($.browser.webkit) // Google Chrome & Safari
	{
		var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
		
		if (is_chrome) // Only Google Chrome
		{
			return true;
		}
	}
	
	return false;
}
function splitClr_n_clrName(colorway, colorwayNameSep)
{
	var ret = new Array();
	
	if (colorway.indexOf(colorwayNameSep) != -1)
	{
		var tmpArr = colorway.split(colorwayNameSep);
		
		ret['CLR_NAME'] = $.trim(tmpArr[0]);
		
		ret['CLR'] = $.trim(tmpArr[1]);
	}
	else
	{
		ret['CLR_NAME'] = '';
		
		ret['CLR'] = $.trim(colorway);
	}
	
	return ret;
}
function makeColorway_w_name(colorway, colorway_name, colorwayNameSep)
{
	var ret = colorway;
				
	if (colorway_name)
		ret = colorway_name + colorwayNameSep + ret;
	
	return ret;
}
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}