/**
 * @file
 * DCDS IS PROTECTED BY INTELLECTUAL PROPERTY LAWS
 * This file is part of the Digital Content Delivery System (DCDS)
 * This is a licensed open source software and shall not be used 
 * without the explicit written permission of the author.
 * Non permitted use of this software, also the non permitted use of
 * only a part of this software is considered as breach of copyright. 
 * The commercially use of this software without explicit permission 
 * of the author is considered as criminal breach of copyright laws. 
 * 
 * Author: Nicolaus Sommer (c) copyright 2009
 *         Nicolaus[at]Sommer.us
 *         http://www.sommer.us
 */
PopUpWidth  =  730;
PopUpHeight =  600;
PopUpLeft   =  (screen.width-PopUpWidth)/2;
PopUpTop    =  (screen.height-PopUpHeight)/2;
PopUpOptions= ',toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,dependent=1';
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
popO='left='+PopUpLeft+',top='+PopUpTop+',width='+PopUpWidth+',height='+PopUpHeight+PopUpOptions;
if (isIE||isNN) {
	document.oncontextmenu=checkV;
} else {
	document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
	document.onmousedown=checkV;
}
function checkV(e) {
	if (isN4){
		if (e.which==2||e.which==3){
			return false;
		}
	} else {
		return false;
	}
}
function ShowPopUp(PopURL) {
	dPUW=window.open(PopURL,'terms',popO);
	dPUW.focus();
}
function MM_openBrWindow(theURL,winName,features) {
	dPUW=window.open(theURL,'terms',popO);
	dPUW.focus();
}
function fieldAdvance( e, ctrlid, ctrlIdToFocus, ctrlidprev ) 
{
    //event codes values
    //9 = tab
    //16 = shift + tab
    //37 = left arrow
    //39 = right arrow
    //13 = enter button
    //if none of these keys are pressed then go inside the if and proceed
    
    var myKeyCode
    
    if ( e.which != null) {
        myKeyCode = e.which;
	} else {
        myKeyCode = e.keyCode;
	}
    if ( myKeyCode != 9 && myKeyCode != 16 && myKeyCode != 37 && myKeyCode != 39) {   
        //keycode 8 = backspace
        //if the backsapce was not pressed check the length of the textbox and go forward
        if ( myKeyCode != 8 ) {
            var ctrlToFocus = document.getElementById( ctrlIdToFocus );       
            if ( document.getElementById( ctrlid ).value.length == document.getElementById( ctrlid ).maxLength ) {
                ctrlToFocus.focus();   
                ctrlToFocus.value = ctrlToFocus.value;         
            }
        } else {
            var ctrlToFocus = document.getElementById( ctrlidprev ); 
            if ( document.getElementById( ctrlid ).value.length == 0 ) {
                ctrlToFocus.focus();
                ctrlToFocus.value = ctrlToFocus.value;
            }
        }    
    }
}    
