function srch_alt_text() {
	var obj = document.srch;
	if(obj.srch_type.value == 'name') {
		obj.srch_term.value = 'Enter name of player';
	} else if (obj.srch_type.value == 'club') {
		obj.srch_term.value = 'Enter Player Club';
	} else if (obj.srch_type.value == 'company') {
		obj.srch_term.value = 'Enter Company';
	} else if (obj.srch_type.value == 'country') {
		obj.srch_term.value = 'Enter Player Country';
	} else if (obj.srch_type.value == 'hcp') {
		obj.srch_term.value = 'Enter Player Handicap';
	} else if (obj.srch_type.value == 'sex') {
		obj.srch_term.value = 'Enter Male/Female';
	} else if (obj.srch_type.value == 'history') {
		obj.srch_term.value = 'Search historical videos';
	}
}
function validate_admin() {
	var obj = document.admin;
	if(obj.name.value == '') {
		alert('Please enter full name.');
		obj.name.focus();
		return false;
	}
	if(obj.username.value == '') {
		alert('Please enter username.');
		obj.username.focus();
		return false;
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	if(obj.confirm_password.value == '') {
		alert('Please enter confirm password.');
		obj.confirm_password.focus();
		return false;
	}
	if(obj.password.value != obj.confirm_password.value) {
		alert('Passwords wont match.');
		obj.password.value = '';
		obj.confirm_password.value = '';
		obj.password.focus();
		return false;
	}
	return true;
}
function validate_login() {
	var obj = document.login;
	if(obj.username.value == '') {
		alert('Please enter username.');
		obj.username.focus();
		return false;
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	return true;
}
function isValidEmail(str) {
   //return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
   return (str.indexOf("@") > 0);
 
}
function validate_member() {
	var obj = document.member;
	if(obj.first_name.value == '') {
		alert('Please enter first name.');
		obj.first_name.focus();
		return false;
	}
	if(obj.last_name.value == '') {
		alert('Please enter last name.');
		obj.last_name.focus();
		return false;
	}
	/*if(obj.street_address.value == '') {
		alert('Please enter street address.');
		obj.street_address.focus();
		return false;
	}*/
	if(obj.city.value == '') {
		alert('Please enter city.');
		obj.city.focus();
		return false;
	}
	/*if(obj.postal_code.value == '') {
		alert('Please enter postal code.');
		obj.postal_code.focus();
		return false;
	}
	if(obj.state_province.value == '') {
		alert('Please enter state / province.');
		obj.state_province.focus();
		return false;
	}*/
	if(obj.country.value == '') {
		alert('Please enter country.');
		obj.country.focus();
		return false;
	}
	/*if(obj.phone.value == '') {
		alert('Please enter phone.');
		obj.phone.focus();
		return false;
	}	*/
	/*if(obj.mobile.value == '') {
		alert('Please enter mobile.');
		obj.mobile.focus();
		return false;
	}	
	if(obj.member_of_club.value == '') {
		alert('Please enter member of club.');
		obj.member_of_club.focus();
		return false;
	}	*/
	if(obj.handicap.value == '') {
		alert('Please select handicap.');
		obj.handicap.focus();
		return false;
	}
	if(obj.email.value == '') {
		alert('Please enter email.');
		obj.email.focus();
		return false;
	} else {
		if(!isValidEmail(obj.email.value)) {
			alert('Please enter valid email.');
			obj.email.focus();
		return false;
		}
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	if(obj.confirm_password.value == '') {
		alert('Please enter confirm password.');
		obj.confirm_password.focus();
		return false;
	}
	if(obj.password.value != obj.confirm_password.value) {
		alert('Passwords wont match.');
		obj.password.value = '';
		obj.confirm_password.value = '';
		obj.password.focus();
		return false;
	}
	return true;
}
function validate_pro_member() {
	var obj = document.member;
	if(obj.first_name.value == '') {
		alert('Please enter first name.');
		obj.first_name.focus();
		return false;
	}
	if(obj.last_name.value == '') {
		alert('Please enter last name.');
		obj.last_name.focus();
		return false;
	}
	if(obj.street_address.value == '') {
		alert('Please enter street address.');
		obj.street_address.focus();
		return false;
	}
	if(obj.city.value == '') {
		alert('Please enter city.');
		obj.city.focus();
		return false;
	}
	/*if(obj.postal_code.value == '') {
		alert('Please enter postal code.');
		obj.postal_code.focus();
		return false;
	}
	if(obj.state_province.value == '') {
		alert('Please enter state / province.');
		obj.state_province.focus();
		return false;
	}*/
	if(obj.country.value == '') {
		alert('Please enter country.');
		obj.country.focus();
		return false;
	}
	if(obj.phone.value == '') {
		alert('Please enter phone.');
		obj.phone.focus();
		return false;
	}	
	/*if(obj.mobile.value == '') {
		alert('Please enter mobile.');
		obj.mobile.focus();
		return false;
	}	
	if(obj.member_of_club.value == '') {
		alert('Please enter member of club.');
		obj.member_of_club.focus();
		return false;
	}	*/
	if(obj.handicap.value == '') {
		alert('Please select handicap.');
		obj.handicap.focus();
		return false;
	}
	if(obj.player.value == '') {
		alert('Please enter player full name.');
		obj.player.focus();
		return false;
	}
	if(obj.date_of_birth.value == '') {
		alert('Please enter date of birth.');
		obj.date_of_birth.focus();
		return false;
	}
	if(obj.place_of_birth.value == '') {
		alert('Please enter place of birth.');
		obj.place_of_birth.focus();
		return false;
	}
	if(obj.residence.value == '') {
		alert('Please enter residence.');
		obj.residence.focus();
		return false;
	}
	if(obj.turned_pro.value == '') {
		alert('Please enter turned pro.');
		obj.turned_pro.focus();
		return false;
	}
	if(obj.email.value == '') {
		alert('Please enter email.');
		obj.email.focus();
		return false;
	} else {
		if(!isValidEmail(obj.email.value)) {
			alert('Please enter valid email.');
			obj.email.focus();
		return false;
		}
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	if(obj.confirm_password.value == '') {
		alert('Please enter confirm password.');
		obj.confirm_password.focus();
		return false;
	}
	if(obj.password.value != obj.confirm_password.value) {
		alert('Passwords wont match.');
		obj.password.value = '';
		obj.confirm_password.value = '';
		obj.password.focus();
		return false;
	}
	return true;
}
function validate_pro() {
	var obj = document.pro;
	if(obj.first_name.value == '') {
		alert('Please enter first name.');
		obj.first_name.focus();
		return false;
	}
	if(obj.last_name.value == '') {
		alert('Please enter last name.');
		obj.last_name.focus();
		return false;
	}
	if(obj.street_address.value == '') {
		alert('Please enter street address.');
		obj.street_address.focus();
		return false;
	}
	if(obj.city.value == '') {
		alert('Please enter city.');
		obj.city.focus();
		return false;
	}
	if(obj.postal_code.value == '') {
		alert('Please enter postal code.');
		obj.postal_code.focus();
		return false;
	}
	if(obj.state_province.value == '') {
		alert('Please enter state / province.');
		obj.state_province.focus();
		return false;
	}
	if(obj.country.value == '') {
		alert('Please enter country.');
		obj.country.focus();
		return false;
	}
	if(obj.phone.value == '') {
		alert('Please enter phone.');
		obj.phone.focus();
		return false;
	}	
	if(obj.mobile.value == '') {
		alert('Please enter mobile.');
		obj.mobile.focus();
		return false;
	}	
	if(obj.member_of_club.value == '') {
		alert('Please enter member of club.');
		obj.member_of_club.focus();
		return false;
	}	
	if(obj.handicap.value == '') {
		alert('Please select handicap.');
		obj.handicap.focus();
		return false;
	}
	if(obj.email.value == '') {
		alert('Please enter email.');
		obj.email.focus();
		return false;
	} else {
		if(!isValidEmail(obj.email.value)) {
			alert('Please enter valid email.');
			obj.email.focus();
		return false;
		}
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	if(obj.confirm_password.value == '') {
		alert('Please enter confirm password.');
		obj.confirm_password.focus();
		return false;
	}
	if(obj.password.value != obj.confirm_password.value) {
		alert('Passwords wont match.');
		obj.password.value = '';
		obj.confirm_password.value = '';
		obj.password.focus();
		return false;
	}
	return true;
}
function validate_member_login() {
	var obj = document.member_login;
	if(obj.username.value == '' || obj.username.value == 'Enter Email') {
		alert('Please enter email.');
		obj.username.focus();
		return false;
	}
	if(obj.password.value == '') {
		alert('Please enter password.');
		obj.password.focus();
		return false;
	}
	return true;
}
function validate_category() {
	var obj = document.category;
	if(obj.category_title.value == '') {
		alert('Please enter category title.');
		obj.category_title.focus();
		return false;
	}
	return true;
}

function validate_contest() {
	var obj = document.contest;
	if(obj.contest_title.value == '') {
		alert('Please enter contest title.');
		obj.contest_title.focus();
		return false;
	}
	return true;
}
function validate_setting() {
	var obj = document.setting;
	if(obj.setting_title.value == '') {
		alert('Please enter setting title.');
		obj.setting_title.focus();
		return false;
	}
	if(obj.setting_value.value == '') {
		alert('Please enter setting value.');
		obj.setting_value.focus();
		return false;
	}
	return true;
}
function validate_video() {
	var obj = document.video;
	if(obj.member_id.value == '') {
		alert('Please select a member.');
		obj.member_id.focus();
		return false;
	}
	if(obj.video_title.value == '') {
		alert('Please enter video title.');
		obj.video_title.focus();
		return false;
	}
	if(obj.contest_id.value == '') {
		alert('Please select a contest.');
		obj.contest_id.focus();
		return false;
	}
	if(obj.category_id.value == '') {
		alert('Please select a category.');
		obj.category_id.focus();
		return false;
	}
	/*if(obj.hid_mode.value == 'add') {
		if(obj.video.value == '') {
			alert('Please select video to upload.');
			obj.video.focus();
			return false;
		}
	}*/
	if(obj.purchase_video[0].checked) {
		if(obj.purchase_price.value == '') {
			alert('Please enter video purchase price.');
			obj.purchase_price.focus();
			return false;
		}
	}
	return true;
}
function validate_prize() {
	var obj = document.prize;
	if(obj.position.value == '') {
		alert('Please enter position.');
		obj.position.focus();
		return false;
	}
	if(obj.prize_title.value == '') {
		alert('Please enter prize title.');
		obj.prize_title.focus();
		return false;
	}
	return true;
}
function validate_page() {
	var obj = document.page;
	if(obj.page_title.value == '') {
		alert('Please enter page title.');
		obj.page_title.focus();
		return false;
	}
	updateRTEs();
	return true;
}
function validate_sponsor() {
	var obj = document.sponsor;
	if(obj.sponsor_title.value == '') {
		alert('Please enter sponsor title.');
		obj.sponsor_title.focus();
		return false;
	}
	return true;
}
function validate_event() {
	var obj = document.event;
	if(obj.category_id.value == '') {
		alert('Please select category.');
		obj.category_id.focus();
		return false;
	}
	if(obj.event_title.value == '') {
		alert('Please enter title.');
		obj.event_title.focus();
		return false;
	}
	if(obj.event_venue.value == '') {
		alert('Please enter venue.');
		obj.event_venue.focus();
		return false;
	}
	if(obj.cameraman.value == '') {
		alert('Please enter cameraman.');
		obj.cameraman.focus();
		return false;
	}
	if(obj.company.value == '') {
		alert('Please enter company.');
		obj.company.focus();
		return false;
	}
	return true;
}
function validate_event_videos() {
	var obj = document.event_videos;
	if(obj.event_id.value == '') {
		alert('Please select event.');
		obj.event_id.focus();
		return false;
	}
	if(obj.member_id.value == '') {
		alert('Please select member.');
		obj.member_id.focus();
		return false;
	}
	if(obj.video_id.value == '') {
		alert('Please select video.');
		obj.video_id.focus();
		return false;
	}
	return true;
}
function validate_message() {
	var obj = document.message;
	if(obj.message_title.value == '') {
		alert('Please enter title.');
		obj.message_title.focus();
		return false;
	}
	if(obj.message_text.value == '') {
		alert('Please enter message text.');
		obj.message_text.focus();
		return false;
	}
	return true;
}
function validate_respond() {
	var obj = document.respond;
	if(obj.comments.value == '') {
		alert('Please enter comments.');
		obj.comments.focus();
		return false;
	}
	return true;
}
function validate_banner() {
	var obj = document.banner;
	if(obj.banner_title.value == '') {
		alert('Please enter banner title.');
		obj.banner_title.focus();
		return false;
	}
	if(obj.type.value == 'add') {
		if(obj.banner_image.value == '') {
			alert('Please select banner to upload.');
			obj.banner_image.focus();
			return false;
		}
	}
	if(obj.banner_url.value == '') {
		alert('Please enter banner url.');
		obj.banner_url.focus();
		return false;
	}
	return true;
}
function menu(val) {
	width = screen.width;
	if(navigator.userAgent.indexOf("Firefox")!=-1){
		left = (width/2)+250;
		topa = 130;	
	} else if (navigator.userAgent.indexOf("MSIE")!=-1) {
		left = (width/2)+165;
		topa = 135;	
	} else {
		left = (width/2)+153;
		topa = 125;	
	}
	
	//alert(width);
	document.getElementById('mypage').style.left=left;
	document.getElementById('mypage').style.top=topa;
	document.getElementById('mypage').style.visibility=val;
	
}
function qs(val) {
	width = screen.width;
	if(navigator.userAgent.indexOf("Firefox")!=-1){
		left = (width/2)-430;
		topa = 120;	
	} else if (navigator.userAgent.indexOf("MSIE")!=-1) {
		left = (width/2)-340;
		topa = 125;	
	} else {
		left = (width/2)-330;
		topa = 120;	
	}
	
	//alert(width);
	document.getElementById('qs').style.left=left;
	document.getElementById('qs').style.top=topa;
	document.getElementById('qs').style.visibility=val;
	
}
function validate_stat() {
	var obj = document.stat;
	var member_id = 0;
	for(i=0; i<obj.elements.length; i++) {
		if(obj.elements[i].name == 'member_id') {
			member_id = 1;
		}
	}
	if(member_id = 1) {
		if(obj.member_id.value == '') {
			alert('Please select a player.');
			obj.member_id.focus();
			return false;
		}
	}
	if(obj.club_name.value == '') {
		alert('Please enter club name.');
		obj.club_name.focus(); 
		return false;
	}
	if(obj.up_down.value != '' && obj.up_down_attempts.value != '') {
		if(obj.up_down.value > obj.up_down_attempts.value) {
			alert('Up and downs cannot be greater than pitch shots.');
			return false;
		}
	}
	if(obj.sandsaves.value != '' && obj.sandsaves_bunker.value != '') {
		if(obj.sandsaves.value > obj.sandsaves_bunker.value) {
			alert('You are not that good!!! Sandsaves cannot be greater than number of bunkershots. Please try again!');
			return false;
		}
	}
	return true;
}
function validate_round_stat() {
	var obj = document.round_stat;
	if(obj.member_id.value == '') {
		alert('Please select a player.');
		obj.member_id.focus();
		return false;
	}
	if(obj.round_date.value == '') {
		alert('Please enter round date.');
		obj.round_date.focus(); 
		return false;
	}
	if(obj.current_handicap.value == '') {
		alert('Please enter current handicap.');
		obj.current_handicap.focus();
		return false;
	}
	if(obj.gross_score.value == '') {
		alert('Please enter gross score.');
		obj.gross_score.focus();
		return false;
	}
	if(obj.stableford_points.value == '') {
		alert('Please enter stableford points.');
		obj.stableford_points.focus();
		return false;
	}
	return true;
}
function validate_insert_numbers() {
	var obj = document.insert_numbers;
	if(obj.member_id.value == '') {
		alert('Please select a player.');
		obj.member_id.focus();
		return false;
	}
	if(obj.pars.value == '') {
		alert('Please enter pars.');
		obj.pars.focus(); 
		return false;
	}
	if(obj.birdies.value == '') {
		alert('Please enter birdies.');
		obj.birdies.focus();
		return false;
	}
	if(obj.eagles.value == '') {
		alert('Please enter eagles.');
		obj.eagles.focus();
		return false;
	}
	if(obj.albatross.value == '') {
		alert('Please enter albatross.');
		obj.albatross.focus();
		return false;
	}
	if(obj.hole_in_ones.value == '') {
		alert('Please enter hole in ones.');
		obj.hole_in_ones.focus();
		return false;
	}
	if(obj.skipped_holes.value == '') {
		alert('Please enter skipped holes.');
		obj.skipped_holes.focus();
		return false;
	}
	if(obj.triple_bogeys.value == '') {
		alert('Please enter triple bogeys.');
		obj.triple_bogeys.focus();
		return false;
	}
	if(obj.double_bogeys.value == '') {
		alert('Please enter double bogeys.');
		obj.double_bogeys.focus();
		return false;
	}
	if(obj.bogeys.value == '') {
		alert('Please enter bogeys.');
		obj.bogeys.focus();
		return false;
	}
	if(obj.par3_perf.value == '') {
		alert('Please enter par 3 performance.');
		obj.par3_perf.focus();
		return false;
	}
	if(obj.par4_perf.value == '') {
		alert('Please enter par 4 performance.');
		obj.par4_perf.focus();
		return false;
	}
	if(obj.par5_perf.value == '') {
		alert('Please enter par 5 performance.');
		obj.par5_perf.focus();
		return false;
	} 
	return true;
}

function validate_insert_course() {
	var obj = document.insert_course;
	if(obj.member_id.value == '') {
		alert('Please select a player.');
		obj.member_id.focus();
		return false;
	}
	if(obj.fairway_hits.value == '') {
		alert('Please enter fairway hits.');
		obj.fairway_hits.focus(); 
		return false;
	}
	if(obj.greens_regulation.value == '') {
		alert('Please enter greens in regulation.');
		obj.greens_regulation.focus();
		return false;
	}
	if(obj.up_down.value == '') {
		alert('Please enter up and down.');
		obj.up_down.focus();
		return false;
	}
	if(obj.sandsaves.value == '') {
		alert('Please enter sandsaves.');
		obj.sandsaves.focus();
		return false;
	}
	if(obj.putts.value == '') {
		alert('Please enter putts.');
		obj.putts.focus();
		return false;
	}
	if(obj.out_bounds.value == '') {
		alert('Please enter out bounds.');
		obj.out_bounds.focus();
		return false;
	}
	if(obj.water.value == '') {
		alert('Please enter water.');
		obj.water.focus();
		return false;
	}
	if(obj.penalty_strokes.value == '') {
		alert('Please enter penalty strokes.');
		obj.penalty_strokes.focus();
		return false;
	}
	if(obj.skipped_holes.value == '') {
		alert('Please enter skipped holes.');
		obj.skipped_holes.focus();
		return false;
	}
	if(obj.shanks.value == '') {
		alert('Please enter shanks.');
		obj.shanks.focus();
		return false;
	}
	if(obj.lost_balls.value == '') {
		alert('Please enter lost balls.');
		obj.lost_balls.focus();
		return false;
	}
	if(obj.mulligans.value == '') {
		alert('Please enter mulligans.');
		obj.mulligans.focus();
		return false;
	} 
	if(obj.beerballs.value == '') {
		alert('Please enter beerballs.');
		obj.beerballs.focus();
		return false;
	}
	if(obj.driving_average_round.value == '') {
		alert('Please enter driving average for the round.');
		obj.driving_average_round.focus();
		return false;
	}
	if(obj.longest_drive_ever.value == '') {
		alert('Please enter longest drive ever.');
		obj.longest_drive_ever.focus();
		return false;
	}
	return true;
}
function validate_library_video() {
	var obj = document.library_video;
	if(obj.category_id.value == '') {
		alert('Please select category.');
		return false;
	}
	return true;
}
function validate_srch() {
	var obj = document.srch;
	var obj1 = document.srch1	
	if(obj.srch_type.value == 'history') {
		//window.location = '';
		obj1.txt_search.value = obj.srch_term.value;
		obj1.submit();
		return false;
	}
	return true;
}
function validate_pro() {
	var obj = document.pro;
	if(obj.player.value == '') {
		alert('Please enter player full name.');
		obj.player.focus();
		return false;
	}
	if(obj.date_of_birth.value == '') {
		alert('Please enter date of birth.');
		obj.date_of_birth.focus();
		return false;
	}
	if(obj.place_of_birth.value == '') {
		alert('Please enter place of birth.');
		obj.place_of_birth.focus();
		return false;
	}
	if(obj.residence.value == '') {
		alert('Please enter residence.');
		obj.residence.focus();
		return false;
	}
	if(obj.turned_pro.value == '') {
		alert('Please enter turned pro.');
		obj.turned_pro.focus();
		return false;
	}
	return true;
}
function showAd() {
	/*var randomnumber=Math.floor(Math.random()*10);
	if(randomnumber == 0) {
		randomnumber = 1;
	}*/
	val = document.getElementById('hid_ad1').value;
	if(val == '') {
		randomnumber = 1;
		document.getElementById('hid_ad1').value = 1;
	} else {
		randomnumber = parseInt(document.getElementById('hid_ad1').value);
		randomnumber = randomnumber+1
		if(randomnumber == 10) {
			document.getElementById('hid_ad1').value = 0;
		} else {
			document.getElementById('hid_ad1').value = randomnumber;
		}
	}
	//document.getElementById('ad1').innerHTML = randomnumber;
	document.getElementById('ad1').style.background = 'url(/ads/ad2/ad'+randomnumber+'.gif) 0px -15px';

	var randomnumber=Math.floor(Math.random()*68);
	if(randomnumber == 0) {
		randomnumber = 1;
	}
	//document.getElementById('ad2').style.background = 'url(/ads/ad'+randomnumber+'.gif)';	
}
function startAd() {
	showAd();
	setInterval("showAd();",5000);
}
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}
function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}
function autoProcess() {
	var flag = 1;
	var div_ids = "ap_hot_swings,ap_last5_view,ap_last5_votes,ap_last5_mobile,ap_swing_month,as_display_video,ap_load_playlist,ap_load_video_title";
	var div_id = "";
	var di_arr = div_ids.split(',');
	for(i=0;i<di_arr.length && flag == 1;i++) {
		if(isExistingDiv(di_arr[i])) {
			div_id = di_arr[i];
			if(div_id == "ap_hot_swings") {
				//do_getData('mode=hot_swings');
				var hid_hot_swing_started = document.getElementById('hid_hot_swing_started').value;
				if(hid_hot_swing_started == '') {
					var timerId = setTimeout("do_getData('mode=hot_swings');",5000);
					document.getElementById('hid_hot_swing_started').value = timerId;
				}
			} else if (div_id == "ap_last5_view") {
				var hid_last5_view = document.getElementById('hid_last5_view').value;
				if(hid_last5_view == '') {
					var timerId = setTimeout("do_getData('mode=last5_view');",5000);
					document.getElementById('hid_last5_view').value = timerId;
				}
			} else if (div_id == "ap_last5_votes") {
				var hid_last5_votes = document.getElementById('hid_last5_votes').value;
				if(hid_last5_votes == '') {
					var timerId = setTimeout("do_getData('mode=last5_votes');",5000);
					document.getElementById('hid_last5_votes').value = timerId;
				}
			} else if (div_id == "ap_last5_mobile") {
				var hid_last5_mobile = document.getElementById('hid_last5_mobile').value;
				if(hid_last5_mobile == '') {
					var timerId = setTimeout("do_getData('mode=last5_mobile');",5000);
					document.getElementById('hid_last5_mobile').value = timerId;
				}
			} else if (div_id == "ap_swing_month") {
				var hid_swing_month = document.getElementById('hid_swing_month').value;
				if(hid_swing_month == '') {
					var timerId = setTimeout("do_getData('mode=swing_month');",5000);
					document.getElementById('hid_swing_month').value = timerId;
				}
			} else if (div_id == "as_display_video") {
				var hid_video_id = document.getElementById('hid_video_id').value;
				var hid_display_video = document.getElementById('hid_display_video').value;
				if(hid_display_video == '') {
					var timerId = setTimeout("do_getData('mode=vd&id='+hid_video_id);",30000);
					document.getElementById('hid_display_video').value = timerId;
				}
			} else if (div_id == "ap_load_playlist") {
				var hid_load_pl = document.getElementById('hid_load_pl').value;
				if(hid_load_pl == '') {
					var timerId = setTimeout("do_getData('mode=play_list');",1000);
					document.getElementById('hid_load_pl').value = timerId;
				}
			} else if (div_id == "ap_load_video_title") {
				var hid_load_video_title = document.getElementById('hid_load_video_title').value;
				var hid_video_id = document.getElementById('hid_video_id').value;
				if(hid_load_video_title == '') {
					var timerId = setTimeout("do_getData('mode=video_title&id="+hid_video_id+"');",1000);
					document.getElementById('hid_load_video_title').value = timerId;
				}
			}
		}
	}
}
function isExisting(obj){
  return typeof(obj)!='undefined';
}	
function isExistingDiv(id){
	if (document.getElementById(id) != null) {
		return true;
	} else {
		return false;
	}
}
function processReqChange() { 
	if (req.readyState == 4) {
		var vals = req.responseText;
		if(vals != '') {
			do_getData_cb(vals);
		}
	}
}
function do_getData_cb(ajax_content) {
	var content_id = "flash_player";
	var show_content = 1;
	bc_pos = ajax_content.indexOf('<bc value="');
	if(bc_pos != -1) {
		bc_arr = ajax_content.split('"');
		var bc = bc_arr[1];
		var bc = bc.ReplaceAll('|','"');
		document.getElementById('bc').innerHTML = bc;
	}
	show_pos = ajax_content.indexOf('<show value="');
	if(show_pos != -1) {
		//alert(ajax_content);
		show_arr = ajax_content.split('"');
		var show = show_arr[1];
		if(show == 'play_list') {
			content_id = "play_list";
			ajax_content = URLDecode(ajax_content);
		} else if (show == 'nav') {
			content_id = "tabsF";
		}
		vt_pos = ajax_content.indexOf('"video_title"');
		if (vt_pos != -1) {
			content = ajax_content.substr((vt_pos+23),ajax_content.length);
			content = ajax_content.substr((vt_pos+23),(content.length-11));
			document.getElementById('video_title').style.background = '#333333';
			content = URLDecode(content);
			ca = content.split('|');
			html_content = '<TABLE  WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5" STYLE="color:#101010;font-size:12px;">';
			alt = 0;
			for(i=0;i<ca.length;i++) {
				var row = ca[i];
				if(row != '') {
					if(alt == 0) {
						bgcolor1 = '#A5EEFD';
						bgcolor2 = '#EDEDED';
						alt = 1;
					} else {
						bgcolor1 = '#EDEDED';
						bgcolor2 = '#A5EEFD';
						alt = 0;
					}
					ra = row.split(',');
					html_content = html_content + '<TR><TD WIDTH="50%" STYLE="font-weight:bold;background:'+bgcolor1+';"><b>'+ra[0]+'</b></TD><TD bgcolor="'+bgcolor2+'" WIDTH="50%">'+ra[1]+'</TD></TR>';				
				}
			}
			html_content = html_content + '</TABLE>';
			document.getElementById('video_title').innerHTML = html_content;
			//alert(content);
		}
		nav_pos = ajax_content.indexOf('"nav"');
		if (nav_pos != -1) {
			
			content_id = "tabsF";
			//ajax_content = content;
		}
		//alert(show);
	}
	if(show_content == 1) {
		if(content_id == 'flash_player') {
			ajax_content = URLDecode(ajax_content);
		}
		document.getElementById(content_id).innerHTML = ajax_content;
	}
}
function loadXMLDoc( url ) {
  req = false;
  if(window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch(e) {
      req = false;
    }
  } else if(window.ActiveXObject) {
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
	    try {
	      req = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(e) {
	      req = false;
	    }
  	}
  }
  if(req) {
    req.onreadystatechange = processReqChange;
    req.open("GET", url, true);
    req.send("");
  }
}
function do_getData(url_params) {
	dt = new Date;
	var content_id = 'flash_player';
	var loading_text = '<img src="<?=HTTP_HOME?>images1/spacer.gif" height="225"><BR>Loading...';
	pl = url_params.indexOf('mode=play_list');
	if(pl != -1) {
		content_id = "play_list";
	}
	pl = url_params.indexOf('mode=video_title');
	if(pl != -1) {
		content_id = "video_title";
		var loading_text = '<img src="<?=HTTP_HOME?>images1/spacer.gif" height="5"><BR>Loading...';
	}
	pl = url_params.indexOf('mode=nav');
	if(pl != -1) {
		content_id = "tabsF";
		var loading_text = 'Loading...';
	}
	document.getElementById(content_id).innerHTML = loading_text;
	loadXMLDoc("ajax.php?a="+dt.getTime()+'&'+url_params);
}	
function do_getDataNav(url_params,nav) {
	do_getData('mode=nav&opt='+nav);
	var timerId = setTimeout("do_getData('"+url_params+"');",2000);
}
function validate_gift_certificate() {
	var obj = document.gift_certificate;
	if(obj.presented_to.value == '') {
		alert('Please enter presented to.');
		obj.presented_to.focus();
		return false;		
	}
	if(obj.from.value == '') {
		alert('Please enter from.');
		obj.from.focus();
		return false;		
	}
	if(obj.gift_of.value == '') {
		alert('Please enter gift of.');
		obj.gift_of.focus();
		return false;		
	}
	if(obj.certificate_value.value == '') {
		alert('Please enter gift certificate value.');
		obj.certificate_value.focus();
		return false;		
	}
	return true;	
}
