function colexp(objId)
{
	obj = document.getElementById(objId);
	if (obj.style.display == 'none')
		obj.style.display = 'block';
	else
		obj.style.display = 'none';
}

function changeColor(tdno, color)
{
	obj = document.getElementById("tdno" + tdno);
	obj.style.background = color;
	//alert(color);
}

function openWin(url, name, attrib)
{
	window.open(url, name, attrib);
}

function setSubCat(obj)
{
	count = obj.options.length;
	//alert(count);
	for(i=0;i<count;i++)
	{
		document.getElementById("span" + i).style.display = "none";
		document.getElementById("subcategory" + i).name = "blah";
	}
	
	val = obj.value;
	span = document.getElementById("span" + val);
	span.style.display = "block";
	document.getElementById("subcategory" + val).name = "subcategory";
}

function validateSubmitForm()
{
	str = "Following errors occured. Please fix them and then try to submit. \n\n";
	i = 1;
	f = document.submitform;
	
	if(f.name.value == "")
	{
		str += i + ". You did not enter your name\n";
		i++;
	}
	if(!validateEmail(f.email.value))
	{
		str += i + ". You did not enter your valid email address\n";
		i++;
	}
	if(f.url.value == "")
	{
		str += i + ". You did not enter your website\n";
		i++;
	}
	if(f.title.value == "" || f.title.value.length <= 4)
	{
		str += i + ". Tutorial title must be greater than 5 characters\n";
		i++;
	}
	if(f.tnurl.value == "")
	{
		str += i + ". You did not enter url of thumbnail of tutorial\n";
		i++;
	}
	if(f.tuturl.value == "")
	{
		str += i + ". You did not enter url of tutorial\n";
		i++;
	}
	if(f.category.value == "" || f.category.value == "0")
	{
		str += i + ". You did not select a category\n";
		i++;
	}
	if(document.getElementById("span" + f.category.value).style.display == "none" || document.getElementById("subcategory" + f.category.value).value == 0)
	{
		str += i + ". You did not select a sub category\n";
		i++;
	}
	if(!f.agreement.checked)
	{
		str += i + ". You must be agreed to our terms and conditions\n";
		i++;
	}
	
	
	if(str == "Following errors occured. Please fix them and then try to submit. \n\n")
		return true;
	else
	{
		alert(str);
		return false;
	}
}

function validateReportForm()
{
	return true;str = "Following errors occured. Please fix them and then try to submit. \n\n";
	i = 1;
	f = document.reportform;
	
	if(f.name.value == "")
	{
		str += i + ". You did not enter your name\n";
		i++;
	}
	if (f.problem.value == "0")
	{
		if(f.message.value == "" || f.message.value.length <= 24 || f.message.value.length > 250)
		{
			str += i + ". Message length must be from 25 to 250 characters\n";
			i++;
		}
	}
	
	if(str == "Following errors occured. Please fix them and then try to submit. \n\n")
		return true;
	else
	{
		alert(str);
		return false;
	}
}

function validateAffForm()
{
	str = "Following errors occured. Please fix them and then try to submit. \n\n";
	i = 1;
	f = document.affiliateform;
	
	if(f.name.value == "")
	{
		str += i + ". You did not enter your name\n";
		i++;
	}
	if(!validateEmail(f.email.value))
	{
		str += i + ". You did not enter your valid email address\n";
		i++;
	}
	if(f.title.value == "")
	{
		str += i + ". You did not enter title of your website\n";
		i++;
	}
	if(f.url.value == "" || f.url.value == "http://")
	{
		str += i + ". You did not enter your website\n";
		i++;
	}
	if(f.picurl.value == "" || f.picurl.value == "http://")
	{
		str += i + ". You did not enter url of your website button\n";
		i++;
	}
	
	if(str == "Following errors occured. Please fix them and then try to submit. \n\n")
		return true;
	else
	{
		alert(str);
		return false;
	}
}

function validateEmail(email)
{
	if (f.email.value == "")
		return false;
	else if(f.email.value.indexOf('@') < 1)
		return false;
	else if(f.email.value.indexOf('.') < 1)
		return false;
	
	return true;
}