//===========================
//disable right click
//===========================
/////function click(e){if (document.all) if (event.button == 2) return false;if
/////(document.layers) if (e.which == 3) return false;}
/////function click2(){event.returnValue=false;return false;}if (document.layers)
/////document.captureEvents(Event.MOUSEDOWN);document.onmousedown=click;document.oncontextmenu=click2;


var currentsec=0;	// initilize variables
var currentmin=0;	// to zero
var currentmil=0;
var keepgoin=false;		// keepgoin is false
function timer(){
 if(keepgoin){
  currentmil+=1;		// add incretement
   if (currentmil==10){		// if miliseconds reach 10
    currentmil=0;		// Change miliseconds to zero
    currentsec+=1;		// and add one to the seconds variable
   }
   if (currentsec==60){		// if seconds reach 60
    currentsec=0;		// Change seconds to zero
    currentmin+=1;		// and add one to the minute variable
   }
  Strsec=""+currentsec;		// Convert to strings
  Strmin=""+currentmin;		// Convert to strings
  Strmil=""+currentmil;		// Convert to strings
   if (Strsec.length!=2){	// if seconds string is less than
    Strsec="0"+currentsec;	// 2 characters long, pad with leading
   }				// zeros
   if (Strmin.length!=2){	// Same deal here with minutes
    Strmin="0"+currentmin;
   }
  document.display.seconds.value=Strsec		// displays times
  document.display.minutes.value=Strmin;	// here
  document.display.milsecs.value=Strmil;
  setTimeout("timer()", 100);	// waits one second and repeats
 }
}
function startover(){		// This function resets
keepgoin=false;			// all the variables
currentsec=0;
currentmin=0;
currentmil=0;
Strsec="00";
Strmin="00";
Strmil="00";
}


function closeWindow()
{
	top.close()
}

function BookmarkLocation(sBookmarkTitle)
{
	var iPlayerMode=parent.left.REALPLAYER.GetPlayState();
	if ((iPlayerMode==3) || (iPlayerMode==4) )
	{
		var iMS=parent.left.REALPLAYER.GetPosition();
		var sMSF=ConvertMS(iMS)
		window.document.frm.txtArea.focus();
		var sMSBegDel='-'
		var sMSEndDel='-'
		var sMSFBegDel='('
		var sMSFEndDel=')'
		var sBookmarkCaptionBegDel='>' 
		var sBookmarkCaptionDefault=sBookmarkTitle
		window.document.frm.txtArea.value=window.document.frm.txtArea.value+'\n'+sMSBegDel+iMS+sMSEndDel+sMSFBegDel+sMSF+sMSFEndDel+sBookmarkCaptionBegDel+sBookmarkCaptionDefault;
	}
	else
	{
		alert('Bookmarking is available only when the media file is currently playing.')
	}

	return false;
}



function ConvertMS(Val){
Val = Val*1
var iSaniye
var igeriKalan
var iSonucDakika
var iSonucSaat
var iSonucSaniye

iSaniye = Math.round(Val / 1000)
igeriKalan = iSaniye

iSonucSaniye=0
iSonucDakika=0
iSonucSaat=0

while (igeriKalan >= 60)
{
    igeriKalan = igeriKalan - 60
    iSonucDakika = iSonucDakika + 1
}

iSonucSaniye = igeriKalan
igeriKalan = iSonucDakika

while (igeriKalan >= 60)
{
    igeriKalan = igeriKalan - 60
    iSonucSaat = iSonucSaat + 1
}

iSonucDakika = igeriKalan

if (iSonucSaniye == 60)
{
    iSonucSaniye = 0
    iSonucDakika = iSonucDakika + 1
}

if (iSonucDakika == 60)
{
    iSonucDakika = 0
    iSonucSaat = iSonucSaat + 1
}


iSonucSaniye=iSonucSaniye+''
iSonucDakika=iSonucDakika+''
iSonucSaat=iSonucSaat+''

if (iSonucSaniye.length == 0)
{
	iSonucSaniye = "00"
}

if (iSonucSaniye.length == 1)
{
    iSonucSaniye = "0" + iSonucSaniye
}



if (iSonucDakika.length == 0)
{
    iSonucDakika = "00"
}

if (iSonucDakika.length == 1)
{
	iSonucDakika = "0" + iSonucDakika
}



if (iSonucSaat.length == 0)
{
	iSonucSaat = "00"
}

if (iSonucSaat.length == 1)
{
	iSonucSaat = "0" + iSonucSaat
}



Val = iSonucSaat + ":" + iSonucDakika + ":" + iSonucSaniye

return Val

}

function leftOf(smstring,lrgstring) {

//returns leftmost characters of lrgstring up to smstring.
//If user passes an empty string, change that to a space.
if (smstring == ""){smstring = " "}
strlen1 = smstring.length
strlen2 = lrgstring.length
foundat = 0
for (i=0;i<=strlen2;i++) {
	comp=lrgstring.substring(i-1,strlen2)
	comp = comp.substring(0,strlen1)		
	if (comp == smstring) {
		foundat = i
		break
	}
}
return lrgstring.substring(0,(foundat-1))
}

function rightOf(smstring,lrgstring) {

	//returns the rightmost characters of lrgstring back to smstring.
	//If user passes an empty string, change that to a space.
	if (smstring == ""){smstring = " "}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=strlen2;i>=0;i--) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)		
		if (comp == smstring) {
			foundat = i
			break
		}
	}
	return lrgstring.substring(foundat,255)
}


function centeredPopup(URL,w,h) {

    //sample call <a href="javascript:popup('index.htm','600','368')">screen saver 1 </a>	
    if (document.all)
    {
        var xMax = screen.width, yMax = screen.height;
    }
    else
    {
        if (document.layers)
        {
            var xMax = window.outerWidth, yMax = window.outerHeight;
		}
        else
        {
            var xMax = 640, yMax=480;
        }
	}

	var xOffset = (xMax - w)/2
	var yOffset = (yMax - h)/2
	var sCenteringString;
	sCenteringString = ',screenX=' + xOffset + ',screenY=' + yOffset + ',top='+ yOffset + ',left=' + xOffset + ''
	var day = new Date();
	var id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h + sCenteringString);");
}

function postToPopup(f,decorations) {

    var targetWindow = window.open("","formWindow",decorations);
    return true;
}


function ReplaceString(sFull, sOld, sNew) {

  var sData = "";
  for (var i=0; i<sFull.length; i++) { 
  if (sFull.substring(i,i+sOld.length) == sOld) {
      sData = sData + sNew;
      i = i + sOld.length - 1;
  } else { sData = sData + sFull.substring(i,i+1) }
  }
  return sData;
}

function replacestring(sFull, sOld, sNew) {

  var sData = "";
  for (var i=0; i<sFull.length; i++) { 
  if (sFull.substring(i,i+sOld.length) == sOld) {
      sData = sData + sNew;
      i = i + sOld.length - 1;
  } else { sData = sData + sFull.substring(i,i+1) }
  }
  return sData;
}





function getinbetween2(sContents, sBeginningKey, sEndingKey) {

     //this is not case sensitive
	//? GetInBetween2("<1>ddd<2>jjj", "<1>", "<2>")
	//ddd
	//? getinbetween2("<1>ddd<1>jjj","<1>","<1>")
	//ddd
	var sText;
	var iBeginningKeyStartsAt;
	var sEndingKeyStartsAt;
	var vbTextCompare;
	var sCapturedResult;
	vbTextCompare=true;
	sText = sContents
	iBeginningKeyStartsAt = instr(1, sContents, sBeginningKey, vbTextCompare);
	sEndingKeyStartsAt = instr(1, sContents, sEndingKey, vbTextCompare);
	if (iBeginningKeyStartsAt > 0 && sEndingKeyStartsAt > 0) {
	   sText = right(sText, (len(sText) - (iBeginningKeyStartsAt + (len(sBeginningKey) - 1))));
	   sText = left(sText, (instr(1, sText, sEndingKey, vbTextCompare) - 1))
	   if ( sText == "" ) {
	      sCapturedResult = ""
	   }
	   else{
	      sCapturedResult = sText
	   }
	}
	else{
	  sCapturedResult = ""
	}
    return sCapturedResult;
}


function instr(iStartingFrom,lrgstring,smstring,bolNotCaseSensitive) {

	//returns a number indicating the spot where smstring appears in lrgstring.
    //behaves exactly like vb's instr function
    //this is how to use 
    /*
	var sString;
	var sSearch;
	var iStartingFrom;
	var vbTextCompare;
	vbTextCompare=true;
	sString='hello World this is a simple string. ';
	sSearch='hello';
	iStartingFrom=1;

	alert(instr(iStartingFrom,sString,sSearch,vbTextCompare)) ;
    */
	
	lrgstring=lrgstring.substring(iStartingFrom-1,lrgstring.length)
	//alert('after the cut' + lrgstring)
	if ( bolNotCaseSensitive ) {
		lrgstring=lrgstring.toLowerCase();	
		smstring=smstring.toLowerCase();
	}	
    // this function has a bug, when the searched word is found at the beginning of the large word , it returns 0!..
    //following fix is just for that !...
   	if ( smstring == lrgstring.substring(0,smstring.length) ) {
   	   //set foundat to 1 and return immediately since smstring is found at the beginning of the lrgstring already !...
   	   foundat=1;
   	   return foundat;
   	}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=0;i<=strlen2;i++) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)		
		if (comp == smstring) {
			foundat = i
			break
		}
	}
   	
	
	if ( iStartingFrom != 1 ) {
	    return foundat-(iStartingFrom-1);
	}
	else{
		return foundat;	
	}
}

function right(str,n) {

	//returns the right n characters of str
	strlen = str.length
	return str.substring(strlen-n,strlen)
}


function mid(str,start,n) {

	//returns a substring of str starting at 'start' that's n characters long.
	//alert('mid param n is passed as ' + n);
	if ( (n == null) || n == "undefined" ) {
	   n = str.length;
	}
	strlen = str.length
	var jj = str.substring(start-1,strlen)
	jj = jj.substring(0,n)
	return jj
}

function left(str,n) {

	//returns the left n characters from str.
	return str.substring(0,n)
}




function len(str) {
/***
        IN: str - the string whose length we are interested in

        RETVAL: The number of characters in the string
***/
  alert('len is in use')	
  return String(str).length;  
}
 



var bolformAlreadySubmitted=false;

function ValidateSignUpForm()
{

	var sEMAIL;
	var sPWD;
	var sPWD2;

	sEMAIL= window.document.frm.EMAIL.value
	sPWD= window.document.frm.PWD.value
	sPWD2= window.document.frm.PWD2.value


	//check required fields

	if ( sEMAIL.length==0 )
	{
		alert('Please fill in your email.\n\nThis must be your primary email as your UserID and your confirmation for Media Library Registeration will be sent to this address.')
		document.frm.EMAIL.focus();
		return false;
	}




	if ( sPWD.length==0 )
	{
		alert('Please fill in your password')
  		document.frm.PWD.value = ''
		document.frm.PWD2.value = ''
  		document.frm.PWD.focus();
		return false;

	}

	//check logical problems

	if (!isvalidemail(sEMAIL))
	{
		alert('Your user EMAIL, does not seem to be valid. ')
		document.frm.EMAIL.focus();
		return false;
	}


	//passwords same ?


	if ( sPWD != sPWD2 )
	{
  		alert('Passwords did not match. Please re-type your password.');
  		document.frm.PWD.value = ''
		document.frm.PWD2.value = ''
  		document.frm.PWD.focus();
		return false;
	 }
	 else
 	{
  		//passwords do match, check to see if they are in between 6 and 10 in character length
  		if (!((sPWD.length > 5) && (sPWD.length < 11)))
		{
   			alert('For your protection, it is required that your password should be within 6 to 10 characters long.');
  			document.frm.PWD.value = ''
			document.frm.PWD2.value = ''
  			document.frm.PWD.focus();
  			return false;
		  }
		  else
  		  {
   			if (instr(1,document.frm.PWD.value," ",true))
   			{
    				alert('Please do not use space character in your password.');
	  			document.frm.PWD.value = ''
				document.frm.PWD2.value = ''
  				document.frm.PWD.focus();
  				return false;

			}
					else
					{
							//passwords are correctly filled !..
							return true;
					}


		 }
	}
}


function isvalidemail(emailStr) {


/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address.
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	//alert("Invalid email address structure detected.")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid
if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   //alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


var windowW=390  // wide
var windowH=500  // high
// set vertical offset if you want the popup
// to rise above or stop below screen bottom;
var Yoffset=0   // in pixels, negative values allowed
// set the vertical motion parameters
var windowStep=2 // move increment (pixels)
var moveSpeed=10 // move speed (larger is slower)
// set the horizontal positioning of the window
// choices are left, center, right
Xmode="right";
// in left or right Xmode, set any offset from
// the screen edge here, if desired
Xoffset=35;

// set the title of the page
var title =  "Multimedia Center Auto Login Display";
// set this to true if the popup should close
// upon leaving the launching page; else, false
var autoclose = true
// ============================
// do not edit below this line
// ============================
var windowX = (screen.width/2)-(windowW/2);
if (Xmode=="left") windowX=0+Xoffset;
if (Xmode=="right") windowX=screen.availWidth-Xoffset-windowW;
var windowY = (screen.availHeight);
var windowYstop = windowY-windowH-Yoffset;
var windowYnow = windowY;
s = "width="+windowW+",height="+windowH;

var beIE = document.all?true:false




function SlideWindow(urlPop){  


  if (beIE){
    PFW = window.open("","MultimediaCenterAutoLoginDisplay","fullscreen,"+s)     
    PFW.blur()
    window.focus()       
    PFW.resizeTo(windowW,windowH)
    PFW.moveTo(windowX,windowY)
    var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
    PFW.document.open();
    PFW.document.write(frameString)
    PFW.document.close()
  } else {
    PFW=window.open(urlPop,"Multimedia Center Auto Login Display","scrollbars,"+s)
    PFW.blur()
    window.focus() 
    PFW.resizeTo(windowW,windowH)
    PFW.moveTo(windowX,windowY)
  }   
  PFW.focus()   
  if (autoclose){
    window.onunload = function(){PFW.close()}
  }
  movePFW();
}

function movePFW(){
  if (document.all){
    if (windowYnow>=windowYstop){
      PFW.moveTo(windowX,windowYnow);
      PFW.focus();
      windowYnow=windowYnow-windowStep;
      timer=setTimeout("movePFW()",moveSpeed);
    }else{
      clearTimeout(timer);
      PFW.moveTo(windowX,windowYstop);
      PFW.focus();
    }
  }else{
    PFW.moveTo(windowX,windowYstop);
  }
}


function loadIntoOpener(URL,sWP) {

    //used by the child window refreshing the media display... if media display happens to be closed by user, this function
    //by passes the fatal callee not available run time error and instead of it lauches a new window in the proper size
    
    if (opener && !opener.closed)
        opener.location=URL;
    else {
        var myWin = window.open(URL,'',sWP);
        // trick the window into thinking it was opened by this new window:
        opener = myWin;
    }
}

function PopInstantWindowMessage(sContent,sWP)
{
	NW=window.open('','name',sWP);
	NW.document.write(sContent);
	NW.document.close();
}


function popWindowRunScript(sURL,sWP)
{
	var winRunScript=window.open(sURL,'winRunScript',sWP)
}


function Post2Target(sUrl, sTarget,iWidth, iHeight,sWin) {

	var dt = new Date();
	var sWinName = 'TempWin' + dt.getMonth() + dt.getDate() + dt.getYear()+ dt.getHours() + dt.getMinutes() + dt.getSeconds();
	//screen object is not understood by netscape 3
	var winX = ((screen.height-iHeight)/2);
	var winY = ((screen.width-iWidth)/2);
        if ( sWin == null ) {

		sWin = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no' + ',width=' + iWidth +',height=' + iHeight + ',top='+ winX +',left='+ winY + '';
        }

	else{
		sWin = sWin  + ',width=' + iWidth +',height=' + iHeight + ',top='+ winX +',left='+ winY + '';
	}
	if (sTarget==''){
		var FloatWin = window.open(sUrl, sWinName, sWin);
	}
	else
	{
		if (sTarget=='self')
		{

			//?
		}
		else
		{
			//alert('submit to frame '+sTarget)
			var sStringToExecute = 'parent.' + sTarget + '.location.href="' + sUrl + '"'
			eval(sStringToExecute)
		}

	}

}


function post2popup(f,decorations) {

	//insert this into frmaction [[[ onSubmit="return post2popup(this,'width=290,height=400,resizable=yes,scrollbars=yes,toolbar=no,titlebar=no');" target="formWindow"  ]]]

	var sUID;
	var sPWD;
	var bolReturnFalse;

	sUID= window.document.frm.UID.value
	sPWD= window.document.frm.PWD.value

	bolReturnFalse=true;

	//check required fields

	if ( sUID.length==0 )
	{
		alert('Please fill in your ID\n\nThis must be your primary email as the confirmation will be sent to this address.')
		bolReturnFalse=false;
	}

	if ( sPWD.length==0 )
	{
		alert('Please fill in your password')
		bolReturnFalse=false;
	}

	//check logical problems

	if ( bolReturnFalse )
	{
		var targetWindow = window.open("","formWindow",decorations);

		return true;

	}
	else
	{
		return false;
	}



}



//function handleError() {
//	alert('An error happened. \n\n\Media Display Window is closed.');
//	return true;
//}
//
//window.onerror = handleError;


//--end hide -->

