function MM_showHideLayers() {
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i = 0; i < (args.length - 2); i += 3)
		with (document)
			if (getElementById && ((obj = getElementById(args[i])) != null)) {
				v = args[i + 2];
				if (obj.style) {
					obj = obj.style;
					v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden'
							: v;
				}
				obj.visibility = v;
			}
}
function MM_changeProp(objId, x, theProp, theValue) {
	var obj = null;
	with (document) {
		if (getElementById)
			obj = getElementById(objId);
	}
	if (obj) {
		if (theValue == true || theValue == false)
			eval("obj.style." + theProp + "=" + theValue);
		else
			eval("obj.style." + theProp + "='" + theValue + "'");
	}
}
function MM_preloadImages() {
	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_openBrWindow(theURL, winName, features) {
	window.open(theURL, winName, features);
}
function getList(loadID, Lines) {
	if (loadID == 'current') {
		xajax_top10current();
		$('boxOfficeHeader').className = 'currentbo';
	}
	if (loadID == 'new') {
		xajax_top10new();
		$('boxOfficeHeader').className = 'newbo';
	}
	if (loadID == 'future') {
		xajax_top10future();
		$('boxOfficeHeader').className = 'futurebo';
	}
	myRun1 = new Run(
			{
				elements :'top10table',
				style : {
					height :Lines * 40
				},
				time :0.5,
				flow :Run.SMOOTH,
				onplay : function() {
					$('top10table').innerHTML = '<div id="progress"><img src="images/interface/ajaxload.gif" alt="" width="16" height="16" />Yükleniyor...</div>'
				}
			});
}
function blinkError() {
	myRun2 = new Run( {
		elements :'errorContainer',
		style : {
			backgroundColor :'#F4F4F4'
		},
		time :2
	});
}
function blinkElement($divname) {
	myRun2 = new Run( {
		elements :$divname,
		style : {
			backgroundColor : [ '#FFFFCC', '#FFFFFF' ]
		},
		time :2
	});
}
function flashElement($divname) {
	myRun2 = new Run( {
		elements :$divname,
		style : {
			backgroundColor : [ '#f8f9e1', '#e7eb6d' ]
		},
		time :1,
		onend : function() {
			flashElement2($divname);
		}
	});
}
function flashElement2($divname) {
	myRun2 = new Run( {
		elements :$divname,
		style : {
			backgroundColor : [ '#e7eb6d', '#f8f9e1' ]
		},
		time :1,
		onend : function() {
			flashElement($divname);
		}
	});
}
function toggleOptional(optionalElement, optionSwitch, runTime) {
	if (runTime) {
		if ($(optionSwitch).checked) {
			myRun3 = new Run( {
				elements :optionalElement,
				style : {
					height :400,
					backgroundColor : [ '#FFCC00', '#F4F4F4' ]
				},
				time :1,
				flow :Run.SMOOTH
			});
		} else {
			myRun3 = new Run( {
				elements :optionalElement,
				style : {
					height :0
				},
				time :1,
				flow :Run.SMOOTH
			});
		}
	} else {
		if ($(optionSwitch).checked) {
			$(optionalElement).style.height = "400px";
		} else {
			$(optionalElement).style.height = "0px";
		}
	}
}
function toggleOptionalNewMember(optionalElement, optionSwitch, runTime) {
	if (runTime) {
		if ($(optionSwitch).checked) {
                    
			myRun4 = new Run( {
				elements :optionalElement,
				style : {
					height :260,
					backgroundColor : [ '#FFCC00', '#F4F4F4' ]
				},
				time :1,
				flow :Run.SMOOTH
			});
		} else {
			myRun4 = new Run( {
				elements :optionalElement,
				style : {
					height :0
				},
				time :1,
				flow :Run.SMOOTH
			});
		}
	} else {
		if ($(optionSwitch).checked) {
			$(optionalElement).style.height = "260px";
		} else {
			$(optionalElement).style.height = "0px";
		}
	}
}
formerElement = false;

// //////////////////////////////////////////
// Tümay ÇEBER 18.07.2009
// toggleEvent fonksiyonuna alternatif
var __toggleSlideEventOld;
function toggleSlideEvent(element, runTime) {
	if (!runTime) {
		$(element).style.height = "1px";
	} else {
		var childHeight = $(element + "child").getHeight();
		myRun = new Run( {
			elements :element,
			style : {
				height :childHeight
			},
			time :0.5,
			flow :Run.SMOOTH
		});
		if (element != __toggleSlideEventOld)
			myRun = new Run( {
				elements :__toggleSlideEventOld,
				style : {
					height :1
				},
				time :0.5,
				flow :Run.SMOOTH
			});
	}
	__toggleSlideEventOld = element;
}
// ////////////////////////////////////////

function toggleEvent(optionalElement, childNumber, runTime, totalEvents) {

	if (!runTime) {

		if (totalEvents > 2) {

			$(optionalElement).style.height = "1px";
		}

		else {

			if (childNumber > 1) {
				childHeight = 70 * childNumber;
			} else {
				childHeight = 110;
			}

			$(optionalElement).style.height = (childHeight) + "px";
		}
	}

	if (runTime && optionalElement) {
		if (childNumber > 1) {
			childHeight = 70 * childNumber;
		} else {
			childHeight = 110;
		}
		myRun4 = new Run( {
			elements :optionalElement,
			style : {
				height :childHeight
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}

	if (runTime && formerElement && formerElement != optionalElement) {
		myRun4 = new Run( {
			elements :formerElement,
			style : {
				height :1
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}

	if (runTime) {
		formerElement = optionalElement;
	}
} 

function toggleSectionEvent(optionalElement, childNumber, runTime, totalEvents) {
	if (!runTime) {
		if (totalEvents > 2) {
			$(optionalElement).style.height = "1px";
		} else {
			if (childNumber > 1) {
				childHeight = 60 * childNumber;
			} else {
				childHeight = 90;
			}
			$(optionalElement).style.height = (childHeight) + "px";
		}
	}
	if (runTime && optionalElement) {
		if (childNumber > 1) {
			if (childNumber > 10) {
				childHeight = 45 * childNumber;
			} else {
				childHeight = 60 * childNumber;
			}
		} else {
			childHeight = 90;
		}
		myRun4 = new Run( {
			elements :optionalElement,
			style : {
				height :childHeight
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime && formerElement && formerElement != optionalElement) {
		myRun4 = new Run( {
			elements :formerElement,
			style : {
				height :1
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime) {
		formerElement = optionalElement;
	}
}

function toggleSectionEventSeans(optionalElement, childNumber, runTime,
		totalEvents) {
	if (!runTime) {
		if (totalEvents > 2) {
			$(optionalElement).style.height = "1px";
		} else {
			if (childNumber > 1) {
				childHeight = 50 * childNumber;
			} else {
				childHeight = 110;
			}
			$(optionalElement).style.height = (childHeight) + "px";
		}
	}
	if (runTime && optionalElement) {
		if (childNumber > 1) {
			childHeight = 50 * childNumber;
		} else {
			childHeight = 110;
		}
		myRun4 = new Run( {
			elements :optionalElement,
			style : {
				height :childHeight
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime && formerElement && formerElement != optionalElement) {
		myRun4 = new Run( {
			elements :formerElement,
			style : {
				height :1
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime) {
		formerElement = optionalElement;
	}
}

function togglePersonelTickets(optionalElement, childNumber, runTime,
		totalEvents) {
	if (!runTime) {
		if (totalEvents > 2) {
			$(optionalElement).style.height = "1px";
		} else {
			if (childNumber >= 3) {
				childHeight = 33 * childNumber;
			} else {
				childHeight = 70;
			}
			$(optionalElement).style.height = (childHeight) + "px";
		}
	}
	if (runTime && optionalElement) {
		if (childNumber >= 3) {
			childHeight = 33 * childNumber;
		} else {
			childHeight = 70;
		}
		myRun4 = new Run( {
			elements :optionalElement,
			style : {
				height :childHeight
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime && formerElement && formerElement != optionalElement) {
		myRun4 = new Run( {
			elements :formerElement,
			style : {
				height :1
			},
			time :0.5,
			flow :Run.SMOOTH
		});
	}
	if (runTime) {
		formerElement = optionalElement;
	}
}

function togglePersonalVenue(optionalElement, childNumber, runTime, totalEvents) {
	if (!runTime) {
		if (totalEvents > 1) {
			$(optionalElement).style.height = "1px";
		} else {
			childHeight = 120 * childNumber;
			$(optionalElement).style.height = (childHeight) + "px";
		}
	}
	if (runTime && optionalElement) {
		if (childNumber > 1) {
			childHeight = 120 * childNumber;
		} else {
			childHeight = 120;
		}
		myRun4 = new Run( {
			elements :optionalElement,
			style : {
				height :childHeight
			},
			time :1,
			flow :Run.SMOOTH
		});
	}
	if (runTime && formerElement && formerElement != optionalElement) {
		myRun4 = new Run( {
			elements :formerElement,
			style : {
				height :1
			},
			time :1,
			flow :Run.SMOOTH
		});
	}
	if (runTime) {
		formerElement = optionalElement;
	}
}

function toggleProgressHelp(runTime) {
	if (!runTime) {
		originalProgressHelp = $('saleProgressReminder').offsetHeight;
		$('saleProgressReminder').style.height = "12px";
		statProgressHelp = false;
	}
	if (runTime) {
		if (statProgressHelp) {
			myRun5 = new Run( {
				elements :'saleProgressReminder',
				style : {
					height :12
				},
				time :1,
				flow :Run.SMOOTH
			});
			statProgressHelp = false;
		} else {
			myRun5 = new Run( {
				elements :'saleProgressReminder',
				style : {
					height :originalProgressHelp,
					backgroundColor : [ '#FFFFD5', '#FFFFFF' ]
				},
				time :1,
				flow :Run.SMOOTH
			});
			statProgressHelp = true;
		}
	}
}

function togglePersonalInfoContainer(runTime) {
	if (!runTime) {
		originalPersonalInfoContainer = $('personalInfoContainer').offsetHeight;
		$('personalInfoContainer').style.height = "30px"; //30px
		statPersonalInfoContainer = false;
	}
	if (runTime) {
		if (statPersonalInfoContainer) {
			myRunPersonal = new Run( {
				elements :'personalInfoContainer',
				style : {
					height :30
				},
				time :1,
				flow :Run.SMOOTH
			});
			statPersonalInfoContainer = false;
		} else {
			myRunPersonal = new Run( {
				elements :'personalInfoContainer',
				style : {
					height :originalPersonalInfoContainer,
					backgroundColor : [ '#FFFFD5', '#FFFFFF' ]
				},
				time :1,
				flow :Run.SMOOTH
			});
			statPersonalInfoContainer = true;
		}
	}
}

function initSeatMapScroller(maxX, maxY) {
	selectedSeatsArray = new Array();
	viewW = 580;
	viewH = 400;
	seatW = (maxX + 1) * 20;
	seatH = (maxY + 1) * 20;
	thumW = 110;
	thumH = Math.floor((110 / seatW) * seatH);
	thuwW = Math.floor(viewW * thumW / seatW);
	thuwH = Math.floor(viewH * thumH / seatH);
	if (thuwW > thumW) {
		thuwW = thumW;
	}
	if (thuwH > thumH) {
		thuwH = thumH;
	}
	$('mapLegendThumb').style.height = thumH + "px";
	$('mapLegendThumb').style.width = thumW + "px";
	$('mapLegendThumbPointer').style.height = thuwH + "px";
	$('mapLegendThumbPointer').style.width = thuwW + "px";
	$('mapLegendThumbPointer').style.marginTop = Math.floor((thumH / seatH)
			* ($('seatSelectMapContainer').scrollTop) + 5)
			+ "px";
	$('mapLegendThumbPointer').style.marginLeft = Math.floor((thumW / seatW)
			* ($('seatSelectMapContainer').scrollLeft))
			+ "px";
	$('seatSelectMapContainer').onscroll = updateSeatMapScroller;
}
function safeSubmit(submitButtonName, submitFormName, isBuyButton) {
	if (isBuyButton) {
		$(submitButtonName).className = "nicebigbuttonbuygray";
	}
	$(submitButtonName).disabled = true;
	$(submitButtonName).value = "Lütfen Bekleyiniz...";
	$(submitFormName).submit();
}
function formSubmit(submitFormName) {
	$(submitFormName).submit();
}
function hideFormElement(submitFormElement) {
	$(submitFormElement).style.display = 'none';
}
function updateSeatMapScroller() {
	if (thuwH
			+ Math.floor((thumH / seatH)
					* ($('seatSelectMapContainer').scrollTop)) <= thumH) {
		$('mapLegendThumbPointer').style.marginTop = Math.floor((thumH / seatH)
				* ($('seatSelectMapContainer').scrollTop) + 5)
				+ "px";
	} else {
		$('mapLegendThumbPointer').style.marginTop = (thumH - thuwH + 5) + "px";
	}
	if (thuwW
			+ Math.floor((thumW / seatW)
					* ($('seatSelectMapContainer').scrollLeft)) <= thumW) {
		$('mapLegendThumbPointer').style.marginLeft = Math
				.floor((thumW / seatW)
						* ($('seatSelectMapContainer').scrollLeft))
				+ "px";
	} else {
		$('mapLegendThumbPointer').style.marginLeft = (thumW - thuwW) + "px";
	}
}

function selectSeat(seatId, serverId, showtimeId, IVR_LOCK_GUID_ID) {
	var id = $('id').value;
	var remCheck = false;
	for (i = 0; i < selectedSeatsArray.length; i++) {
		if (selectedSeatsArray[i] == seatId) {
			selectedSeatsArray.splice(i, 1);
			remCheck = true;
			$('s' + seatId).className = 'as';
			var preHTML = $('s' + seatId).innerHTML;
			$('s' + seatId).innerHTML = '<img src="images/icons/sp.gif" alt="progress" width="10" heigth="10">';
			$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
			$('selectedSeatSubmit').disabled = true;
			$('selectedSeatSubmit').value = "Bekleyiniz...";
			xajax_deSelectUserSeat(id, seatId, serverId, showtimeId, preHTML,
					IVR_LOCK_GUID_ID);
		}
	}
	if (selectedSeatsArray.length < 9) {
		if (!remCheck) {
			selectedSeatsArray[selectedSeatsArray.length] = seatId;
			$('s' + seatId).className = 'as';
			var preHTML = $('s' + seatId).innerHTML;
			$('s' + seatId).innerHTML = '<img src="images/icons/sp.gif" alt="progress" width="10" heigth="10">';
			$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
			$('selectedSeatSubmit').disabled = true;
			$('selectedSeatSubmit').value = "Bekleyiniz...";
			xajax_selectUserSeat(id, seatId, serverId, showtimeId, preHTML,
					IVR_LOCK_GUID_ID);
		}
		if (selectedSeatsArray.length) {
			$('selectedSeatCount').innerHTML = '<strong>' + selectedSeatsArray.length + '</strong> adet koltuk seçtiniz.';
			$('selectedSeatField').value = selectedSeatsArray.join(';');
		} else {
			$('selectedSeatCount').innerHTML = '&nbsp;';
		}
	} else {
		proAlert("Bu salondan en fazla 9 adet koltuk satın alabilirsiniz.");
	}
}

function selectSeatBus(seatId, serverId, showtimeId, IVR_LOCK_GUID_ID) {
	var remCheck = false;
	for (i = 0; i < selectedSeatsArray.length; i++) {
		if (selectedSeatsArray[i] == seatId) {
			selectedSeatsArray.splice(i, 1);
			remCheck = true;
			$('s' + seatId).className = 'asBus';
			var preHTML = $('s' + seatId).innerHTML;
			$('s' + seatId).innerHTML = '<img src="images/icons/sp.gif" width="10" heigth="10" style="vertical-align:bottom;">';
			$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
			$('selectedSeatSubmit').disabled = true;
			$('selectedSeatSubmit').value = "Bekleyiniz...";
			xajax_deSelectUserSeatBus(seatId, serverId, showtimeId, preHTML,
					IVR_LOCK_GUID_ID);
		}
	}
	if (selectedSeatsArray.length < 2) {
		if (!remCheck) {
			selectedSeatsArray[selectedSeatsArray.length] = seatId;
			$('s' + seatId).className = 'asBus';
			var preHTML = $('s' + seatId).innerHTML;
			$('s' + seatId).innerHTML = '<img src="images/icons/sp.gif" width="10" heigth="10" style="vertical-align:bottom;">';
			$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
			$('selectedSeatSubmit').disabled = true;
			$('selectedSeatSubmit').value = "Bekleyiniz...";
			xajax_selectUserSeatBus(seatId, serverId, showtimeId, preHTML,
					IVR_LOCK_GUID_ID);
		}
		if (selectedSeatsArray.length) {
			$('selectedSeatCount').innerHTML = '<strong>' + selectedSeatsArray.length + '</strong> adet koltuk seçtiniz.';
			$('selectedSeatField').value = selectedSeatsArray.join(';');
		} else {
			$('selectedSeatCount').innerHTML = '&nbsp;';
		}
	} else {
		proAlert("Bu sefer için aynı anda en fazla 2 adet koltuk satın alabilirsiniz.\nDaha fazla koltuk almak istiyorsanız, bu işlemi tamamladıktan sonra yeni işlem yapabilirsiniz.");
	}
}

function buySeat() {
	if (selectedSeatsArray.length > 0) {
		$('selectedSeatForm').submit();
		$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
		$('selectedSeatSubmit').disabled = true;
		$('selectedSeatSubmit').value = "Lütfen Bekleyiniz...";
	} else {
		proAlert("Devam etmeden önce koltuk seçmeniz gereklidir.");
	}
}

function buySeatNoNumber() {
	if (document.getElementById('selectedSeatField').value.length > 0) {
		$('selectedSeatForm').submit();
		$('selectedSeatSubmit').className = "nicebigbuttonbuygray";
		$('selectedSeatSubmit').disabled = true;
		$('selectedSeatSubmit').value = "Lütfen Bekleyiniz...";
	} else {
		proAlert("Devam etmeden önce koltuk seçmeniz gereklidir.");
	}
}

function reCalculateTotal() {
	totalPrice = parseInt($('totalService').value)
			+ parseInt($('totalTickerPrice').value)
			+ parseInt($('totalPromotionPrice').value);
	$('generalTotal').innerHTML = '<strong>' + (totalPrice / 100).toFixed(2) + ' TL</strong>';
}

function reCalculateSeatPrice(boxList, servicePrice) {
	var seatArray = boxList.split('-');
	var totalPrice = servicePrice;
	for (i = 0; i < seatArray.length; i++) {
		totalPrice = totalPrice
				+ parseInt($('s' + seatArray[i]).options[$('s' + seatArray[i]).selectedIndex].value
						.split('-')[1]);
	}
	$('buyTicketCalcSum').innerHTML = '<strong>' + (totalPrice / 100)
			.toFixed(2) + ' TL</strong>';
}

function reCalculateSeatPriceConfirm(boxList, servicePrice) {
	var seatArray = boxList.split('-');
	var totalPrice = 0;
	for (i = 0; i < seatArray.length; i++) {
		totalPrice = totalPrice
				+ parseInt($('s' + seatArray[i]).options[$('s' + seatArray[i]).selectedIndex].value
						.split('-')[1]);
	}
	$('totalTickerPrice').value = totalPrice;
	$('totalService').value = servicePrice;
	reCalculateTotal();
	$('buyTicketCalcSum').innerHTML = '<strong>' + (totalPrice / 100)
			.toFixed(2) + ' TL</strong>';
}

function reCalculateSeatPricePromo(boxList) {
	var promoArray = boxList.split('-');
	var totalPrice = 0;
	for (i = 0; i < promoArray.length; i++) {
		totalPrice = totalPrice
				+ (parseInt($('promoCount' + promoArray[i]).value) * parseInt($('promoPrice' + promoArray[i]).value));
		$('totalPromosyonShow' + promoArray[i]).innerHTML = '<strong>' + ((parseInt($('promoCount' + promoArray[i]).value) * parseInt($('promoPrice' + promoArray[i]).value)) / 100)
				.toFixed(2) + ' TL</strong>';
	}
	$('totalPromotionPrice').value = totalPrice;
	reCalculateTotal();
	$('promosyonTotal').innerHTML = '<strong>' + (totalPrice / 100).toFixed(2) + ' TL</strong>';
}

function reCalculateSeatPriceBus(boxList, servicePrice) {
	var seatArray = boxList.split('-');
	var totalPrice = servicePrice * seatArray.length;
	for (i = 0; i < seatArray.length; i++) {
		totalPrice = totalPrice
				+ parseInt($('s' + seatArray[i]).options[$('s' + seatArray[i]).selectedIndex].value
						.split('-')[1]);
	}
	$('buyTicketCalcSum').innerHTML = '<strong>' + (totalPrice / 100)
			.toFixed(2) + ' TL</strong>';
}

function confirmUserAction(userMessage, confirmUrl) {
	if (confirm(userMessage)) {
		window.location.href = confirmUrl;
	}
}
function openURL(Url) {
	window.location.href = Url;
}
var ccInits = new Array();

function ccNext(inputId, e) {
	var tusKodu = (document.all) ? event.keyCode : e.keyCode
	if (document.getElementById('ccn' + inputId).value.length == 4
			&& (tusKodu != 9) && (tusKodu != 16 && tusKodu != 9)) {
		if (inputId < 4) {
			document.getElementById("ccn" + (inputId + 1)).focus();
			document.getElementById("ccn" + (inputId + 1)).select();
		} else {
			document.getElementById("ccexpm").focus();
		}
	} else if (document.getElementById('ccn' + inputId).value.length == 0) {
		if (inputId > 1 && ccInits[inputId]) {
			document.getElementById("ccn" + (inputId - 1)).focus();
			document.getElementById("ccn" + (inputId - 1)).select();
			ccInits[inputId] = false;
		}
	}
	if (document.getElementById("ccn" + inputId).value.length > 0)
		ccInits[inputId] = true;

}

function numbersonly(myfield, e) {
	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13)
			|| (key == 27))
		return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	else
		return false;
}

