FocusButtonID = null;
EventKeyHandler = function(evt)
{
	evt = (evt) ? evt : window.event;
	if ((evt.which && evt.which == 13) || (evt.keyCode && evt.keyCode == 13))
	{
		if( FocusButtonID != null && FocusButtonID.length > 0 )
		{	
			if( client.isIE ) document.getElementById( FocusButtonID ).focus();
			else document.getElementById( FocusButtonID ).click();
		}
	}
}
SetFocusButton = function( id )
{
	if( id == "" ) id = null;
	FocusButtonID = id;
}

getRandomNumber = function( n ){return Math.floor(Math.random() * (n ? n : 32768) );}

// button controllers
var oversuffix 	= "_on";
var persist		= null;

rollover = function( img ){
	if( !img || !img.src ) return false;
	var src = img.src;
	if( src.indexOf( oversuffix ) > 0 ) return;
	img.src = src.substring(0,src.length-4) + oversuffix +  src.substring(src.length-4, src.length) 
}
rollout = function( img ){
	if( !img || !img.src ) return false;
	if( persist == img ) return;
	var src = img.src;
	if( src.indexOf( oversuffix ) < 0 ) return;
	img.src = src.substring(0,src.indexOf( oversuffix )) + src.substring(src.length-4, src.length);
}
preload = function(){
	for( var i=0; i<arguments.length; i++){
		img = new Image();
		img.src = arguments[i];
	}
}

/* Client Class */
Client = function(){
	this.isWin = (navigator.appVersion.indexOf("Win") > -1)
	this.isMac = (navigator.appVersion.indexOf("Mac") > -1)
	this.isIE = (navigator.userAgent.indexOf("MSIE") > 0 );
	this.isFirefox = (navigator.userAgent.indexOf("Firefox") > 0 );
	
	if (document.images){
		this.isDOM1 = (document.getElementById && !(this.isMac && document.all)) ? true : false;
		this.isDOM0 = (document.all) ? true : false;
		this.isBaseline = (this.isDOM1 || this.isDOM0) ? true : false;
	}
	this.request = [];
	qs = location.search;
	if( qs )
	{
		if( qs.indexOf("?") == 0 ) qs = qs.substr( 1, qs.length )
		qs = qs.split("&")
		for( var i=0; i<qs.length; i++ ){ temp = qs[i].split("="); this.request[temp[0]] = temp[1]; }
	}
}
Client.prototype.getObject = function(o)
{
	if (typeof o == "object") return o;
	if (this.isDOM1) return document.getElementById(o);
	if (this.isDOM0) return document.all[o];
	return false;
}
Client.prototype.getStyle = function(o)
{
	o = this.getObject(o).style;
}

client = new Client();

/* Date class additions */
Date.prototype.format = function( type )
{
	switch ( type )
	{
		default:
			dy = this.getDate().toString();
			if( dy.length == 1 ) dy = "0" + dy;
			mo = (this.getMonth() + 1).toString();
			if( mo.length == 1 ) mo = "0" + mo;
			yr = this.getFullYear ().toString();
			return mo + "/" + dy + "/" + yr;
	}
}

// window.onload
var onloadFunctions = new Array();
AddOnloadFunction = function( func )
{
	onloadFunctions[ onloadFunctions.length ] = func;
}
window.onload = function()
{
	for( var i=0; i<onloadFunctions.length; i++ )
		eval(onloadFunctions[i]);
}

function isValidEmail( str ) 
{
	if( str == null || str.length < 6 ) return false; 
	
	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(" ")!=-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;
	
	return true;					
}


function Trim(str)
{
	if(str.length < 1) return "";
	str = RTrim(str);
	str = LTrim(str);
	return str;
}

function RTrim(str)
{
	var w_space 	= String.fromCharCode(32);
	var v_length 	= str.length;
	var strTemp 	= "";
	
	if(v_length < 0) return "";
	
	var iTemp = v_length -1;
	
	while(iTemp > -1)
	{
		if(str.charAt(iTemp) != w_space)
		{
			strTemp = str.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} 
	return strTemp;
}

function LTrim(str)
{
	var w_space 	= String.fromCharCode(32);
	var v_length 	= str.length;
	var strTemp 	= "";

	if(v_length < 1) return "";
	
	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(str.charAt(iTemp) != w_space)
		{
			strTemp = str.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}

//function Detail( aid )
//{
//	window.open( AppRoot + "footage/preview.aspx?aid=" + aid, "clip", "height=400,width=800,resizable=yes,scrollbars=yes,statusbar=no" );
//}

//Modified by Hemant Angane on 24th Sept 2006 for SFE ID 114
function Detail( aid )
{
	newwindow = window.open( AppRoot + "footage/preview.aspx?aid=" + aid, "clip", "height=400,width=800,resizable=yes,scrollbars=yes,statusbar=no" );//Added by by Hemant Angane on 24th Sept 2006 for SFE ID 114
	//window.open( AppRoot + "footage/preview.aspx?aid=" + aid, "clip", "height=400,width=800,resizable=yes,scrollbars=yes,statusbar=no" ); //Commented by Hemant Angane on 24th Sept 2006 for SFE ID 114
	if (window.focus) {newwindow.focus()} //Added by Hemant Angane on 24th Sept 2006 for SFE ID 114
	
}


function Login( aid )
{
	location.href = AppRoot + "account/login.aspx";
}

//ID 164 ON HOLD as on 26th OCT 2006)
//START-->Added by Hemant Angane for SFE ID 164 on 17th October 2006 
//function PreviewWindow(aid)
//{
//newwindow = window.open( AppRoot + "footage/PreviewClip.aspx?aid=" + aid, "_blank", "height=600,width=800,resizable=yes,scrollbars=yes,statusbar=no",target="_blank" );//Added by by Hemant Angane on 24th Sept 2006 for SFE ID 114
	////window.open( AppRoot + "footage/preview.aspx?aid=" + aid, "clip", "height=400,width=800,resizable=yes,scrollbars=yes,statusbar=no" ); //Commented by Hemant Angane on 24th Sept 2006 for SFE ID 114
	//if (window.focus) {newwindow.focus()} //Added by Hemant Angane on 24th Sept 2006 for SFE ID 114
//}
//END-->Added by Hemant Angane for SFE ID 164 on 17th October 2006 