//====================================================================================================
//	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 = window name for the reference of that window
//						w		= width
//						h		= height
//						menu	= if you want menubar to be enabled on the window
//						resize	= if you wanna resize the window
//						scroll	= if you need
//	Return			:	true or false
//----------------------------------------------------------------------------------------------------
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";
	
    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 Name	:	CheckUncheck_Click
//----------------------------------------------------------------------------------------------------
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 Name	:	UploadImage_Change
//----------------------------------------------------------------------------------------------------
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 Name	:	MM_preloadImages
//----------------------------------------------------------------------------------------------------
function MM_preloadImages()
{	// v3.0
	var d = document;
	
	if(d.images)
	{
		if(!d.MM_p)
			d.MM_p = new Array();
		
		var i;
		var j = d.MM_p.length;
		var 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 Name	:	MM_findObj
//----------------------------------------------------------------------------------------------------
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 Name	:	MM_swapImgRestore
//----------------------------------------------------------------------------------------------------
function MM_swapImgRestore()
{	// v3.0
	var i, x;
	var a = document.MM_sr;
	
	for(i=0; a&&i<a.length&&(x=a[i])&&x.oSrc; i++)
		x.src = x.oSrc;
}

//====================================================================================================
//	Function Name	:	MM_swapImage
//----------------------------------------------------------------------------------------------------
function MM_swapImage()
{	// v3.0
	var i, x;
	var j = 0;
	var 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 Name	:	ShowHide
//----------------------------------------------------------------------------------------------------
function showHide(div, display)
{
	document.getElementById(div).style.display = display;
}

//====================================================================================================
//	Function Name	:	GetCookie
//----------------------------------------------------------------------------------------------------
function GetCookie(name)
{
	var arg		= name + "=";
	var alen	= arg.length;
	var clen	= document.cookie.length;
	var i		= 0;
	
	while(i < clen)
	{
		var j = i + alen;
		
		if(document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		
		i = document.cookie.indexOf(" ", i) + 1;
		
		if(i == 0)
			break;
	}
	
	return null;
}

//====================================================================================================
//	Function Name	:	SetCookie
//----------------------------------------------------------------------------------------------------
function SetCookie(name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	
	var expires = (argc > 2) ? argv[2] : null;
	var path	= (argc > 3) ? argv[3] : null;
	var domain	= (argc > 4) ? argv[4] : null;
	var secure	= (argc > 5) ? argv[5] : false;
	
	document.cookie = name + "=" + escape (value) +
	((expires	== null)	? "" 			: ("; expires=" + expires.toGMTString())) +
	((path		== null)	? "" 			: ("; path=" + path)) +
	((domain	== null)	? "" 			: ("; domain=" + domain)) +
	((secure	== true)	? "; secure"	: "");
}

//====================================================================================================
//	Function Name	:	newImage
//----------------------------------------------------------------------------------------------------
function newImage(arg)
{
	if(document.images)
	{
		rslt		= new Image();
		rslt.src	= arg;
		
		return rslt;
	}
}

//====================================================================================================
//	Function Name	:	changeImages
//----------------------------------------------------------------------------------------------------
function changeImages()
{
	if(document.images && (preloadFlag == true))
	{
		for(var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//====================================================================================================
//	Function Name	:	StartMeUp
//----------------------------------------------------------------------------------------------------
function StartMeUp(urlName, path)
{
	var s1 = new SWFObject(path+"player.swf","ply","320","240","9","#FFFFFF");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("wmode","transparent");
	s1.addParam("flashvars","file="+urlName+"&autostart=true");
	s1.write("container");
}

//====================================================================================================
//	Function Name	:	attachEventListener
//----------------------------------------------------------------------------------------------------
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 Name	:	detachEventListener
//----------------------------------------------------------------------------------------------------
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;
	}
}
