﻿// JScript File
// functions for Gyldendal Business

function ignoreFold(e)
{
	if(!e) 
		e = window.event;
    
	e.cancelBubble = true;

	if (e.stopPropagation) 
		e.stopPropagation();
}

function validateInt(inputStr)
{
    if(inputStr.indexOf(",")!=-1)
	{
		alert("Der må kun angives tal eller komma.");
		var repl = /\,/gi;
		inputStr = inputStr.replace(repl, "");
	}
	return inputStr;
}

function loginFunction()
{
    alert('Her har vi loginFunction i js/JSInlineGyldendalBusiness.js...');
} // end of loginFunction(0)

//function forgotPasswordFunction()
//{
//    alert('Her har vi forgotPasswordFunction i js/JSInlineGyldendalBusiness.js...');
//} // end of forgotPasswordFunction(0)

//function newUser1Function()
//{
//    alert('Her har vi newUser1Function i js/JSInlineGyldendalBusiness.js...');
//} // end of newUser1Function(0)

function newUser2Function()
{
    alert('Her har vi newUser2Function i js/JSInlineGyldendalBusiness.js...');
} // end of newUser2Function(0)

function saadanHandlerDuFunction()
{
    alert('Her har vi saadanHandlerDuFunction i js/JSInlineGyldendalBusiness.js...');
} // end of saadanHandlerDuFunction(0)

function spoergsmaalFunction()
{
    alert('Her har vi spoergsmaalFunction i js/JSInlineGyldendalBusiness.js...');
} // end of spoergsmaalFunction(0)

function presseFunction()
{
    alert('Her har vi presseFunction i js/JSInlineGyldendalBusiness.js...');
} // end of presseFunction(0)

function omForlagetFunction()
{
    alert('Her har vi omForlagetFunction i js/JSInlineGyldendalBusiness.js...');
} // end of omForlagetFunction(0)

function kontaktFunction()
{
    alert('Her har vi kontaktFunction i js/JSInlineGyldendalBusiness.js...');
} // end of kontaktFunction(0)

function aktueltFunction()
{
    alert('Her har vi aktueltFunction i js/JSInlineGyldendalBusiness.js...');
} // end of aktueltFunction(0)

//function forfattereFunction()
//{
//    alert('Her har vi forfattereFunction i js/JSInlineGyldendalBusiness.js...');
//} // end of forfattereFunction(0)

//function arrangementerFunction()
//{
//    alert('Her har vi arrangementerFunction i js/JSInlineGyldendalBusiness.js...');
//} // end of arrangementerFunction(0)

function artiklerFunction()
{
    alert('Her har vi artiklerFunction i js/JSInlineGyldendalBusiness.js...');
} // end of artiklerFunction(0)

function showLoginFunction()
{
    document.getElementById('login_closedID').style.display='none';
    document.getElementById('login_openID').style.display='';
    
} // end of showLoginFunction(0)

function hideLoginFunction(thisGiven)
{
    //alert('This is: ' + thisGiven + ', thisname: ' + thisGiven.name + ', thisid: ' + thisGiven.id);
    document.getElementById('login_closedID').style.display='';
    document.getElementById('login_openID').style.display='none';
    
} // end of showLoginFunction(0)


function laesmereOmBogbidderFunction()
{
    alert('Læs mere om bogbidder...');
} // end of laesmereOmBogbidderFunction(0)

function laesmereOmAbstractsFunction()
{
    alert('Læs mere om abstracts...');
} // end of laesmereOmAbstractsFunction(0)

function laesmereOmLydAbstractsFunction()
{
    alert('Læs mere om lyd abstracts...');
} // end of laesmereOmLydAbstractsFunction(0)

function laesmereOmLaeseguidesFunction()
{
    alert('Læs mere om læseguides...');
} // end of laesmereOmLaeseguidesFunction(0)

//function putInBasketFunction(id)
//{
//    alert('Her har vi putInBasketFunction i js/JSInlineGyldendalBusiness.js, with id: ' + id + '...');
//} // end of putInBasketFunction(0)

//function produktStorPutInBasketFunction(id)
//{
//    alert('Her har vi produktStorPutInBasketFunction i js/JSInlineGyldendalBusiness.js, with id: ' + id + '...');
//} // end of produktStorPutInBasketFunction(0)

function produktGreenKoebAbstractPutInBasketFunction(id)
{
    alert('Her har vi produktGreenKoebAbstractPutInBasketFunction i js/JSInlineGyldendalBusiness.js, with id: ' + id + '...');
} // end of produktGreenKoebAbstractPutInBasketFunction(0)

function produktGreenKoebMP3AbstractPutInBasketFunction(id)
{
    alert('Her har vi produktGreenKoebMP3AbstractPutInBasketFunction i js/JSInlineGyldendalBusiness.js, with id: ' + id + '...');
} // end of produktGreenKoebMP3AbstractPutInBasketFunction(0)

//function getAuthorFunction()
//{
//    alert('Her har vi getAuthorFunction i js/JSInlineGyldendalBusiness.js...');
//} // end of getAuthorFunction(0)

function produktStorTipEnKollegaFunction()
{
    alert('Her har vi produktStorTipEnKollegaFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktStorTipEnKollegaFunction(0)

function produktStorGreenLaesMereBogbidderFunction()
{
    alert('Her har vi produktStorGreenLaesMereBogbidderFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktStorGreenLaesMereBogbidderFunction(0)

function produktStorGreenLaesMereLaeseguideFunction()
{
    alert('Her har vi produktStorGreenLaesMereLaeseguideFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktStorGreenLaesMereLaeseguideFunction(0)

function produktStorGreenLaesMereKoebAbstractFunction()
{
    alert('Her har vi produktStorGreenLaesMereKoebAbstractFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktStorGreenLaesMereKoebAbstractFunction(0)

function produktStorGreenLaesMereKoebMP3AbstractFunction()
{
    alert('Her har vi produktStorGreenLaesMereKoebMP3AbstractFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktStorGreenLaesMereKoebMP3AbstractFunction(0)

function produktGreenBogbidderTilmeldFunction()
{
    alert('Her har vi produktGreenBogbidderTilmeldFunction i js/JSInlineGyldendalBusiness.js...');
} // end of produktGreenBogbidderTilmeldFunction(0)

function goHomeFunction()
{
    alert('Her har vi goHomeFunction i js/JSInlineGyldendalBusiness.js...');
} // end of goHomeFunction(0)

function showRabatInInkoebskurv()
{
    if (document.getElementById('indtastrabatkode').value == '')
        document.getElementById('showRabatTd').innerHTML = '<label class="basketPrice">-00,00 (m.moms)</label>';
    else
        document.getElementById('showRabatTd').innerHTML = '<label class="basketPrice">-' + document.getElementById('indtastrabatkode').value + ' (m.moms)</label>';
} // end of showRabatInInkoebskurv(0) function

function checkAdresse(frmObject)
{
    var message = '';
    if (frmObject.name.value == '')
        message += '\n\'Navn\'';
    if (frmObject.occupation.value == '')
        message += '\n\'Titel/funktion\'';
    if (frmObject.address.value == '')
        message += '\n\'adresse\'';
    if (frmObject.postalcode.value == '')
        message += '\n\'Postnr.\'';
    if (frmObject.city.value == '')
        message += '\n\'By\'';
    if (frmObject.country.value == '')
        message += '\n\'Land\'';
    if (frmObject.email.value == '')
        message += '\n\'Email\'';
    else
        if (!isemail(frmObject.email.value))
            message += '\n\'E-mailadressen er ugyldig\'';
    if (message != '')
    {
        alert('Adressen kan ikke anvendes da der mangler følgende felter:\n' + message);
        return false;
    }
}

function checkOpretNyKontoSyntax()
{
    var message = '';
    if (!isemail(document.frmUserCreate.us_login.value))
    message ='Ugyldig email adresse...';
    if ((document.frmUserCreate.us_password.value != document.frmUserCreate.us_passwordKontrol.value) || (document.frmUserCreate.us_password.value == ''))
        message += '\nDu skal angive det samme kodeord to gange...';
    if (message != '')
    {
        alert(message);
        return;
    }
    document.frmUserCreate.submit()
} // end of checkOpretNyKontoSyntax(0) function

function isemail(s) {
	re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/

	var ss = new String(s);
	
	var pos = ss.match(re); 
	if(pos!=null)
		return(true);
	else
		return(false);
}
function isphone(s) {
	rem = /((\+?\s?\(\s?([0-9]{2})\s?\)\s?)?\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1})\s?([0-9]{1}))/
	try {
		var pos = s.match(rem);
		if(pos["index"]==0 && pos[0]==s)
			return(true);
		else {
			return(false);
		}
	}
	catch(e) {
		return(false);
	}
}

function isalpha(s) {
	re = /[0-9]/

	var ss = new String(s);
	
	var pos = ss.search(re); 
	if(pos==-1)
		return(true);
	else
		return(false);
}

function isalnum(s) {
	return(true);
}

function isdigit(s) {
	re = /[^0-9]/

	var ss = new String(s);

	var pos = ss.search(re); 
	if(pos==-1)
		return(true);
	else
		return(false);
}

var hWnd;
function hWndPopup(url)
{
    if(hWnd && hWnd.location)
        try {
            hWnd.location = url;
        }
        catch(e) {
            hWnd = window.open (url,"hWnd","location=1,status=1,scrollbars=1,width=980,height=600");
        }
    else
        hWnd = window.open (url,"hWnd","location=1,status=1,scrollbars=1,width=980,height=600");
    hWnd.focus();
} 

function mailEncode(obj,id) {
    objSubject = document.getElementById('subject'+id)
    objBody    = document.getElementById('body'+id)

    obj.href="mailto:?subject=" + escape(objSubject.innerHTML) + "&body=" + escape(objBody.innerHTML)
    return true;
}
