/*----var checking----*/
if (typeof labdParamButtonStyles=="undefined")
var labdParamButtonStyles='background-color:#666;color:#FFF;';
if (typeof labdParamPreLoadingPercent=="undefined")
var labdParamPreLoadingPercent='5';
if (typeof labdParamAutoPlayable=="undefined")
var labdParamAutoPlayable=1;
if (typeof labdParamWaitTime=="undefined")
var labdParamWaitTime='5';
if (typeof labdParamClickLink=="undefined")
var labdParamClickLink='javascript:labdClosePresenterOpenForm();';
if (typeof labdParamEndLink=="undefined")
var labdParamEndLink = 'javascript:labdClosePresenterOpenForm();';
if (typeof labdParamPosition=="undefined")
var labdParamPosition=4;
if (typeof labdParamVideoHeight=="undefined")
var labdParamVideoHeight=330;
if (typeof labdParamVideoWidth=="undefined")
var labdParamVideoWidth=300;
if (typeof labdParamVerticalVideoOffset=="undefined")
var labdParamVerticalVideoOffset=0;
if (typeof labdParamHorizontalVideoOffset=="undefined")
var labdParamHorizontalVideoOffset=0;
if (typeof labdParamFormImage=="undefined")
var  labdParamFormImage = 'background-image:url(http://www.netresultsinternational.com/include/big-form-bg2.png);';
if (typeof labdParamUserEmail=="undefined")
var labdParamUserEmail='info@localadsbydesign.com';
if (typeof labdParamUserPhone=="undefined")
var labdParamUserPhone='000-000-0000';
if (typeof labdParamUserWebsite=="undefined")
var labdParamUserWebsite='Website Not Defined';
if (typeof labdParamUserWebpage=="undefined")
var labdParamUserWebpage='Page Not Defined'
if (typeof labdParamBigForm=="undefined")
var labdParamBigForm='yes';
if (typeof labdParamFormTitle=="undefined")
var labdParamFormTitle='Quick Quote';
if (typeof labdVidDuration=="undefined")
var labdVidDuration=1;

//file handling
if (typeof labdParamFileName=="undefined")
var labdParamFileName='dan_featured_v1.flv';
if (typeof labdParamVideoLocation=="undefined")
var labdParamVideoLocation='default';

if (typeof labdParamPlayerLocation=="undefined")
var labdParamPlayerLocation='http://www.netresultsinternational.com/include/presenter.swf';
/*end var checking*/

function labdSetHtml(elementId,newString){
	var newElem = document.createElement('div');
	newElem.setAttribute("id", elementId);
	document.getElementById(elementId).parentNode.replaceChild(newElem, document.getElementById(elementId));
}

/*flash loading*/
function labdLoadVideo(){
	var flashvars = {
		videoToLoad: labdParamFileName,
		playStatus: labdParamAutoPlayable,
		preLoadPercent: labdParamPreLoadingPercent,
		clickLink: labdParamClickLink,
		endLink: labdParamEndLink,
		waitTime: labdParamWaitTime,
		videoWidth: labdParamVideoWidth,
		videoHeight: labdParamVideoHeight,
		horizontalVideoOffset: labdParamHorizontalVideoOffset,
		verticalVideoOffset: labdParamVerticalVideoOffset,
		videoLocation:labdParamVideoLocation
	};
	var params = {
		wmode:'transparent',
		scale:'noscale',
		salign:'lt',
		AllowScriptAccess:'always'
	};
	var attributes = {
	  id: "labdPresenterFlash",
	  name: "labdPresenterFlash"
	};
	swfobject.embedSWF(labdParamPlayerLocation, "labdPresenterFlash", labdParamVideoWidth, labdParamVideoHeight, "9.0.0",false,flashvars, params, false);
}
/*end nolib flash loading*/
function labdCloseForm(){
	document.getElementById('labdBigForm').style.display = 'none';
} 

function labdClosePresenterOpenForm() {
	labdSetHtml('labdPresenterFlash','a');
	document.getElementById('labdPresenterFlash').style.display = "none";
	document.getElementById('labdBigForm').style.display = "block";
	document.getElementById('labdOpenClosePresenter').innerHTML = 'Open Welcome Video';
	
	var labdElement = document.getElementById('labdOpenClosePresenter');
	labdElement.onclick = labdCloseFormOpenPresenter; 
};

function labdCloseFormOpenPresenter(){
	labdCloseForm()
	labdLoadVideo();
	document.getElementById('labdPresenterFlash').style.display = 'block';
	document.getElementById('labdOpenClosePresenter').innerHTML = 'Close Welcome Video';
    labdflashEvent('videoreplay');

	var labdElement = document.getElementById('labdOpenClosePresenter');
	labdElement.onclick = labdClosePresenterOpenForm; 
};

//presenter/form positioning
var labdPresenterPositionString = 'bottom:0px;left:20px;';//default value
var labdFormPositoinString = 'bottom:20px;left:20px;';//default value
switch(labdParamPosition)
{
case 1:
  labdPresenterPositionString = 'top:0px;left:0px;';
  labdFormPositoinString = 'top:20px;left:0px;';
  break;
case 2:
  labdPresenterPositionString = 'top:0px;right:0px;';
  labdFormPositoinString = 'top:20px;right:0px;';
  break;
case 3:
  labdPresenterPositionString = 'bottom:0px;left:0px;';
  labdFormPositoinString = 'bottom:20px;left:0px;';
  break;
case 4:
  labdPresenterPositionString = 'bottom:0px;right:0px;';
  labdFormPositoinString = 'bottom:20px;right:0px;';
  break;
}

/*Com function*/
function labdflashEvent(newEvent){
	//alert(newEvent);
    var completeurl = window.location.protocol + "//" + window.location.host + window.location.pathname;
	switch(newEvent){
	case 'videostart':
		document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=2&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	case 'videoend':
		document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=3&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	case 'videoclose':
        document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=4&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	case 'videoclick':
		document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=5&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	case 'videoreplay':
		document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=7&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	case 'qqclose':
		document.getElementById("screenAliveCom").setAttribute("src","http://www.netresultsinternational.com/Analytics.aspx?anaqtype=8&anaqmine=" + escape(completeurl) + "&anaq=" + escape(labdParamFileName) + "_" + labdVidDuration + '&randkey=' + labdRandomKeySession);
		break;
	}
}


//print div structure
var labdMyScreenAlive=
'	<iframe id="screenAliveCom" width="0px" height="0px" allowtransparency="false" scrolling="No" frameborder="0" src=""></iframe>' +


'<div id="labdPresenterContainer" style="position:fixed;z-index:10;' + labdPresenterPositionString + '">' +
'	<div id="labdPresenterFlash"></div>'+
'	<div id="labdOpenClosePresenter" onClick="labdClosePresenterOpenForm();labdflashEvent(\'videoclose\');" style="cursor:pointer;font-weight:bold;text-align:center;padding:2px 10px;font-size:12px;'+ labdParamButtonStyles +'">Close</div>'+
'</div>';
					
if (labdParamBigForm == 'yes'){
  labdMyScreenAlive = labdMyScreenAlive + 
'<div id="labdBigForm" style="z-index: 10000; width:265px;padding: 10px; height: 255px; position: fixed; display: block;'+ labdFormPositoinString + labdParamFormImage +'">'+
'   <div style="text-align:center;margin: 0 0 5px 0; font-size: 25px; line-height: 25px; font-weight: bold; color: rgb(255, 255, 255);" id="labdCallNow"><img src="http://www.netresultsinternational.com/include/small-phone-icon.png"/>'+labdParamUserPhone+'</div>'+
'   <div style="text-align:center;margin: 0 0 5px 0; font-size: 30px; line-height: 30px; font-weight: bold; color: rgb(255, 255, 255);" id="labdQuickQuoteTitle"><img src="http://www.netresultsinternational.com/include/small-mail-icon.png"/>'+labdParamFormTitle+'</div>'+
'   <iframe id="myScreenAliveFrame" width="265" height="197" allowtransparency="true" scrolling="No" frameborder="0" src="http://www.netresultsinternational.com/UserFiles/c87/5/qq3.aspx?randkey=' + labdRandomKeySession + '&videoname=' + labdParamFileName + '&location='+labdParamUserWebpage+'&url='+labdParamUserWebsite+'&email='+labdParamUserEmail+'"></iframe>'+
'		<!--[if lt IE 8]>'+
'   	<style>#labdCloseBigFormDiv{top:-28px;}</style><![endif]-->'+
'   	<style>#labdCloseBigFormDiv{top:-24px;}</style>'+
'   <div id="labdCloseBigFormDiv" onclick="labdCloseForm();labdflashEvent(\'qqclose\');" style="position:relative;left:85px;width:85px;">'+
'   <img height="21" width="88" src="http://www.netresultsinternational.com/include/button-close-big-form.gif" style="cursor: pointer;" id="CloseBigForm"></div>'+
'</div>';
}

/*--------- begin main function ---------*/
document.onload = labd(); function labd(){
	
    if (typeof labdCallAnalyticsQueryAlreadyCreated=="undefined")
        labdCallAnalyticsQuery();
    
	/*begin create html*/
	var newDiv = document.createElement('div');
	newDiv.innerHTML = labdMyScreenAlive;
	document.body.appendChild(newDiv);
	/*end create html*/
	
	//hide form
	labdCloseForm();
	
labdLoadVideo();
};
/*---------- end main function ----------*/
