function submitFormOnEnter( pFormId, pController, e ) {
if (!e) {
var e = window.event;
}
var code;
if (e.keyCode) {
code = e.keyCode;
}	else if (e.which) {
code = e.which;
}
if (code == 13) {
var form = null;
form = document.getElementById( pFormId );
if ( pController != null ) {
form.action=pController;
}
form.target=window.name;
form.submit();
}
}
function checkKey( keyPressed ) {
var charCode = (navigator.appName == "Netscape") ? keyPressed.which : keyPressed.keyCode;
if ( charCode == "013" ) {
areCookiesEnabled();
}
}
function areCookiesEnabled() {
document.cookie = "Enabled=true";
var cookieValid = document.cookie;
if(cookieValid.indexOf("Enabled=true") == -1) {
location.href = '/wx/[LBL_LANGUAGE]/WXSession/WXSessionCookiesDisabled.htm' ;
} else {
document.LOGIN.action="https:\/\/www.globalwinespirits.com\/wx\/[LBL_LANGUAGE]\/SESSION.LOGIN" ;
document.LOGIN.target="_top"
document.LOGIN.submit();
}
}
function askSecretAnswer() {
document.LOGIN.action="https:\/\/www.globalwinespirits.com\/wx\/[LBL_LANGUAGE]\/Password.SecretQuestion$Prep" ;
document.LOGIN.submit();
}
function SPWindow() {
sp = window.open( "/wx/de/WXMessage/WXDownloadSP2.htm" , "HELP_WINDOW", "height=375,width=750,resizable=yes,scrollbars=yes,status=no,menubar=no,location=no,directories=no" );
}
function getScreenRes() {
document.LOGIN.ScreenResolution.value = screen.height + " X " + screen.width;
}
function detect_browser(){
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
if ( is_ie ){
SPIndex = navigator.appMinorVersion.indexOf(";SP");
if (SPIndex != -1){
ServicePackLevel =
navigator.appMinorVersion.substring( SPIndex+3,
navigator.appMinorVersion.indexOf(";", SPIndex+2));
} else {
ServicePackLevel = null;
}
} else {
ServicePackLevel = null;
}
if ( is_ie5_5 && ( ServicePackLevel == null )){
SPWindow();
} else {
document.LOGIN.Session_Username.focus();
}
}
function calculateDaysLeft(start, end, imgElapse, imgLeft, ratio, height){

var splS = start.split('/');
var splE = end.split('/');
var today=new Date();
var endDate=new Date(splE[0], splE[1]-1, splE[2]); 
endDate.setHours(23);
endDate.setMinutes(59);
endDate.setSeconds(59);
var startDate=new Date(splS[0], splS[1]-1, splS[2]);

var one_day=1000*60*60*24;

var daysLeft = Math.ceil((endDate.getTime()-today.getTime())/(one_day));

var allDays =  Math.ceil((endDate.getTime()-startDate.getTime())/(one_day));
var ratioElapse;
var ratioLeft;
if ( allDays != 0 ) {
ratioLeft = (allDays-daysLeft)/allDays*ratio;
ratioElapse = daysLeft/allDays*ratio;
} else {
ratioElapse = 0;
ratioLeft = ratio;
}




document.write(daysLeft +" "+ "Verbleibende Zeit" );
}
function switchAllSections( pAction, pCount ) {
var wButtonExpandAll = document.getElementById( "expandAll" );
var wButtonCollapseAll = document.getElementById( "collapseAll" );
for ( i=1; i <= pCount; i++ ) {
var wRowName = 'productRowHidden'+i;
var buttonExp = 'expand'+i;
var buttonColl = 'collapse'+i;
if ( pAction == 'expandAll' ) {
switchSections( '', wRowName, buttonExp, buttonColl );
wButtonExpandAll.style.display = "none";
wButtonCollapseAll.style.display = "";
} else {
switchSections( wRowName, '', buttonColl, buttonExp );
wButtonExpandAll.style.display = "";
wButtonCollapseAll.style.display = "none";
}
}
}
