/**************************************/
/* Auto Scroll Feed */

var t;
function stopscroll() { 
	clearTimeout(t);
}
function autoscroll() {
	var scrollingbox=document.getElementById('autoscrollingbox');
	var scrollposition=scrollingbox.scrollTop + 1;
	scrollingbox.scrollTop=scrollposition;
	t=setTimeout(autoscroll,20);
}


/**************************************/
/* Calendar Popup Window */
function popitup(url) {
	newwindow=window.open(url,'name','height=400,width=600,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

/**************************************/
/* Swap the active CSS */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/**************************************/
/* Contact Validation */
function validateContact(oForm) {
	var bValid = true;

	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address for your feedback.');
		return false;
	}
	if (oForm.tel.value == '') {
		alert('Please enter your preferred contact number.');
		return false;
	}
	if (oForm.otherInfo.value == '') {
		alert('Please enter your message.');
		return false;
	}

return true;
}

/**************************************/
/* Contact Validation */
function validateContactTurkish(oForm) {
	var bValid = true;

	if (validateEmail(oForm.email) == false) {
		alert('Görüsleriniz için geçerli bir e-posta adresi girin.');
		return false;
	}
	if (oForm.tel.value == '') {
		alert('Tercih ettiginiz irtibat numarasi giriniz.');
		return false;
	}
	if (oForm.otherInfo.value == '') {
		alert('Mesajinizi girin.');
		return false;
	}

return true;
}

/**************************************/
/* Application Validation */
function validateApplication(oForm) {
	var bValid = true;

	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address for your application.');
		return false;
	}
	if (oForm.name.value == '') {
		alert('Please enter your name.');
		return false;
	}

return true;
}

/**************************************/
/* Caneldar Validation */
function validateCalendar(oForm) {
	var bValid = true;

	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address to veiw the information.');
		return false;
	}
	if (oForm.name.value == '') {
		alert('Please enter your name.');
		return false;
	}

return true;
}

/**************************************/
/* validate the email field */
function validateEmail(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) { return false; }
		else { return true; }
	}
}

function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
