
//====================================================================================================
//	File Name		:	functions.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Javascript Utility functions
//	Author			:	Dinesh Sailor
//	Creation Date	:	11-June-2004
//	Copyright		:	Copyrights © 2004 Dot Infosys
//	Email			:	dinesh@dotinfosys.com
//	History			:
//						Date						Author						Remark
//						11-June-2004				Dinesh Sailor				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
//								x and y are the co-ordinates where you wld like to show the window on the screen
//	Return			:	true or false
//	Author			:	Dinesh Sailor
//	Creation Date	:	11-June-2004
//----------------------------------------------------------------------------------------------------

function popupWindowURL(url, winname,  w, h, menu, resize, scroll, x, y) {
	
	if (winname == null) winname = "newWindow";
	if (w == null) w = 600;
	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";
	
	if (x == null || y == null) {
		cwin=window.open(url,winname,"status," + menutype + "," + scrolltype + "," + resizetype + ",width=" + w + ",height=" + h);
	}
	else {
		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 popupAdvertisement(discountcouponurl ,siteurl, banid ) {
	if(discountcouponurl != '')
		popupWindowURL(discountcouponurl, '',  '900', '600', false, true, true);
	
	if(siteurl != '')
		window.open('../advertise.php?ban_id='+banid+'&siteurl='+siteurl);

	return true;
	
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function setHomePage (url) {
  if (document.all && document.getElementById)
    oHomePage.setHomePage(url);
  else if (document.layers && navigator.javaEnabled()) {
    netscape.security.PrivilegeManager.enablePrivilege
('UniversalPreferencesWrite');
    navigator.preference('browser.startup.homepage', url);
  }
}

function Check_Click(selectall)
{
	if(document.all["recent_search_id[]"].length)
	{
		if(selectall == 'yes')
		{
			for(i=0; i < document.all["recent_search_id[]"].length; i++)
			{
				document.all["recent_search_id[]"][i].checked = true;
			}
		}
		else
		{
			for(i=0; i < document.all["recent_search_id[]"].length; i++)
			{
				document.all["recent_search_id[]"][i].checked = false;
			}
		}
	}
	else
	{
		if(document.frmMember.checkall.checked == true)
		{
			document.all["selectall[]"].checked = true;
		}
		else
		{
			document.all["selectall[]"].checked = false;
		}
	}
}


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 CheckUncheck_Click(fld, status)
{
	if(fld.length)
		for(i=0; i < fld.length; i++)
			fld[i].checked = status;
	else
		fld.checked = status;
}


function change_town_list(frm,lstcounty,townSel,town_combo_name)
{
	cat = lstcounty.options[lstcounty.selectedIndex].value;
	
	with(frm)
	{
		for(i=0; i<arrTown.length; i++)
		{
			if(arrTown[i][0] == cat)	break;
		}
	
		if(i!=arrTown.length)
		{
			
			town_combo_name.disabled=false;
			//levelid.disabled=false;
			//gender.disabled=false;
			//tournament_id.disabled=false;
			town_combo_name.length = 1;
			
			for(j=1; j<arrTown[i].length; j+=3)
			{
				town_combo_name.length++;
				town_combo_name[town_combo_name.length-1].value = arrTown[i][j];
				town_combo_name[town_combo_name.length-1].text = arrTown[i][j+1];
				
				if(townSel == arrTown[i][j])
				{
					
					town_combo_name[town_combo_name.length-1].selected = true;
				}
			}
	
		}
		else
		{
			town_combo_name.length = 1;
			town_combo_name.disabled=true;
			//levelid.disabled=true;
			//gender.disabled=true;
			//tournament_id.disabled=true;
		}
		
	}
}
function Show_Town1(county_id)
{
	
	with(document.frmCounty)
	{  
	
	    datadiv_show='datadiv'+county_id;
		/*
		if(document.all(datadiv_show).style.display == "none")
		{		
		alert("hii"+datadiv_show);
			document.all(datadiv_show).style.display = "block";
		}
		else
		alert("hello"+datadiv_show);
		  	document.all(datadiv_show).style.display = "none";
		*/	
	}
}


