//browser detect
sAppName	= navigator.appName.toLowerCase();
sAppVersion	= navigator.appVersion.toLowerCase();
sUserAgent	= navigator.userAgent.toLowerCase();

sWin	= (sAppVersion.indexOf("win")>=0);
sLinux	= (sAppVersion.indexOf("x11")>=0);
sMac	= (sAppVersion.indexOf("mac")>=0);
	
bOpera	= (sUserAgent.indexOf('opera')>=0);
bGecko	= ((sUserAgent.indexOf('gecko')>=0) && (!bOpera));
bIe		= ((sUserAgent.indexOf('msie')>=0) && (!bOpera));
bNs		= (document.layers);
iVer 	= 0;

if (bOpera) iVer = parseFloat(sUserAgent.slice(sUserAgent.indexOf('opera')+6));
if (bGecko) iVer = parseFloat(sAppVersion);
if (bIe) 	iVer = parseFloat(sUserAgent.slice(sUserAgent.indexOf('msie')+5));
if (bNs)	iVer = parseFloat(sAppVersion);

//set explorer image toolbar off
document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\">");

function emailCheck(src) {
	var regex = /^[&a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return (regex.test(src));
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
	var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//get style element of css
getStyleObject = function(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
    } else {
		return false;
	}
}

//get object of css
getObject = function(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
		return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
    } else {
		return false;
	}
}

function getScreenWidth() {
	if (bOpera || bIe) return document.body.clientWidth;
	else if (bGecko) return document.body.clientWidth;
	else return window.innerWidth-20;
}
function getScreenHeight() {
	if (bOpera || bIe) return document.body.clientHeight;
	else if (bGecko) return document.body.clientHeight;
	else return window.innerHeight-20;
}

function getCaptionPic(thumbCategory) {
		var oDiv = getStyleObject("captionPic");
		var sString = "<img src=\"ecards/" + thumbCategory + "\" class=\"ecardThumb\">";
		getObject("captionPic").innerHTML = sString;	
		oDiv.visibility = "visible";
}
function hideCaptionPic() {
		oDiv = getStyleObject("captionPic");
		oDiv.visibility = "hidden";		
		resetCaptionPic();		
}
function resetCaptionPic() {
		var oDiv = getStyleObject("captionPic");
		var sString = "<img src=\"img/ecardTeaser.jpg\" class=\"ecardThumb\">";
		getObject("captionPic").innerHTML = sString;	
		oDiv.visibility = "visible";
}

//set ecard variables
var ecardsTimer;
var ecardsDrag = false;

// show ecard tooltip
function ecardsShowTip(sTip) {
	if(!bNs & !ecardsDrag) {
		getObject("ecardsTipContent").innerHTML = sTip;
		window.status = sTip;
		oDiv = getStyleObject("ecardsTip");
		oDiv.visibility = "visible";
		oDiv.left = muisX + 10;
		oDiv.top = muisY - 65;
		oDiv.width= 200;
		if(ecardsTimer!="") clearTimeout(ecardsTimer);
	}
}

// hide ecard tooltip after x seconds
function ecardsHideTip() {
	if(!bNs) ecardsTimer = setTimeout("ecardsHider()",10);  //10 ms
	window.status = "";
}

// hide ecard
function ecardsHider() {
	if(!bNs) {
		oDiv = getStyleObject("ecardsTip");
		oDiv.visibility = "hidden";	
		clearTimeout(ecardsTimer);
	}
}

function ecardPreview(cardId, cat, filename, ecardContentType){
    document.getElementById('txtCardId').value = cardId;
	document.getElementById('txtCatId').value = cat;
	document.getElementById('txtEcardContentType').value = ecardContentType;
	
	//empty interactive fields
	document.getElementById('int_var_1').value = "";
	document.getElementById('int_var_2').value = "";
	document.getElementById('int_var_3').value = "";
	document.getElementById('int_var_4').value = "";
	document.getElementById('int_var_5').value = "";
	
	switch (ecardContentType)
    {
    case "1":
	    var fo1 = new FlashObject("/flash/Presenter12fps2.swf", "presenter", "350", "292", "8", "#4d1979");
	    break
    case "4":
	    var fo1 = new FlashObject("/flash/Presenter25fps2.swf", "presenter", "350", "292", "8", "#4d1979");
	    break
    case "5":
	    var fo1 = new FlashObject("/flash/Presenter18fps2.swf", "presenter", "350", "292", "8", "#4d1979");
	    break
    case "6":
	    var fo1 = new FlashObject("/flash/Presenter12fps2.swf", "presenter", "350", "292", "8", "#4d1979");
	    break   
	case "8":
	    var fo1 = new FlashObject("/flash/Presenter18fps2.swf", "presenter", "350", "292", "8", "#4d1979");
	    break  
    default:
	    var fo1 = new FlashObject("/flash/Presenter18fps2.swf", "presenter", "350", "292", "8", "#4d1979");
    }
   
    fo1.addParam("quality", "high");
    fo1.addParam("menu", "false");
    // bgcolor
    fo1.addVariable("bgcolor", "0xE6E6FA");
    // personal text
    fo1.addVariable("myText", "Hier steht der persönliche Text, der bei Schritt 2 eingegeben wird");
    // buttons
    fo1.addVariable("c_text", "");
    fo1.addVariable("c_replay", "");
    fo1.addVariable("c_send", "");
    fo1.addVariable("c_select", "");
    // color of the buttons
    fo1.addVariable("c_color", "0x990000");
    fo1.addVariable("c_over_color", "0x4d1979");
    // show or hide
    fo1.addVariable("showmenu", "true");
    // url for 'verstuur deze e-card'
    fo1.addVariable("sendurl", "");
    // url for 'kies andere e-card'
    fo1.addVariable("selecturl", "");                        
                        		
   fo1.addVariable("card", "/ecards/" + filename);
   fo1.addVariable("pub", "/flash/preloader_blank.swf");
   fo1.addVariable("thema", "/images/themas/001.swf");
   fo1.addVariable("myText", "Hier steht der persönliche Text, der bei Schritt 2 eingegeben wird");
   if(ecardContentType == 5){ 
        fo1.addVariable("int_tS", "form"); //for interactive e-card
   }else{
        fo1.addVariable("int_tS", ""); 
   }
   fo1.write("ecardvoorbeeldStap1");
}

// open popup in center of screen
function openPopup(file,popName,width,height,scrolling) { 
	var w = screen.availWidth;
	var h = screen.availHeight;
	var popW = width, popH = height;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2; 
 	open(file,popName,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos +',toolbar=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=' + scrolling); 
}

function switchSubCat(id){
    var oDiv = getStyleObject("divCaption" + id);
    
    switch(oDiv.visibility){
        case "hidden":
            oDiv.display = "inline";    
            oDiv.visibility = "visible";
            eval("document.captionImg" + id).src = "/images/iconen/minder.gif";
            break;
        case "visible":
            oDiv.display = "none";
            oDiv.visibility = "hidden";
            eval("document.captionImg" + id).src = "/images/iconen/meer.gif";
            break;	                
    }    
}

function showFaq(id){
    var oDiv = getStyleObject("faqDes" + id);
    
    switch(oDiv.visibility){
        case "hidden":
            oDiv.display = "inline";    
            oDiv.visibility = "visible";
            break;
        case "visible":
            oDiv.display = "none";
            oDiv.visibility = "hidden";
            break;	                
    }    
}

function showAllMoments(divname, imgName){
    var oDiv = getStyleObject(divname);
    
    switch(oDiv.visibility){
        case "hidden":
            oDiv.display = "inline";    
            oDiv.visibility = "visible";
             eval("document." + imgName).src = "/images/iconen/minder.gif";
            break;
        
        case "visible":
            oDiv.display = "none";
            oDiv.visibility = "hidden";
             eval("document." + imgName).src = "/images/iconen/meer.gif";
            break;	                
    }    
}
   
function gotoPlace(flashfile,frame) {
    eval("document." + flashfile + ".gotoPlace(frame)");
}


/* oude presenter tools */ 
var movieName = "presenter";

function thisMovie(movieName) {
	// IE and Netscape refer to the movie object differently.
	// This function returns the appropriate syntax depending on the browser.
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return window[movieName]
	} else {
		return document[movieName]
	}
}
function movieIsLoaded (theMovie) {
	// First make sure the movie's defined.
	if (typeof(theMovie) != "undefined") {
		// If it is, check how much of it is loaded.
		return theMovie.PercentLoaded() == 100;
	} else {
		// If the movie isn't defined, it's not loaded.
		return false;
	}
}
function gaNaarTekst() {
	document.presenter.GotoFrame(74);
	document.presenter.Play();
}
function rewind() {
	document.presenter.GotoFrame(0);
	document.presenter.Play();
}
/* oude presenter tools */

 
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var muisX = 0;
var muisY = 0;
function getMouseXY(e) {
if (IE) {
	muisX = event.clientX + document.body.scrollLeft;
	muisY = event.clientY + document.body.scrollTop;
}
else {
	muisX = e.pageX;
	muisY = e.pageY;
}  
if (muisX < 0){muisX = 0;}
if (muisY < 0){muisY = 0;}  
//window.status = muisX + ", " + muisY
return true;
}

