/////////// AJAX for on AIR /////
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function radar(url){
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function() {
		if(xmlhttp.readyState== 4) {
			if(xmlhttp.status == 200){
				radarResponse = xmlhttp.responseText;
				printSelect(radarResponse);
			}
		}
	}
	xmlhttp.send(null);
	setTimeout("radar('/common/onair.php')",60000);
}

function printSelect(responce){
	if(responce=='0'){
		document.getElementById('onair').innerHTML='';
	}else{
		document.getElementById('onair').innerHTML='';
		document.getElementById('onair').innerHTML="<table width=\"280\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" dir=\"ltr\"><tr><td width=\"16\" valign=\"top\" align=\"right\"><img src=\"/images/on_air_right.gif\" alt=\"\" border=\"0\"/></td><td width=\"177\" valign=\"middle\" align=\"right\" class=\"marquee_class\"><marquee SCROLLAMOUNT='5' direction='right' onmouseover='this.stop()' onmouseout='this.start()'>"+responce+"</marquee></td><td width=\"87\" valign=\"top\" align=\"right\"><img src=\"/images/on_air.gif\" alt=\"\" border=\"0\"/></td></tr></table>";
	}
}
//////////////////////////////////////////////

//// header /////
var link1 = new Image();
var link2 = new Image();
var link3 = new Image();
var link4 = new Image();
var link5 = new Image();
var link6 = new Image();
var link7 = new Image();
var link8 = new Image();
var link9 = new Image();
var link10 = new Image();
var link11 = new Image();
var link12 = new Image();
var link13 = new Image();
var link14 = new Image();
var link15 = new Image();
var link16 = new Image();
var link17 = new Image();
var link18 = new Image();
///////////////////

/////////// Footer ////////
var link19 = new Image();
var link20 = new Image();
///////////////////

/// header ///
link2.src = "/images/menu/home.jpg";
link1.src = "/images/menu/home_v.jpg";
link4.src = "/images/menu/about_us.jpg";
link3.src = "/images/menu/about_us_v.jpg";
link6.src = "/images/menu/grid.jpg";
link5.src = "/images/menu/grid_v.jpg";
link8.src = "/images/menu/download.jpg";
link7.src = "/images/menu/download_v.jpg";
link10.src = "/images/menu/login.jpg";
link9.src = "/images/menu/login_v.jpg";
link12.src = "/images/menu/live_streaming.jpg";
link11.src = "/images/menu/live_streaming_v.jpg";
link14.src = "/images/menu/music.jpg";
link13.src = "/images/menu/music_v.jpg";
link16.src = "/images/menu/games.jpg";
link15.src = "/images/menu/games_v.jpg";
link18.src = "/images/menu/news_events.jpg";
link17.src = "/images/menu/news_events_v.jpg";
/////////////////////////////////////////////

/////////// footer /////////////////
link19.src = "/images/ndp_link.gif";
link20.src = "/images/ndp_link_v.gif";
////////////////////////////////////

function validateCareers(){
	root = document.app;

	if(root.FirstName.value==''){
		alert('Please enter your first name.');
		root.FirstName.focus();
		return false;
	}
	if(root.LastName.value==''){
		alert('Please enter your last name.');
		root.LastName.focus();
		return false;
	}

	if(root.Email.value==''){
		alert('Please enter your email address.');
		root.Email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.Email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.Email.select();
		return false;
	}

	if(root.Cv.value==''){
		alert('Please select a cv to upload.');
		root.Cv.focus();
		return false;
	}
	return true;

}

function clearCareers(){
	root = document.app;

	if(confirm('Are you sure you want to clear this form?')){
		app.FirstName.value='';
		app.LastName.value='';
		app.Gender.selectedIndex=0;
		app.year.selectedIndex=0;
		app.month.selectedIndex=0;
		app.day.selectedIndex=0;
		app.Degrees.value='';
		app.Work.value='';
		app.Telephone.value='';
		app.Nationality.value='';
		app.Email.value='';
		app.Education.value='';
		app.Homeaddress.value='';
		app.Additional.value='';
		app.Cv.value='';
	}

	return false;
}

function clearTellaFriend(e){
	var con=confirm('Are you sure you want to clear the form?');
	if(con){
		var root = document.tell_a_friend;
		root.name.value='';
		root.email.value='';
		root.message.value='';
		root.vcode.value='';
		for(var i=0;i<e;i++){
			var f_name= eval('root.f_name'+i+'');
			var f_email= eval('root.f_email'+i+'');
			f_name.value='';
			f_email.value='';
		}
	}else{
		return false;
	}
}

function validateTellAFriend(e){
	var root = document.tell_a_friend;
	var name = root.name.value;
	if (name==''){
		alert('Please fill up your name');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		alert('Please fill up your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	var count=0;
	for(var i=0;i<e;i++){
		var f_name= eval('root.f_name'+i+'.value');
		var f_email= eval('root.f_email'+i+'.value');
		if(f_name==''&&f_email==''){
			count++;
		}
		if(f_name==''&&f_email!=''){
			alert('Please fill up your friends name');
			eval('root.f_name'+i+'.focus()');
			return false;
		}
		if(f_name!=''&&f_email==''){
			alert('Please fill up your friends email');
			eval('root.f_email'+i+'.focus()');
			return false;
		}
		var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(f_name!=''){
			flag=f_email.match(pattern);
			if(!flag){
				alert('Please insert a valid email address.');
				eval('root.f_email'+i+'.select()');
				return false;
			}
		}
	}
	if(count==e){
		alert('Please provide at least one friend email');
		root.f_name0.focus();
		return false;
	}
	var vcode = root.vcode.value;
	if (vcode==''){
		alert('Please provide the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}

function toggle(obj) {
	// Moz. or IE
	var sibling=(obj.nextSibling.nodeType==3)? obj.nextSibling.nextSibling : obj.nextSibling;
	// hide or show
	if(sibling.style.display=='' || sibling.style.display=='block') {
		sibling.style.display='none';
		obj.firstChild.firstChild.data='+';
	}
	else {
		sibling.style.display='block';
		obj.firstChild.firstChild.data='-';
	}
}
//
function initCollapse() {
	var oDT=document.getElementById('content').getElementsByTagName('dt');
	for (var i=0; i < oDT.length; i++) {
		oDT[i].onclick=function() {toggle(this)};
		var oSpan=document.createElement('span');
		var sign=document.createTextNode('+');
		oSpan.appendChild(sign);
		oDT[i].insertBefore(oSpan, oDT[i].firstChild);
		oSpan.style.fontFamily='monospace';
		oSpan.style.paddingRight='0.5em';
		oDT[i].style.cursor='pointer';
		toggle(oDT[i]);
	}
	oDT=null;
}
function validateFaq(){
	var root=document.submit_faq;
	question1 = root.question.value;

	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(question1==''){
		alert('Please provide a question.');
		root.question.focus();
		return false;
	}
	return true;
}

function clearFAQ(){
	var root=document.submit_faq;
	email = root.email;
	ques = root.question;

	if(confirm('Are you sure you want to clear this form?')){
		email.value="";
		ques.value="";
		return false;
	}

	return false;

}
function validateContact(){
	root = document.contact;

	if(root.fname.value==''){
		alert('Please enter your full name.');
		root.fname.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email address.');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.country.value==''){
		alert('Please enter your country.');
		root.country.focus();
		return false;
	}
	if(root.mobile.value==''){
		alert('Please enter your mobile number.');
		root.mobile.focus();
		return false;
	}
	if(root.message.value==''){
		alert('Please enter a message.');
		root.message.focus();
		return false;
	}
	if(root.vcode.value==''){
		alert('Please enter the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}

function clearContactForm(){
	var root=document.contact;
	if(confirm('Are you sure you want to clear all the form?')){
		root.fname.value='';
		root.email.value='';
		root.country.value='';
		root.message.value='';
		root.mobile.value='';
		root.vcode.value='';
		root.fname.focus();
		return false;
	}return false;

}

function validateMemberSignIn(){
	var root = document.signin;
	var username = root.username.value;
	var password = root.password.value;
	if (username == ''){
		alert('Please enter your username.');
		root.username.focus();
		return false;
	}
	if (password == ''){
		alert('Please enter your password.');
		root.password.focus();
		return false;
	}
	password = hex_md5(password);
	root.password.value = password;
	root.hashed.value = 'yes';
	return true;
}

function validateForgotPassword(){
	var root=document.forgot_password;

	var username=root.username;
	var email=root.email;

	if(username.value==''){
		alert('Please enter your username.');
		username.focus();
		return false;
	}
	if(email.value==''){
		alert('Please enter your email address.');
		email.focus();
		return false;
	}

}

function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 500;
	defaultHeight = 500;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src='+imageURL+' style="display:block"></body></html>');
			close();
		}
}

function validChars(e,goods,itemId) {

	var key, keychar;

	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if(key==48){
		var qty=eval('document.add_item.qty_'+itemId+'.value');
		if(qty == ''){
			return false;
		}
	}
	if (key == null) return true;



	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
	return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27){
		return true;
	}

	return false;

}


function validateAddReview(){
	var root=document.add_review;

	var name=root.fullName;
	var email=root.email;
	var title=root.title;
	var message=root.message;

	if(name.value==''){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==''){
		alert('Please enter your email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(title.value==''){
		alert('Please enter the message title.');
		title.focus();
		return false;
	}
	if(message.value==''){
		alert('Please enter your message.');
		message.focus();
		return false;
	}

}

function clearReviewsForm(){
	var root=document.add_review;

	var name=root.fullName;
	var email=root.email;
	var title=root.title;
	var message=root.message;

	if(confirm('Are you sure you wnat to clear this form?')){
		name.value='';
		email.value='';
		title.value='';
		message.value='';
	}
	return false;

}

function checkSearchKeyword(){
	var keyword=document.search.keyword;

	if(keyword.value==''){
		alert('Please enter at least one keyword.');
		keyword.focus();
		return false;
	}
	if(keyword.value.length<3){
		alert('The keyword should be at least 3 characters long.');
		keyword.select();
		return false;
	}
}

function validateEditProfile(){
	var root = document.editProfile;

	if(root.FirstName.value==''){
		alert('Please enter your first name.');
		root.FirstName.focus();
		return false;
	}
	if(root.LastName.value==''){
		alert('Please enter your last name.');
		root.LastName.focus();
		return false;
	}

	if(root.Email.value==''){
		alert('Please specify an email address');
		root.Email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.Email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.Email.select();
		return false;
	}
	return true;
}

function addIcon(symbol,element){
	var toAddTo=window.opener.document.getElementById(element);
	toAddTo.value=toAddTo.value + '' + symbol + ' ';
	toAddTo.focus();
	return false;
}

var got;
var chars;

function change()
{
	var randstring = "";
	var rslength = chars.length - got.length;

	var decrypted = document.getElementById("decoded");
	var encrypted = document.getElementById("encoded");

	for(var x=0;x<rslength;x++)
	{
		i = Math.floor(Math.random() * chars.length);
		randstring += chars.charAt(i);
	}

	if(randstring.charAt(0) == chars.charAt(got.length))
	{
		got += randstring.charAt(0);
		decrypted.innerHTML = got;
	}
	else
	{
		encrypted.innerHTML = randstring;
	}

	if(chars.length > got.length)
	{
		setTimeout("change()", 10);
	}
	else
	{
		encrypted.innerHTML = "";
	}
}
function startdecrypt()
{
	var decrypted = document.getElementById("decoded");
	var encrypted = document.getElementById("encoded");

	chars = decrypted.innerHTML;
	decrypted.innerHTML = "";
	got = "";
	setTimeout("change()", 10);
}

function validateAdvancedSearch(){
	var root=document.advanced_search;
	var key=root.keyword;

	if(key.value==''){
		alert('Please enter a keyword');
		key.focus();
		return false;
	}

	if(key.value.length<3){
		alert('Please enter a keyword with a minimum of 3 characters.');
		key.focus();
		return false;
	}

}

function validateRegistration(){
	root = document.regForm;

	if(root.FirstName.value==''){
		alert('Please specify your first name');
		root.FirstName.focus();
		return false;
	}
	if(root.LastName.value==''){
		alert('Please specify your last name');
		root.LastName.focus();
		return false;
	}
	if(root.Username.value==''){
		alert('Please specify your username');
		root.Username.focus();
		return false;
	}
	if(root.Password.value==''){
		alert('Please specify your password');
		root.Password.focus();
		return false;
	}
	if(root.Confirm.value==''){
		alert('Please Confirm your password');
		root.Confirm.focus();
		return false;
	}

	if(root.Confirm.value!=root.Password.value){
		alert('The password and its confirmation do not match');
		root.Confirm.focus();
		return false;
	}

	if(root.Email.value==''){
		alert('Please specify an email address');
		root.Email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.Email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.Email.select();
		return false;
	}


	return true;
}

function clearRegForm(){
	var root=document.regForm;

	if(confirm('Are you sure you want to clear this form?')){
		root.FirstName.value='';
		root.LastName.value=''	;
		root.Username.value='';
		root.Password.value='';
		root.Confirm.value='';
		root.Email.value='';
		root.Nationality.value='';
		root.Gender.value='';
		root.year.selectedIndex=0;
		root.month.selectedIndex=0;
		root.day.selectedIndex=0;
		root.Fax.value='';
		root.Telephone.value='';
		root.Billingaddress.value='';
		root.Homeaddress.value='';

		return false;
	}
	return false;
}

function validateAddVirtual(){

	var root=document.virtual;
	var FirstName=root.FirstName;
	var LastName=root.LastName;
	var Email=root.Email;

	if(root.FirstName.value==''){
		alert('Please specify your first name');
		root.FirstName.focus();
		return false;
	}
	if(root.LastName.value==''){
		alert('Please specify your last name');
		root.LastName.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.Email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.Email.select();
		return false;
	}

}
function checkFAQSearch(){
	var root=document.faqSearch;
	var keyword=root.k1;

	if(keyword.value==''){
		alert('Please enter a keyword');
		keyword.focus();
		return false;
	}
	if(keyword.value.length<3){
		alert('The keyword should be longer 3 characters long.');
		keyword.focus();
		return false;
	}

}
function clearVirtual(){
	if(confirm('Are you sure you want to clear all the form?')){
		root = document.virtual;

		root.FirstName.value='';
		root.LastName.value='';
		root.Email.value='';
		root.Nationality.value='';
		root.Gender.value='';
		root.year.selectedIndex=0;
		root.month.selectedIndex=0;
		root.day.selectedIndex=0;
		root.Fax.value='';
		root.Telephone.value='';
		root.Billingaddress.value='';
		root.Homeaddress.value='';
		return true;

	}
	return false;
}
function validateShippingAddress(){
	var root = document.shipping;

	var prev=root.previousAddress;

	var address=root.address;
	var city=root.city;
	var country=root.country;
	var newShipping=document.getElementById('shippingNew');
	var shippingPrev=document.getElementById('shippingPrev');

	if(!shippingPrev.checked && !newShipping.checked){
		alert('Please select an old shipping address or add a new one.');
		return false;
	}

	if(shippingPrev.checked){
		if(prev.value==''){
			alert('Please select a previous shipping address.');
			prev.focus();
			return false;
		}
	}

	if(newShipping.checked){
		if(root.address.value==''){
			alert('Please specify the shipping address.');
			address.focus();
			return false;
		}
		if(root.city.value==''){
			alert('Please specify the city.');
			city.focus();
			return false;
		}
		if(root.country.value==''){
			alert('Please specify select a country.');
			country.focus();
			return false;
		}
	}
}

function showHideMemberMenu(){
	var theLayer=document.getElementById('memberMenu');
	if(theLayer.style.visibility=='hidden'){
		theLayer.style.visibility='visible';
	}
	else{
		theLayer.style.visibility='hidden';
	}
}

////////////////////////////////////////////
//////////////// BANNERS CHANGE/////////////
////////////////////////////////////////////

var banArray = new Array; //for banners, increase size as necessary
var counter = 0;
var count = 0;
//calls the changeBanner() function every 10 seconds
//change the timer as necessary (minutes * 60000) or (seconds * 1000)
var timer = window.setInterval("changeBanner()", 10000);

function changeBanner() //banner changer function
{
  	if(counter >= count)
  	{
   		counter = 0;
  	}
  	 if(count != 0)
  	 {
  	 	//alert('100');
		  var bannertd_id = 'bannerTd';
	  	  document.getElementById(bannertd_id).innerHTML='';
	  	  var temp = new Image();
		  //alert('101');
		  temp.src = banArray[counter].src;
		  document.getElementById(bannertd_id).innerHTML= "<img src="+temp.src+" border='0'>"; //sets a new banner
  	 }
	 counter++; //increase the counter for the next banner
}

//////////////////////////////////////////////////


//////////////// BANNERS CHANGE/////////////
function check_newsletter()
{
	var root = document.newsletter;
	var name = root.name;
	var email = root.email;
	var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	if(name.value == '' || name.value == 'name')
	{
		alert('Please insert your name');
		name.focus();
		return false;
	}
	if(email.value == '' || email.value == 'e-mail')
	{
		alert('Please insert your email');
		email.focus();
		return false;
	}
	var flag1 = email.value.match(email_pattern);
	if(!flag1)
	{
		alert("Please enter a valid email address");
		email.select();
		return false;
	}
	return true;
}
//////////////////////////////////////////////////

//////////////// Feedback/////////////
function clearFeedbackForm(){
	var root=document.feedback_form;
	if(confirm('Are you sure you want to clear all the form?')){
		root.name.value='';
		root.email.value='';
		root.project_id.value='0';
		root.feedback.value='';
		root.vcode.value='';
		root.name.focus();
		return false;
	}return false;

}
function validateFeedback()
{
	root = document.feedback_form;

	if(root.name.value==''){
		alert('Please enter your name.');
		root.name.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email address.');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}


	if(root.project_id.value=='0'){
		alert('Please select a project.');
		root.project_id.focus();
		return false;
	}
	if(root.feedback.value==''){
		alert('Please enter your feedback.');
		root.feedback.focus();
		return false;
	}
	if(root.vcode.value==''){
		alert('Please enter the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}
//////////////////////////////////////////////////

//////////for photos///////////////////////////////
var Timer;
function ScrollLeft()
{
	Timer = setInterval("document.getElementById('PANORAMA').scrollLeft -= 2", 15);
}
function ScrollRight()
{
	Timer = setInterval("document.getElementById('PANORAMA').scrollLeft += 2", 15);
}
function previewCatImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 500;
	defaultHeight = 500;
	//alert(imageURL);
	var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
			writeln('<img name="Image" src='+imageURL+' style="display:block"></body></html>');
			close();
		}
}
////// AJAX ///////
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			xmlhttp.overrideMimeType('text/html');
		}
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//////////////////////////////////////
var counter_clicks = 0;
function displayPreview(id){
	counter_clicks++;
	if(counter_clicks == 1)
	{
		window.moveTo(0,0);
		window.resizeTo(screen.width,screen.height);
	}
	xmlhttp.open("GET","/projects/display_preview.php?id="+id,true);

	//Send the proper header information along with the request
	/*xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", str.length);
	xmlhttp.setRequestHeader("Connection", "close");*/
	xmlhttp.onreadystatechange=function() {

		if(xmlhttp.readyState==4) {
			if(xmlhttp.status ==200){
				response = xmlhttp.responseText;
				var values = response;
				var container1 = document.getElementById('preview_container');
				container1.innerHTML=values;
				//InitialiseScrollableArea2();
			}
		}
	}
	xmlhttp.send(null);
}
//////////////////////////////////////////////////

/////// for scrollers ///////////////////////////////

function verifyCompatibleBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new verifyCompatibleBrowser()


var speed=50

var loop, timer

function ConstructObject(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=MoveAreaUp;this.down=MoveAreaDown;
	this.MoveArea=MoveArea; this.x; this.y;
	this.obj = obj + "Object"
	eval(this.obj + "=this")
	return this
}
function MoveArea(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}

function MoveAreaDown(move){
	if(this.y>-this.scrollHeight+objContainer.clipHeight){
		this.MoveArea(0,this.y-move)
		if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
function MoveAreaUp(move){
	if(this.y<0){
		this.MoveArea(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

function PerformScroll(speed){
	if(initialised){
		loop=true;
		if(speed>0) objScroller.down(speed)
		else objScroller.up(speed)
	}
}

function CeaseScroll(){
	loop=false
	if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
	objContainer=new ConstructObject('divContainer')
	objScroller=new ConstructObject('divContent','divContainer')
	objScroller.MoveArea(0,0)
	objContainer.css.visibility='visible'
	initialised=true;
}
function InitialiseScrollableArea2(){
	objContainer=new ConstructObject('divContainer2')
	objScroller=new ConstructObject('divContent2','divContainer2')
	objScroller.MoveArea(0,0)
	objContainer.css.visibility='visible'
	initialised=true;
}
function InitialiseScrollableArea3(){
	objContainer=new ConstructObject('divContainer3')
	objScroller=new ConstructObject('divContent3','divContainer3')
	objScroller.MoveArea(0,0)
	objContainer.css.visibility='visible'
	initialised=true;
}
//////////////////////////////////////////////////////

///////////////////NewsLetter////////
function validatemailinglist(NAME,EMAIL){
	var root= document.newsletter;
	if(root.name.value==NAME){
		root.name.focus();
		alert('Please enter your full name');
		return false;
	}
	if(root.email.value==EMAIL){
		root.email.focus();
		alert('Please enter your email address');
		return false;
	}
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	email = root.email.value;
	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address');
		root.email.select();
		return false;
	}
	return true;
}

function clearnewsletterform(NAME,EMAIL)
{
	var root= document.newsletter;
	root.name.value=NAME;
	root.email.value=EMAIL;
	return false;
}
function setNewsLetter()
{
	var state = document.getElementById('newsletter_div').style.visibility;
	if(state == "hidden"){
		document.getElementById('newsletter_div').style.visibility="visible";
	}else{
		document.getElementById('newsletter_div').style.visibility="hidden";
	}
}
//////////////////////////////////////

///////////// contact the staff //////
function validateSendMessage(){
	var root=document.sendMessage;
	if(root.name.value==''){
		alert('Please provide your full name');
		root.name.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please provide your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.country.value==''){
		alert('Please select a country from the drop down menu');
		root.country.focus();
		return false;
	}

	if(root.message.value==''){
		alert('Please provide a message');
		root.message.focus();
		return false;
	}

	return true;
}
////////////////////////////////////////

////Guestbook//////
function setGuestbookForm()
{
	var state = document.getElementById('div_send_guestbook').style.visibility;
	if(state == "hidden"){
		document.getElementById('div_send_guestbook').style.visibility="visible";
		return false;
	}else{
		document.getElementById('div_send_guestbook').style.visibility="hidden";
		return false;
	}
}

function hideGuestbookForm()
{
	document.getElementById('div_send_guestbook').style.visibility="hidden";
	return false;
}
function validateGuestbook()
{
	root = document.guestbook;

	if(root.fname.value==''){
		alert('Please enter your full name.');
		root.fname.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email address.');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.message.value==''){
		alert('Please enter a message.');
		root.message.focus();
		return false;
	}
	if(root.vcode.value==''){
		alert('Please enter the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}
///////////////////

////lyrics//////
function setLyricsForm()
{
	var state = document.getElementById('div_send_lyrics').style.visibility;
	if(state == "hidden"){
		document.getElementById('div_send_lyrics').style.visibility="visible";
		return false;
	}else{
		document.getElementById('div_send_lyrics').style.visibility="hidden";
		return false;
	}
}

function hideLyricsForm()
{
	document.getElementById('div_send_lyrics').style.visibility="hidden";
	return false;
}
function validateLyrics()
{
	root = document.lyrics;

	if(root.fname.value==''){
		alert('Please enter your full name.');
		root.fname.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please enter your email address.');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.message.value==''){
		alert('Please enter a message.');
		root.message.focus();
		return false;
	}
	if(root.vcode.value==''){
		alert('Please enter the visual code.');
		root.vcode.focus();
		return false;
	}
	return true;
}
///////////////////
function validateVote()
{
	var root = document.vote;
	var name = root.name.value;
	if (name==''){
		alert('Please fill up your name');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email==''){
		alert('Please fill up your email');
		root.email.focus();
		return false;
	}
	var country = root.country.value;
	if (country==''){
		alert('Please choose country');
		root.country.focus();
		return false;
	}
	var gender=root.age.value;
	if (age==''){
		alert('Please fill up your age');
		root.age.focus();
		return false;
	}
	return true;
}
