

function validityc(){
	frm = contact;
	if(frm.name.value==""){
		alert('Please enter your Name');
		frm.name.focus();
		return false;
	}
	if(frm.email.value==""){
		alert('Please enter your Email');
		frm.email.focus();
		return false;
	}

	if(frm.email.value!=""){
		var str = frm.email.value;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		if (!reg1.test(str) && reg2.test(str)){ 	// if syntax is valid
			//return true;
		}
		else{
			alert ("Please Fill Proper Email Address");
			frm.email.focus();
			return false;
		}
	}

	if(frm.description.value==""){
		alert('Please enter the Message');
		frm.description.focus();
		return false;
	}
	if(frm.valid_code.value==""){
		alert('Please enter the Code');
		frm.valid_code.focus();
		return false;
	}
	if(frm.valid_code.value != "{{spamcode}}"){
		alert('Spam Detection code Should be equal to given code like {{spamcode}}');
		frm.valid_code.focus();
		return false;
	}	
			
	return true;
}


function validity()
{
	frm = document.newsletter;
	if(frm.username.value=="")
	{
		alert('Please enter your Name');
		frm.username.focus();
		return false;
	}
	if(frm.email.value=="")
	{
		alert('Please enter your Email');
		frm.email.focus();
		return false;
	}

	if(frm.email.value!="")
	{
		var str = frm.email.value;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		if (!reg1.test(str) && reg2.test(str)){ 	// if syntax is valid
			//return true;
		}
		else
		{
			alert ("Please Fill Proper Email Address");
			frm.email.focus();
			return false;
		}
	}
	return true;
}

function valid_compsubs()
{
	frm = document.comp_subs;
	if(frm.name.value=="")
	{
		alert('Please enter your Name');
		frm.name.focus();
		return false;
	}
	if(frm.email.value=="")
	{
		alert('Please enter your Email');
		frm.email.focus();
		return false;
	}

	if(frm.email.value!="")
	{
		var str = frm.email.value;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		if (!reg1.test(str) && reg2.test(str)){ 	// if syntax is valid
			//return true;
		}
		else
		{
			alert ("Please Fill Proper Email Address");
			frm.email.focus();
			return false;
		}
	}
	return true;
}


function checkval()
{
	frm=document.search;
	frm=document.search;
	if(frm.category.value=='' && frm.title.value=='')
	{
		alert('Type title or select Category to search...');
		frm.category.focus();
		return false;
	}
	return true;
}

ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='http://www.dinosave.com/plus.gif' class='statusicon' />", "<img src='http://www.dinosave.com/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


function validate2()
{
	frm = document.cPrd;
	if(frm.title.value=='')
	{
		alert('Title should not be empty');
		frm.title.focus();
		return false;
	}
	if(frm.image.value == '')
	{
		alert("Select image to upload");
		frm.image.focus();
		return false;
	}
	if(frm.url.value=='')
	{
			alert('Website should not be empty');
			frm.url.focus();
			return false;
	}
	if(frm.category.value=='')
	{
			alert('Select category');
			frm.category.focus();
			return false;
	}
	return true;
}

var reqObj = null;
function createRequest(){
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
			try {
			reqObj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (err2) {
			try {
			   reqObj = new XMLHttpRequest();
			}
			catch (err3) {
			   reqObj = null;
			}
		}
	}
	return reqObj;
}
var ajx_frm = '';
function add_subs(frm, pcats){
	//alert('Form: '+frm.name+' Pcats: '+pcats);
	xmlhttp = createRequest();
	if(xmlhttp != null){
		ajx_frm = frm;
		xmlhttp.open("GET", "/ajxsubcats.php?action=ajxsubs&key=key123&pcats="+pcats+"&rand="+Math.random(1,10), true);
		xmlhttp.onreadystatechange = add_subs_selectbox;
		xmlhttp.send(null);
	}	
}

function add_subs_selectbox(){
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
		  var text1  = xmlhttp.responseText;
			if(text1 != 0){
				//alert(text1);
				var subsoption_arr = text1.split('#');
				ajx_frm.subcategory.options.length = 1;
				for(i=0; i<subsoption_arr.length; i++){
					var subs_arr = subsoption_arr[i].split(':');
					var no = new Option();
					no.value = subs_arr[0];
					no.text = subs_arr[1];

					ajx_frm.subcategory.options[ajx_frm.subcategory.options.length] = no;
				}
			}
		}
	}
}
