////// 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;
	}
}

function doGenBanner(id){
	xmlhttp.open("GET","/advertise/dogenBanner.php?id="+id);
	//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;
				if(values != ''){
					window.location = "http://"+values;
				}
			}
		}
	}
	xmlhttp.send(null);
}

function doGenBannerSp(id){
	xmlhttp.open("GET","/sponsors/dogenBanner.php?id="+id);
	//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;
				if(values != ''){
					window.location = "http://"+values;
				}
			}
		}
	}
	xmlhttp.send(null);
}
function doGenBannerSmall(id){
	xmlhttp.open("GET","/advertise_home/dogenBanner.php?id="+id);
	//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;
				if(values != ''){
					window.location = "http://"+values;
				}
			}
		}
	}
	xmlhttp.send(null);
}

function doGenBraking(id){
	xmlhttp.open("GET","/braking/dogenBanner.php?id="+id);
	//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;
				if(values != ''){
					window.location = "http://"+values;
				}
			}
		}
	}
	xmlhttp.send(null);
}

function checkNull(num){
	xmlhttp.open("GET","/advertise_home/checkPosition.php?id="+num);
	//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;
				if(values == 1){
					var numm = num-1;
					var root = document.bannerForm;
					alert("Sorry this position is already taken !");
					root.position[numm].checked = false;
				}
			}
		}
	}
	xmlhttp.send(null);
}

var xmlhttp1=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 {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp1 = false;
}
}
@end @*/
if (!xmlhttp1 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp1 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}
if (!xmlhttp1 && window.createRequest) {
	try {
		xmlhttp1 = window.createRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}

function bnRadar(url){
	xmlhttp1.open("GET",url,true);
	xmlhttp1.onreadystatechange=function() {
		if(xmlhttp1.readyState== 4) {
			if(xmlhttp1.status == 200){
				var radarResponse = xmlhttp1.responseText;
				//alert(radarResponse);
				printBn(radarResponse);
			}
		}
	}
	xmlhttp1.send(null);
	//setTimeout("bnRadar('/braking/getBn.php')",600000);
}

function printBn(responce){
	if(responce!='0'&&responce!=''){
		date = new Date();
		date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 30));
		document.cookie = "bBcookie" + "=" + date + ";path=/; expires=" + date.toGMTString();
		document.getElementById('bntag').innerHTML="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center' style='height:130px;'><tr><td width='20%' style='background-color:#005ED3;'></td><td class='whiteText' style='background-color:#005ED3;' valign='middle' align='center'><a href='#' onclick=\"return doGenBraking('"+responce+"');return false;\" target='_blank'><img src='/braking/banners_preview/"+responce+"' alt='' /></a></td><td valign='top' width='20%' align='right' class='whiteTitleSmall black' style='background-color:#005ED3;'><a href='#' onclick=\"document.getElementById('bannerBot').style.visibility='hidden'; return false;\"><img src='/images/close2.jpg' style='margin-top:5px;' border='0'></a>&nbsp;&nbsp;</td></tr></TABLE>";
		document.getElementById('bannerBot').style.visibility='visible';
	}
}

window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement("link");
	css.setAttribute("href","xfade2.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;

	setTimeout(so_xfade,15000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,15000);
	} else {
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}

}



/*window.addEventListener?window.addEventListener("load",so_initD,false):window.attachEvent("onload",so_initD);
var e=document, imgsD = new Array(), zInterval = null, currentD=0, pause=false;

function so_initD() {
if(!e.getElementById || !e.createElement)return;
css = e.createElement("link");
css.setAttribute("href","xfade2.css");
css.setAttribute("rel","stylesheet");
css.setAttribute("type","text/css");
e.getElementsByTagName("head")[0].appendChild(css);

imgsD = e.getElementById("imageContainerOne").getElementsByTagName("img");
for(i=1;i<imgsD.length;i++) imgsD[i].xOpacityD = 0;
imgsD[0].style.display = "block";
imgsD[0].xOpacityD = .99;

setTimeout(so_xfadeD,5000);
}

function so_xfadeD() {
cOpacityD = imgsD[currentD].xOpacityD;
nIndexD = imgsD[currentD+1]?currentD+1:0;

nOpacityD = imgsD[nIndexD].xOpacityD;

cOpacityD-=.05;
nOpacityD+=.05;

imgsD[nIndexD].style.display = "block";
imgsD[currentD].xOpacityD = cOpacityD;
imgsD[nIndexD].xOpacityD = nOpacityD;

setOpacityD(imgsD[currentD]);
setOpacityD(imgsD[nIndexD]);

if(cOpacityD<=0) {
imgsD[currentD].style.display = "none";
currentD = nIndexD;
setTimeout(so_xfadeD,5000);
} else {
setTimeout(so_xfadeD,50);
}

function setOpacityD(objD) {
if(objD.xOpacityD>.99) {
objD.xOpacityD = .99;
return;
}
objD.style.opacity = objD.xOpacityD;
objD.style.MozOpacity = objD.xOpacityD;
objD.style.filter = "alpha(opacity=" + (objD.xOpacityD*100) + ")";
}

}*/


/*function showPopUp(type){
if(type=='0'){
var images="employers.jpg";
var w=422;
var h=550;
}else if(type=='1'){
var images="job_seeker.jpg";
var w=422;
var h=550;
}else if(type=='3'){
var images="perks_card.jpg";
var w=750;
var h=242;
}
window.open('/common/popup.php?img='+images,'new_pop','top=100,left=100,width='+w+',height='+h+',toolbars=0,scrollbars=0,resizable=0');
}*/

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('version').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='arial';
		oSpan.style.paddingRight='10px';
		oSpan.style.paddingLeft='10px';
		oSpan.style.paddingTop='2px';
		oSpan.style.paddingBottom='0px';
		oDT[i].style.cursor='pointer';
		toggle(oDT[i]);
	}
	oDT=null;
}

function validateCompanyRegistration(){

	var root = document.edit;

	var username = root.username;
	var passwd = root.password;
	var conf_passwd = root.confirm_password;
	var name = root.name;
	var email = root.email;
	var phone = root.phone;
	var fax = root.fax;
	var business = root.job_category_types;
	var location = root.location;
	var profile = root.profile;
	var logo = root.logo;

	if (username.value == '' || passwd.value == '' || conf_passwd.value == '' || name.value == '' || email.value == '' || phone.value == '' || fax.value == '' || business.value == '' || location.value == '' || profile.value == ''){
		alert('Please fill all the fields');
		return false;
	}

	if (passwd.value != conf_passwd.value){
		alert('Your password and its confirmation do not match');
		passwd.focus();
		return false;
	}

	var passwordMD5 = hex_md5(passwd.value);
	passwd.value = passwordMD5;
	conf_passwd.value = passwordMD5;
	root.hashed.value = 'yes';
	return true;
}

function validateAddReferences(){

	var root = document.add;

	if (root.name.value == '' || root.email.value == ''){
		alert('Please fill all the obligatery fields');
		return false;
	}

	return true;

}

function validateAddReference(){

	var root = document.add;

	if (root.name.value == '' || root.email.value == ''){
		alert('Please fill all the obligatery fields');
		return false;
	}

	return true;

}

function validatePersonalInformation(){
	//alert('here');
	var root = document.edit;

	if (root.first_name.value == '' || root.last_name.value == '' || root.country.value == '' || root.year.value == '' || root.month.value == '' || root.day.value == '' || root.gender.value == '' || root.ms.value == '' || root.nb_o_d.value == '' || root.references.value == '' || root.username.value == ''){
		alert('Please fill all the fields');
		return false;
	}

	return true;

}

function validateAddSkills(){

	var root = document.add;

	if (root.skill.value == '' || root.skill_level.value == '' || root.years_of_experience.value == '' || root.last_used.value == ''){
		alert('Please fill all the fields');
		return false;

	}
	return true

}

function validateActivateCV1(){

	var root = document.edit;

	if (root.reference.value == ''){
		alert('Please insert your CV reference number.');
		root.reference.focus();
		return false;
	}

	if (root.payment[0].checked == false && root.payment[1].checked == false && root.payment[2].checked == false){
		alert('Please choose a payment method');
		return false;
	}

}

function validateRef(){
	if(document.check1.reference.value==''){
		alert('please insert reference number');
		document.check1.reference.focus();
		return false;
	}
}

function validateRef2(){
	if(document.check2.f_name.value==''){
		alert('please insert your first name');
		document.check2.f_name.focus();
		return false;
	}
	if(document.check2.l_name.value==''){
		alert('please insert your last name');
		document.check2.l_name.focus();
		return false;
	}
	var email=document.check2.email.value;
	if(email==''){
		alert("Please specify an email address.");
		document.check2.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.');
		document.check2.email.focus();
		return false;
	}
}

function validatePhoto(){
	if (document.upload_photo.photo.value == ''){
		alert('Please browse your photo.');
		return false;
	}
}

function validateRequest(){
	var root = document.request;
	var name = root.name;
	if(name.value==''){
		alert('Please enter your name.');
		root.name.focus();
		return false;
	}
	var nationality = root.nationality[root.nationality.selectedIndex].value;
	if(nationality == ''){
		alert('Please select your nationality.')
		root.nationality.focus();
		return false;
	}
	var address = root.address;
	if(address.value==''){
		alert('Please enter your address.');
		root.address.focus();
		return false;
	}
	var email=root.email.value;
	if(email==''){
		alert("Please enter your email address.");
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.match(pattern);
	if(!flag){
		alert('Please enter a valid email address.');
		root.email.focus();
		return false;
	}
	var phone = root.phone;
	if(phone.value==''){
		alert('Please enter your phone number.');
		root.phone.focus();
		return false;
	}
	c = 0;
	var countriesRep = root.elements[8].length;
	for(i=0;i<countriesRep;i++){
		if(root.elements[8][i].selected == true){
			c++;
		}
	}
	if(c == 0){
		alert('Please choose the Cities / Countries you would like to represent.');
		root.elements[8].focus();
		return false;
	}
	var comment = root.comments;
	if(comment.value==''){
		alert('please enter your comments.');
		root.comments.focus();
		return false;
	}

}



function validateContactInformation(){

	var root = document.edit;

	if (root.location.value == ''){

		alert('Please select your location.');
		root.location.focus();
		return false;
	}

	if (root.email.value == ''){

		alert('Please enter 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.focus();
		return false;
	}

	return true;

}

function validateCareerObjectives(){

	var root = document.edit;

	if (root.position_sought.value == ''){
		alert('Please enter the sought position');
		root.position_sought.focus();
		return false;
	}

	if (root.career_level.value == ''){
		alert('Please select your career level');
		root.career_level.focus();
		return false;
	}

	return true;

}

function validateAddEducation(){

	var root = document.add;

	var institution = root.institution.value;
	var country = root.country_id.value;
	var degree = root.degree.value;
	var year = root.year.value;
	var month = root.month.value;

	if (institution == '' || country == '' || degree == '' || year == '' || month == ''){
		alert('Please fill all the required fields');
		return false;
	}

	return true;


}

function validateAddPE(){

	var root = document.add;

	var position = root.position.value;

	var location = root.location.value;
	var startMonth = root.start_month.value;
	var startYear = root.start_year.value;
	var endMonth = root.end_month.value;
	var endYear = root.end_year.value;
	var workDescription = root.work_description.value;

	if (endMonth == 'Present') endYear = 'aadsf';

	if (position == '' || location == '' || startMonth == '' || startYear == '' || endMonth == '' || endYear == '' || workDescription == ''){
		alert('Please fill all the required fields');
		return false;
	}
	return true;

}

function validateAddLanguage(){

	var root = document.add;

	if (root.language.value == '' || root.skill_level.value == '' || root.years_of_experience.value == '' || root.last_used.value == ''){
		alert('Please fill all the fields');
		return false;
	}
	return true;

}


function checkContactform(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if(department.value==""){
		alert('Please select the department you wish to contact.');
		department.focus();
		return false;
	}
	if(subject.value==""){
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		alert('Please enter your message.');
		message.focus();
		return false;
	}
}


function clearContactForm(){
	var root=document.contactForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var department=root.department;
	var subject=root.subject;
	var message=root.message;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		company.value="";
		street.value="";
		city.value="";
		state.value="";
		country.value="";
		phone.value="";
		mobile.value="";
		email.value="";
		department.value="";
		subject.value="";
		message.value="";

		return false;
	}

	return false;
}

function clearAdvForm(){
	var root=document.bannerForm;

	var name=root.name;
	var company=root.company;
	var city=root.city;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var banLink=root.link;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		company.value="";
		city.value="";
		country.value="";
		phone.value="";
		mobile.value="";
		email.value="";
		banLink.value="";
		return false;
	}

	return false;
}

function validateLogIn(){

	var root = document.login;
	var username = root.username;
	var password = root.password;

	if (username.value == ''){
		alert('Please enter your username');
		username.focus();
		return false;
	}
	if (password.value == ''){
		alert('Please enter your password');
		password.focus();
		return false;
	}
	if (root.type[root.type.selectedIndex].value == ''){
		alert('Please select a member type');
		return false;
	}
	var md5Password = hex_md5(password.value);
	password.value = md5Password;
	root.hashed.value = 'yes';
	return true;


}

function boomEmail(){

	var jc = document.edit.job_category_types[document.edit.job_category_types.selectedIndex].value;
	var loc = document.edit.location[document.edit.location.selectedIndex].value;

	radar(jc,loc);
	return false;

}

function checkBannerform(){
	var root=document.bannerForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var banner=root.banPic;
	var link=root.link;
	var vcode=root.vcode;

	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if (root.email.value == ''){

		alert('Please enter 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.focus();
		return false;
	}
	if(banner.value==""){
		alert('Please browse for the banner.');
		banner.focus();
		return false;
	}

	if(link.value != ""){
		var linkFlag = /^(?:http:\/\/)?(?:[\w-]+\.)+[a-z]{2,3}$/i
		flagLink = root.link.value.match(linkFlag);
		if(!flagLink){
			alert('Please insert a valid URL address.');
			root.link.focus();
			return false;
		}
	}

	if(vcode.value==""){
		alert('Please insert the visual code.');
		vcode.focus();
		return false;
	}
}

function checkSponsorForm(){
	var root=document.bannerForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var banner=root.banPic;
	var bannerLogo=root.banLogo;
	var bannerFlash=root.banFlash;
	var link=root.link;
	var vcode=root.vcode;

	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(company.value==""){
		alert('Please enter the company name.');
		company.focus();
		return false;
	}
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if (root.email.value == ''){

		alert('Please enter 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.focus();
		return false;
	}
	if(bannerLogo.value==""){
		alert('Please browse for the company logo.');
		bannerLogo.focus();
		return false;
	}
	if(banner.value==""){
		alert('Please browse for the banner.');
		banner.focus();
		return false;
	}
	if(bannerFlash.value==""){
		alert('Please browse for flash banner.');
		bannerFlash.focus();
		return false;
	}

	if(link.value != ""){
		var linkFlag = /^(?:http:\/\/)?(?:[\w-]+\.)+[a-z]{2,3}$/i
		flagLink = root.link.value.match(linkFlag);
		if(!flagLink){
			alert('Please insert a valid URL address.');
			root.link.focus();
			return false;
		}
	}

	if(vcode.value==""){
		alert('Please insert the visual code.');
		vcode.focus();
		return false;
	}
}
function validatePaySponsor(){
	var root = document.edit;
	if(root.typeP[0].checked == false && root.typeP[1].checked == false && root.typeP[2].checked == false){
		alert('Please choose a payment method');
		return false;
	}
	if(root.typeP[0].checked == true){
		if (root.payment[0].checked == false && root.payment[1].checked == false && root.payment[2].checked == false && root.payment[3].checked == false){
			alert('Please choose your fees type');
			return false;
		}
	}
}

function setPaymentTable(){
	document.getElementById('newsletterPop').style.visibility="visible";
	document.getElementById('tdHolder').style.height="121px";
}
function hidePaymentTable(){
	document.getElementById('newsletterPop').style.visibility="hidden";
	document.getElementById('tdHolder').style.height="20px";
}
function chooseBannerType(type){
	if(confirm('Are you sure you want to proceed ?')){
		window.location.href=type;
	}
	return false;
}
function checkBannerformHome(){
	var root=document.bannerForm;

	var name=root.name;
	var company=root.company;
	var street=root.street;
	var city=root.city;
	var state=root.state;
	var country=root.country;
	var phone=root.phone;
	var mobile=root.mobile;
	var email=root.email;
	var banner=root.banPic;
	var link=root.link;
	var payment=root.position;
	var vcode=root.vcode;

	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(country.value==""){
		alert('Please select a country from the list.');
		country.focus();
		return false;
	}
	if(phone.value==""){
		alert('Please enter your home phone number.');
		phone.focus();
		return false;
	}
	if(isNaN(phone.value)){
		alert('The phone number should only contain digits.');
		phone.select();
		return false;
	}
	if(isNaN(mobile.value) && mobile.value!=""){
		alert('The mobile phone number should only contain digits');
		mobile.select();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	if (root.email.value == ''){

		alert('Please enter 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.focus();
		return false;
	}
	if(banner.value==""){
		alert('Please browse for the banner.');
		banner.focus();
		return false;
	}
	if (payment[0].checked == false && payment[1].checked == false && payment[2].checked == false && payment[3].checked == false && payment[4].checked == false){
		alert('Please choose a position for your banner');
		return false;
	}

	if(link.value != ""){
		var linkFlag = /^(?:http:\/\/)?(?:[\w-]+\.)+[a-z]{2,3}$/i
		flagLink = root.link.value.match(linkFlag);
		if(!flagLink){
			alert('Please insert a valid URL address.');
			root.link.focus();
			return false;
		}
	}

	if(vcode.value==""){
		alert('Please insert the visual code.');
		vcode.focus();
		return false;
	}
}
function previewCatImage(imageURL,imageTitle){
	defaultWidth  = 1000;
	defaultHeight = 500;

	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:10px;}</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="yes" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=FFFFFF scroll="yes" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src='+imageURL+' style="display:block"></body></html>');
			close();
		}
}