var objVisibleLayer;
var infowindow;

function RefreshForm(formName) 
{
	var f = document.getElementById(formName);
	f.postback.value = 1;

	f.submit();
}

function swapImage(image, caption)
{
	var ext = '';
	ext = image.substring(image.length-3);
	
	if(ext == 'peg' || ext == 'jpg')
	{
		document.getElementById('mainPropImage').src = 'images/property/main/' + image;		
	}
	else
	{
		document.getElementById('mainPropImage').src = 'images/property/' + image;
	}
	
	document.getElementById('mainPropImage').alt = caption;
}

function addToFavourites()
{
	window.external.AddFavorite(self.location.href, window.title); 
}

function ShowPopUp(url, w, h)
{
	var t=0, l = 0, winstring = "";

	if(infowindow){
		if(!infowindow.closed) infowindow.close()
	}

	l = ((screen.width / 2) - (w / 2))
	t = ((screen.height / 2) - (h / 2))

	winstring = "width=" + w + ", height=" + h + ",left=" + l + ",top=" + t +  ",status=" + 'no' + ",resizable=" + 'yes' + ",scrollbars=" + 'yes';

	infowindow = window.open(url,'extnew' ,winstring);
}

function BigPicLink(picID, w, h, newWin){
	if( newWin )
		ShowPopUpWindow("BigPic","bigpic.cfm?pic_id="+picID,w,h,"no","no","yes");
	else
		document.location.href = 'popup_pic.cfm?pic_id=' + picID;
}

function showContactDetails(divID)
{
	document.getElementById(divID).style.visibility = 'visible';
	document.getElementById(divID).style.display = '';
	
	document.getElementById(divID + 'link').style.visibility = 'hidden';
	document.getElementById(divID + 'link').style.display = 'none';
}

function showLayer(layerID){
	if( objVisibleLayer ){
		if( objVisibleLayer.id == layerID ) return 0;
	}

	objVisibleLayer = document.getElementById(layerID);

	if( objVisibleLayer )
		objVisibleLayer.style.display = '';

}

function hideLayer(){

	if( objVisibleLayer ){
		objVisibleLayer.style.display = 'none';
		objVisibleLayer = null;
	}

}

function swapSideImage(imgName, imgPath){
	var imgRef = document.getElementById(imgName);

	if( imgRef ){

		imgRef.src = imgPath;

	}

}

function ShowPopUpWindow(Name, File, w, h, Status, Resize, Scroll){
	var t=0, l = 0, winstring = "";

	if(infowindow){
		if(!infowindow.closed) infowindow.close()
	}

	l = ((screen.width / 2) - (w / 2))
	t = ((screen.height / 2) - (h / 2))

	winstring = "width=" + w + ", height=" + h + ",left=" + l + ",top=" + t +  ",status=" + Status + ",resizable=" + Resize + ",scrollbars=" + Scroll;

	infowindow = window.open(basehref + File,Name,winstring);
}

function showElement(eName)
{
	var e = document.getElementById(eName);
	e.style.visibility = 'visible';
	e.style.display = '';
}

function hideElement(eName)
{
	var e = document.getElementById(eName);
	e.style.visibility = 'hidden';
	e.style.display = 'none';
}

function getRadioButtonValue(radioButtonArray) {
	var value = '';
	
	if (!radioButtonArray.length) {
		// Only one radio button, so form.radiobuttonname returns a radiobutton element, not an array
		if (radioButtonArray.checked) {
			value = radioButtonArray.value;
		}
	}
	else {
		for (var i=0; i<radioButtonArray.length; i++) {
			if (radioButtonArray[i].checked) {
				value = radioButtonArray[i].value;
				break;
			}
		}
	}
	
	return value;
}

function GetElementPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function SetValue(id, newValue) {
	identity=document.getElementById(id);
	identity.value=newValue;
}

function SetInnerHtml(id, newValue) {
	identity=document.getElementById(id);
	identity.innerHTML=newValue;
}

function SetStyle(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

function isEmail(email) {
	var invalidCharString = " ,<>!\"?%^&*()+=*/\\\';:#~[]{}";
	var i = 0;
	
	for (i = 0; i < invalidCharString.length; i++) {
		if (-1 < email.indexOf(invalidCharString.charAt(i))) {
			return false;
		}
	}
	
	var firstAt = email.indexOf('@');
	var lastAt = email.lastIndexOf('@');
	var lastDot = email.lastIndexOf('.');
	if (!((0 < firstAt) && (1 < lastDot) && (firstAt == lastAt) && ((firstAt + 1) < lastDot) && (lastDot < (email.length - 2)))) 
	{
		return false;
	}
	else {
		return true;
	}
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		
		return false;
	}
return true;
}
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789.-";
	var IsNumber=true;
	var Char;


	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
   
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function SetVisibility(id, visible) {
	var identity=document.getElementById(id);
	if (visible) {
		identity.className = "visibleElement";
	}
	else {
		identity.className = "hiddenElement";
	}
}

function getInputArrayValue(inputArray) {
	var value = '';
	
	if (!inputArray.length) {
		// Only one radio button, so form.radiobuttonname returns a radiobutton element, not an array
		if (inputArray.checked) {
			value = inputArray.value;
		}
	}
	else {
		for (var i=0; i<inputArray.length; i++) {
			if (inputArray[i].checked) {
				value = inputArray[i].value;
				break;
			}
		}
	}
	
	return value;
}

function InsertTextAtCursor(inputElement,textToInsert) {
	inputElement.focus();
	
	if (inputElement.selectionStart) {
		var curPos = inputElement.selectionStart;
		inputElement.value = inputElement.value.substr(0,inputElement.selectionStart) + textToInsert + inputElement.value.substr(inputElement.selectionEnd,inputElement.value.length);
		inputElement.selectionStart = curPos + textToInsert.length;
		inputElement.selectionEnd = inputElement.selectionStart;
	}
	else if (document.selection) {
		var sel = document.selection.createRange();
		sel.text = textToInsert;
	}
	else {
		inputElement.value += textToInsert;
	}
}

function NoneLink() {}

function ReturnKeyCheck(source, e) {
	var characterCode; // literal character code will be stored in this variable
	
	if (e && e.which){ //if which property of event object is supported (NN4)
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	return (characterCode == 13);
}

function NewWindowLink(a) {
	if (!window.focus) 
	{
		return true;
	}
	window.open(a.href,"_blank");
	return false;
}

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.01
  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 && d.getElementById) x=d.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];}
}

function showTab(t)
{
	if(t == 'details')
	{
		document.getElementById('propdetails').style.visibility = 'visible';
		document.getElementById('propdetails').style.display = '';
		document.getElementById('propgallery').style.visibility = 'hidden';
		document.getElementById('propgallery').style.display = 'none';
		document.getElementById('propfloorplans').style.visibility = 'hidden';
		document.getElementById('propfloorplans').style.display = 'none';
		document.getElementById('propmaps').style.visibility = 'hidden';
		document.getElementById('propmaps').style.display = 'none';
		
		document.getElementById('tabLinkdetails').className = 'tabOn';
		if(document.getElementById('tabLinkgallery'))
		{
			document.getElementById('tabLinkgallery').className = 'tabOff';
		}
		if(document.getElementById('tabLinkfloorplans'))
		{
			document.getElementById('tabLinkfloorplans').className = 'tabOff';
		}
		document.getElementById('tabLinkmaps').className = 'tabOff';
	}
	else if(t == 'gallery')
	{
		document.getElementById('propdetails').style.visibility = 'hidden';
		document.getElementById('propdetails').style.display = 'none';
		document.getElementById('propgallery').style.visibility = 'visible';
		document.getElementById('propgallery').style.display = '';
		document.getElementById('propfloorplans').style.visibility = 'hidden';
		document.getElementById('propfloorplans').style.display = 'none';
		document.getElementById('propmaps').style.visibility = 'hidden';
		document.getElementById('propmaps').style.display = 'none';
		
		document.getElementById('tabLinkdetails').className = 'tabOff';
		if(document.getElementById('tabLinkgallery'))
		{
			document.getElementById('tabLinkgallery').className = 'tabOn';
		}
		if(document.getElementById('tabLinkfloorplans'))
		{
			document.getElementById('tabLinkfloorplans').className = 'tabOff';
		}
		document.getElementById('tabLinkmaps').className = 'tabOff';
	}
	else if(t == 'floorplans')
	{
		document.getElementById('propdetails').style.visibility = 'hidden';
		document.getElementById('propdetails').style.display = 'none';
		document.getElementById('propgallery').style.visibility = 'hidden';
		document.getElementById('propgallery').style.display = 'none';
		document.getElementById('propfloorplans').style.visibility = 'visible';
		document.getElementById('propfloorplans').style.display = '';
		document.getElementById('propmaps').style.visibility = 'hidden';
		document.getElementById('propmaps').style.display = 'none';	

		document.getElementById('tabLinkdetails').className = 'tabOff';
		if(document.getElementById('tabLinkgallery'))
		{
			document.getElementById('tabLinkgallery').className = 'tabOff';
		}
		if(document.getElementById('tabLinkfloorplans'))
		{
			document.getElementById('tabLinkfloorplans').className = 'tabOn';
		}
		document.getElementById('tabLinkmaps').className = 'tabOff';
	}
	else if(t == 'maps')
	{
		document.getElementById('propdetails').style.visibility = 'hidden';
		document.getElementById('propdetails').style.display = 'none';
		document.getElementById('propgallery').style.visibility = 'hidden';
		document.getElementById('propgallery').style.display = 'none';
		document.getElementById('propfloorplans').style.visibility = 'hidden';
		document.getElementById('propfloorplans').style.display = 'none';
		document.getElementById('propmaps').style.visibility = 'visible';
		document.getElementById('propmaps').style.display = '';	

		document.getElementById('tabLinkdetails').className = 'tabOff';
		if(document.getElementById('tabLinkgallery'))
		{
			document.getElementById('tabLinkgallery').className = 'tabOff';
		}
		if(document.getElementById('tabLinkfloorplans'))
		{
			document.getElementById('tabLinkfloorplans').className = 'tabOff';
		}
		document.getElementById('tabLinkmaps').className = 'tabOn';
	}
}

function ValidateEnquiry()
{
	var msg="";
	var f = document.getElementById('frmEnquiry');	
	
	if(f.txtName.value == "")
	{
		msg += "\r\n- Name";
	}
	
	if(f.txtEmail.value == "")
	{
		msg += "\r\n- Email";
	}
	else if(!isEmail(f.txtEmail.value))
	{
		msg += "\r\n- Valid email";
	}
	
	if(msg == "")
	{
		document.frmEnquiry.submit();
	}
	else
	{
		alert("Please complete the following:" + msg);
	}
}

function showMap()
{
	document.getElementById('mapSearch').style.visibility = 'visible';
	document.getElementById('mapSearch').style.display = '';
}

function hideMap()
{
	document.getElementById('mapSearch').style.visibility = 'hidden';
	document.getElementById('mapSearch').style.display = 'none';
}

function CountWords (this_field) 
{
	var char_count = this_field.value.length;
	var fullStr = this_field.value + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;
	
	if (fullStr.length <2) {
		word_count = 0;
	}
	
	return word_count;
}

var slider;
var slider2;
var container;
var topPos;
var timerId;
var timeOut;
var maxHeight;
var moveCounter = 0;

function startScrollNews(tOut, mHeight)
{	
	slider = document.getElementById("sliderNews");	
	slider2 = document.getElementById("sliderNews2");	
	
	container = document.getElementById("newsScroller");
	topPos = 0;
	moveCounter = 0;
	timeOut = tOut * 1000;
	maxHeight = mHeight;
	
	window.setTimeout(startNews, timeOut);
}

function startNews()
{
	timerId = window.setInterval(scrollNews, 15);
}

function scrollNews()
{
	topPos -= 1;
	moveCounter++;
	
	slider.style.top = topPos + 'px';
	slider2.style.top = topPos + maxHeight + 'px';
	
	if(moveCounter == 100)
	{
		if(topPos <= (-1 * maxHeight))
		{
			topPos = 0;
			
			var tS = slider;
			var tS2 = slider2;
			
			slider = tS2;
			slider2 = tS;
		}
		
		moveCounter = 0;
		window.clearInterval(timerId);
		window.setTimeout(startNews, timeOut);			
	}
}

function addPageToFavourites()
{
	// IE 
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		if((parseInt(navigator.appVersion) >= 4))
		{
			if(navigator.userAgent.indexOf("MSIE 7") > 0)
			{
				alert("To add this page to your favourites please either press Ctrl+D on your keyboard or click the 'Add to Favorites' button in the Internet Explorer toolbar.");
			}
			else
			{
				window.external.AddFavorite (location.href, document.title); 
			}
		}
	} 
	else 
	{
		window.sidebar.addPanel ( document.title, location.href,""); 
	}
}

function ShowFlashPlayer(f,w,h)
{
	CloseFlashPlayer();
	 
	var s = '<p class="closePlayerLink"><a href="JavaScript:CloseFlashPlayer()" class="closePlayerLink">Close player</a></p><object width="' + w + '" height="' + h + '"><param name="movie" value="' + basehref + 'swf/' + f + '"><embed src="' + basehref + 'swf/' + f + '" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed></object>';

	document.getElementById('flashplayercontainer').innerHTML = s;	
	
	h += 18;
	
	document.getElementById('flashplayercontainer').style.width = w + 'px';
	document.getElementById('flashplayercontainer').style.height = h + 'px';
	
	var ScrollTop = 0;

	if (window.pageYOffset)
	{
		ScrollTop = window.pageYOffset;
	}
	else if(document.getElementById('flashplayercontainer').offsetParent)
	{
		ScrollTop = document.getElementById('flashplayercontainer').offsetParent.scrollTop;
	}
	else if(document.body.parentElement)
	{
		ScrollTop = document.body.parentElement.scrollTop;
	}
	else
	{
		ScrollTop = 0;
	}


	ScrollTop = ScrollTop + 50;

	document.getElementById('flashplayercontainer').style.top = ScrollTop + 'px';

	var bodyWidth = document.body.clientWidth;
	var availWidth = 741;
	
	var availLeft = 0;

	if(availWidth < bodyWidth)
	{
		availLeft = (bodyWidth - availWidth) / 2;
	}

	availLeft += 100;

	document.getElementById('flashplayercontainer').style.left = availLeft + 'px';
	
	document.getElementById('flashplayercontainer').style.display = '';
	document.getElementById('flashplayercontainer').style.visibility = 'visible';
}

function CloseFlashPlayer()
{
	document.getElementById('flashplayercontainer').innerHTML = '';	
	document.getElementById('flashplayercontainer').style.display = 'none';
	document.getElementById('flashplayercontainer').style.visibility = 'hidden';
}

function RefreshForm() {
	var f = document.getElementById('frmEnquiry');
	f.postback.value = 1;

	f.submit();
}

function submitEnquiry() {
	var msg = "";

	var f = document.getElementById('frmEnquiry');
	
	
	if(f.lstProductReq && f.lstProduct.options && f.lstProduct.options[f.lstProduct.selectedIndex].value=="-1") { msg += "\n- Product"; }
	if(f.lstInfoProductReq && f.lstProduct.options && f.lstProduct.options[f.lstProduct.selectedIndex].value=="-1") { msg += "\n- Information pack request for"; }
	
	if(f.optContactTimesReq)
	{
		if(getRadioButtonValue(f.optContactTimes) == "")
		{
			msg += "\n- My preferred date and times or contact me to discuss";
		}
		else if(getRadioButtonValue(f.optContactTimes) == "Times" && f.txtContactTimes.value == "")
		{
			msg += "\n- Preferred date and times";
		}
	}
	
	if(f.txtContactNameReq && f.txtContactName.value=="") { msg += "\n- Name"; }
	if(f.txtPracticeNameReq && f.txtPracticeName.value=="") { msg += "\n- Business name"; }
	if(f.txtAddressReq && f.txtAddress.value=="") { msg += "\n- Postal address"; }
	if(f.txtPostCodeReq && f.txtPostCode.value=="") { msg += "\n- Post code"; }
	if(f.txtTelephonReq && f.txtTelephone.value=="") { msg += "\n- Telephone"; }
	
	if(f.txtEmailReq && f.txtEmail.value=="") 
	{
		msg += "\n- E-mail address"; 
	}
	else if(f.txtEmailReq && !isEmail(f.txtEmail.value))
	{
		msg += "\n- Valid e-mail address"; 
	}
	
	if(f.chkProductReq)
	{
		var chkCount = 0;
		var elems = f.elements;
		for (var ix=0; ix < elems.length; ix++) {
			var elem = elems[ix];

			if(elem.name.substring(0, 10) == 'chkProduct' && elem.checked)
			{
				chkCount++;
			}
		}		
		
		if(chkCount == 0)
		{
			msg += "\n- Select at least one product";
		}
	}
	
	if(f.txtTelephoneReq && f.txtTelephone.value=="") { msg += "\n- Telephone"; }
	
	if(f.optSendPrefReq && getRadioButtonValue(f.optSendPref) == "")
	{
		msg += "\n- How would you prefer to receive the information pack?";
	}
	
	if(f.optSendPrefReqPresentation && getRadioButtonValue(f.optSendPref) == "")
	{
		msg += "\n- How would you prefer to be contacted?";
	}

	if(f.lstSectorReq && f.lstSector.options && f.lstSector.options[f.lstSector.selectedIndex].value=="-1") { msg += "\n- Type of business"; }
	

	if(f.txtTrialUsersReq && f.txtTrialUsers.value=="") 
	{
		msg += "\n- Number of users for trial"; 
	}
	else if(f.txtTrialUsersReq && !IsNumeric(f.txtTrialUsers.value))
	{
		msg += "\n- Number of users for trial must be numeric"; 
	}
		
	if(f.txtPracticeSizeReq && f.txtPracticeSize.value=="") 
	{
		msg += "\n- Practice size"; 
	}
	else if(f.txtPracticeSizeReq && !IsNumeric(f.txtPracticeSize.value))
	{
		msg += "\n- Practice size must be numeric"; 
	}
	
	if(f.lstTrialUsersReq && f.lstTrialUsers.selectedIndex == 0) { msg += "\n- Number of users for trial"; }
	if(f.lstPracticeSizeReq && f.lstPracticeSize.selectedIndex == 0) { msg += "\n- Number of potential users"; }
	
	if (trim(f.captchatext.value) == "") { msg += "\n- The code given in the image at the bottom of the form"; }

	if(msg == "") 
	{
		f.submit();
	}
	else 
	{
		alert("Please complete the following:" + msg);
	}
}

function setTextAreaMaxLengths()
{
	var textareaArray = document.getElementsByTagName('textarea');
	if (textareaArray) {
		if (!textareaArray.length) {
			var i = 0;
			if (textareaArray[i].getAttribute('maxlength'))
			{
				textareaArray[i].onkeyup = textareaArray[i].onchange = checkMaxLength;
				textareaArray[i].onkeyup();
			}
		}
		else
		{
			for (var i=0; i<textareaArray.length; i++)
			{
				if (textareaArray[i].getAttribute('maxlength'))
				{
					textareaArray[i].onkeyup = textareaArray[i].onchange = checkMaxLength;
					textareaArray[i].onkeyup();
				}
			}
		}
	}
}

function checkMaxLength()
{
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
	{
		this.value = this.value.substring(0,maxLength);
	}
}

function OpenVideoViewer(id, w, h, filename, openPopup)
{
	if(openPopup == 1)
	{
		ShowPopUp('VideoViewer.cfm?id=' + id, w + 28, h + 30)
	}
	else
	{
		var vidContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab##version=6,0,29,0" width="' + w + '" height="' + h + '" ID="Captivate1">';	
		vidContent += '<param name="movie" value="library/' + filename + '">';
		vidContent += '<param name="quality" value="high">';
		vidContent += '<param name="menu" value="false">';
		vidContent += '<param name="loop" value="0">';
		vidContent += '<embed src="library/' + filename + '" width="' + w + '" height="' + h + '" loop="0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>';
		vidContent += '</object>';

		var d = document.getElementById('divDlgVideoViewer');
		d.innerHTML = vidContent;

		$('#divDlgVideoViewer').dialog('open');
	}
}
