
var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;

/****************************/
function trim(s){
   while (s.substring(0,1) == ' '){
       s = s.substring(1,s.length);
   }
   while (s.substring(s.length-1,s.length) == ' '){
       s = s.substring(0,s.length-1);
   }
   return s;
}

/***************************/

function vote (user, id, htmlid, md5, value){

	if (xmlhttp) {
		url = "http://www.gamindex.com/vote.php";
		var mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value + "&htmlid=" + htmlid;
		
		anonymous_vote = false;
		
        if (anonymous_vote == false && user == '0') {
<!--            window.location="/login.php?return="+location.href;-->

		document.getElementById('change-' +htmlid).className = 'section1 fadethis';
		document.getElementById('login-needed-' +htmlid).className = 'not-signed-in';			
						
        } else {
        	mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
        	
    		if (mnmxmlhttp) { 
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type','application/x-www-form-urlencoded');
    			
    					   
    			mnmxmlhttp[htmlid].send (mycontent); 
    			errormatch = new RegExp ("^ERROR:");    
    			
    			target1 = document.getElementById ('xvotes-' + htmlid);    
    			
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    		    			
    			
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					//alert(xvotesString[htmlid]);
    					errorText = xvotesString[htmlid].split('|')
 					
    					if(errorText[1] == "error")
    					{
    						alert('You have reached the maximum voting times');
    						return false;
    					}
    					if(errorText[1] == "error1")
    					{
    						alert('You cannot vote or junk your own resource');
    						return false;
    					}

    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);    					} else {
														if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues (htmlid, value, false); }     					}
    				}
    			}
    		}
    	}
	}
}


function unvote (user, id, htmlid, md5, value)
{

  	if (xmlhttp) {
		url = "http://www.gamindex.com/vote.php";
		var mycontent = "unvote=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            window.location="http://www.gamindex.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
				target1 = document.getElementById ('xvotes-' + htmlid);
  				target2 = document.getElementById ('xvote-' + htmlid);    
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						 xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);target2.innerHTML = "<span>Vote</span>";						} else {
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {target2.innerHTML = "<span>Vote</span>";changemnmvalues (htmlid, value, false); }							
    					}
    				}
    			}
    		}
    	}
	}
}

function cvote (user, id, htmlid, md5, value)
{
	if (xmlhttp) {
		url = "http://www.gamindex.com/cvote.php";
		mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;

        if (anonymous_vote == false && user == '0') {
            window.location="http://www.gamindex.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
    			mnmxmlhttp[htmlid].send (mycontent);
    			//errormatch = new RegExp ("ERROR:");
    			//alert(errormatch);
    			target1 = document.getElementById ('cvote-' + htmlid);        
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			target1.style.backgroundColor = '#FFFFFF';
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					
    					if (xvotesString[htmlid].match ("ERROR:")) {
    					
    						xvotesString[htmlid] = xvotesString[htmlid].substring (7, xvotesString[htmlid].length);						
    						changecvotevalues (htmlid, true);							
    					} else {
							//target1 = document.getElementById ('ratebuttons-' + id);
							//target1.style.display = "none";
							//target2 = document.getElementById ('ratetext-' + id);
							//target2.innerHTML = "Thank you for rating this comment.";
							changecvotevalues (htmlid, true);
    					}
    				}
    			}
    		}
    	}
	}
}

function changemnmvalues (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	//alert(document.getElementById("xreport-"+id));
		
	if (error) {
		if (value > 0) { target2.innerHTML = "<span>Voted</span> "; }
		else if (value < 0) { target2.innerHTML = "<span>Buried</span> "; }
		return false;
	}
	if (b.length <= 7) {
		if(value == '1')
		{
			document.getElementById('change-' +id).className = 'section1';
			//target1.innerHTML = b[0] +'<span>votes</span>';
			target1.innerHTML = (trim(b[0]))+'<span>votes</span>';
			document.getElementById('changetrust-' +id).innerHTML = b[2] +'<em>/10</em>';
		}
		else if(value == '0')
		{
			document.getElementById('change-' +id).className = 'section1';
			//target1.innerHTML = b[0] +'<span>votes</span>';
			target1.innerHTML =(trim(b[0]))+'<span>votes</span>';
			document.getElementById('changetrust-' +id).innerHTML = b[2] +'<em>/10</em>';
		}
		else if(value < '0')
		{
			
			document.getElementById('change-' +id).className = 'section1 junked';
			//target1.innerHTML = b[0] +'<span>votes</span>';
			target1.innerHTML = (trim(b[0]))+'<span>votes</span>';
			document.getElementById('changetrust-' +id).innerHTML = b[2] +'<em>/10</em>';
		}
<!--		new Effect.Fade(target3);-->
		var upImageUrl = 'http://www.gamindex.com/templates/yget/images/blue-tupp.gif';
		var downImageUrl = 'http://www.gamindex.com/templates/yget/images/blue-tdown.gif';
				
		if(value == 0)
		{
		//alert("unvote 2 vote");
				target2.className = 'tvote';
				
				
				document.getElementById('changevote-' +id).innerHTML = 'vote';
				document.getElementById('changevote-' +id).style.padding = '2px 0 3px 20px';
				document.getElementById('changevote-' +id).style.background = 'url('+upImageUrl+') no-repeat 4px 3px';
				document.getElementById('changevote-' +id).setAttribute("href","javascript:"+b[3]);
				
				if (document.getElementById('changevote1-' +id) != null) {
					document.getElementById('changevote1-' +id).innerHTML = 'vote';
					document.getElementById('changevote1-' +id).style.padding = '2px 0 3px 20px';
					document.getElementById('changevote1-' +id).style.background = 'url('+upImageUrl+') no-repeat 4px 3px';
					document.getElementById('changevote1-' +id).style.color = "#105cbb";
					document.getElementById('changevote1-' +id).setAttribute("href","javascript:"+b[3]);
				}
				
			if(document.getElementById('changejunk-' +id)==null)
			{ 
			
				if (document.getElementById('changejunk1-' +id) != null) {
					document.getElementById('changejunk1-' +id).innerHTML = 'junk';
					document.getElementById('changejunk1-' +id).style.background = 'url('+downImageUrl+') no-repeat right center';
					document.getElementById('changejunk1-' +id).setAttribute("href","#nogo");				
				}
				if (document.getElementById("xreport-"+id) != null) {
					document.getElementById("xreport-"+id).className='junk';
					document.getElementById('xreport-' +id).innerHTML = "<a id='changejunk-" + id + "' href='#nogo' style='background: url(templates/yget/images/blue-tdown.gif) no-repeat right center;'  >junk</a><div><ul class='clearfix' ><li style='background:url(templates/yget/images/blue-tdown.gif) no-repeat right center;'><a href=javascript:"+ b[4] +" >duplicate</a></li><li><a href=javascript:"+ b[6] +">wrong category</a></li><li><a href=javascript:"+ b[4] +">inaccurate</a></li><li><a href=javascript:"+ b[4] +">spam</a></li></ul></div> ";				
				}
			}
			if(document.getElementById('changejunk1-' +id)==null)
			{
				if (document.getElementById("xreport-"+id) != null) {
					document.getElementById("xreport-"+id).className='junk';
					document.getElementById('xreport-' +id).innerHTML = "<a id='changejunk-" + id + "' href='#nogo' style='background: url(templates/yget/images/blue-tdown.gif) no-repeat right center;'  >junk</a><div><ul class='clearfix' ><li style='background:url(templates/yget/images/blue-tdown.gif) no-repeat right center;'><a href=javascript:"+ b[4] +" >duplicate</a></li><li><a href=javascript:"+ b[6] +">wrong category</a></li><li><a href=javascript:"+ b[4] +">inaccurate</a></li><li><a href=javascript:"+ b[4] +">spam</a></li></ul></div> ";
				}
			}
			
		}

		else if (value > 0) 
		{ 
			//alert("here");
			
				target2.className = 'tvote hist';
				document.getElementById('changevote-' +id).innerHTML = 'unvote';
				//document.getElementById('changevote-' +id).style.background = 'url(templates/yget/images/blue-tupp1.gif)';
				document.getElementById('changevote-' +id).style.background = 'none';
				document.getElementById('changevote-' +id).style.padding = '2px 0px 3px 0px';
				document.getElementById('changevote-' +id).setAttribute("href","javascript:"+b[5]);
				
				if (document.getElementById('changevote1-' +id) != null) {
					document.getElementById('changevote1-' +id).innerHTML = 'unvote';
					//document.getElementById('changevote1-' +id).style.background = 'url(templates/yget/images/blue-tupp1.gif)';
					/*document.getElementById('changevote1-' +id).style.background = 'none';
					document.getElementById('changevote1-' +id).style.color = "#d52c27";
					document.getElementById('changevote1-' +id).style.padding = '2px 0px 3px 0px';*/
					
					document.getElementById('changevote1-' +id).style.background = 'none';
					document.getElementById('changevote1-' +id).style.color = "#d52c27";
					document.getElementById('changevote1-' +id).style.padding = '2px 0px 2px 4px';
					document.getElementById('changevote1-' +id).setAttribute("href","javascript:"+b[5]);
				}
				//alert("changejunk  "+document.getElementById('changejunk-' +id));
				//alert("changejunk1  "+document.getElementById('changejunk1-' +id));
				
				if(document.getElementById('changejunk-' +id) == null)
				{
					if (document.getElementById('changejunk1-' +id) != null) {
						document.getElementById('changejunk1-' +id).innerHTML = 'junk';
						document.getElementById('changejunk1-' +id).style.background = 'url(templates/yget/images/blue-tdown.gif) no-repeat right center';
						document.getElementById('changejunk1-' +id).setAttribute("href","javascript:"+b[4]);				
					}
					if (document.getElementById("xreport-"+id) != null) {
						document.getElementById("xreport1-"+id).className='junk';
						document.getElementById('xreport1-' +id).innerHTML = "<a id='changejunk1-" + id + "' href='#nogo' style='background: url(templates/yget/images/blue-tdown.gif) no-repeat right center;'  >junk</a><div><ul class='clearfix' ><li style='background:url(templates/yget/images/blue-tdown.gif) no-repeat right center;'><a href=javascript:"+ b[4] +" >duplicate</a></li><li><a href=javascript:"+ b[6] +">wrong category</a></li><li><a href=javascript:"+ b[4] +">inaccurate</a></li><li><a href=javascript:"+ b[4] +">spam</a></li></ul></div> ";
					}
				}
				else if(document.getElementById('changejunk1-' +id) == null)
				{
					document.getElementById("xreport-"+id).className='junk';					
					document.getElementById('xreport-' +id).innerHTML = "<a id='changejunk-" + id + "' href='#nogo' style='background: url(templates/yget/images/blue-tdown.gif) no-repeat right center;'  >junk</a><div><ul class='clearfix' ><li style='background:url(templates/yget/images/blue-tdown.gif) no-repeat right center;'><a href=javascript:"+ b[4] +" >duplicate</a></li><li><a href=javascript:"+ b[6] +">wrong category</a></li><li><a href=javascript:"+ b[4] +">inaccurate</a></li><li><a href=javascript:"+ b[4] +">spam</a></li></ul></div> ";
				}
				
		}
		
		
		else if (value < 0 ) 
		{ 
			target2.className = 'tvote hist';
			
			document.getElementById('changevote-' +id).innerHTML = 'unjunk';
			document.getElementById('changevote-' +id).style.background = 'url(templates/yget/images/blue-tupp1.gif)';
			document.getElementById('changevote-' +id).style.padding = '0px 0 0px 0px';
			document.getElementById('changevote-' +id).setAttribute("href","javascript:"+b[5]);
			
			document.getElementById('xreport-' +id).className = "greyvote";				
			document.getElementById('xreport-' +id).innerHTML = '<a id="changejunk-' + id + '" href="javascript:'+ b[3] +'" style="background: url(templates/yget/images/grey-tup.gif) no-repeat 100% 2px"  >vote</a>'; 
		}
	}
	return false;
}

function changecvotevalues (id, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	
	target1 = document.getElementById ('cvote-' + id);

	if (!error) {
		return false;
	}

	if (b.length <= 3) {
	
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
	}
	return false;
}

function enablebutton (button, button2, target)
{
	//alert(typeof(button)+'||'+typeof(button2)+'||'+typeof(target))
	var string = target.value;
	//alert(typeof(button2))
	//alert(button2.disabled)
	button2.disabled = false;
	if (string.length > 0) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

String.prototype.wordWrap = function(m, b, c){
    var i, j, s, r = this.split("<br>");
    
    if(m > 0) for(i in r){
        for(s = r[i], r[i] = ""; s.length > m;
            j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length
            || m,
            r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")
        );
        r[i] +=s;
    }
    	
        return r.join("<br>");
};


function checkfield (type, form, field)
{
	url = 'http://www.gamindex.com/checkfield.php?type='+type+'&name=' + field.value;
	
	imgSrc1 = 'http://www.gamindex.com';
	checkitxmlhttp = new myXMLHttpRequest ();
	checkitxmlhttp.open ("GET", url, true);
	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
		
		var brokenstring=responsestring.split("\n");
		responsestring1 = brokenstring[1];
		var response = field.value + ' is Available';
			if (responsestring1 == 'Available' || responsestring1 == response) {
				<!--alert('*'+document.getElementById ('captchaCodecheckitvalue').innerHTML+'*')-->
<!-- 			eval("alert('*'+document.getElementById (type+'checkitvalue').innerHTML+'*')"); -->
				<!--alert(field.value);-->
				
				if ((document.getElementById (type).getAttribute('class') == 'common inp284 warn-input') || (document.getElementById (type).getAttribute('class') == 'common inp284') && (type == 'username')) {
					document.getElementById (type).style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById (type).className = 'common inp284';
					document.getElementById("lblUname").style.color = "";
				}
				if ((document.getElementById (type).getAttribute('class') == 'common inp487 warn-input') || (document.getElementById (type).getAttribute('class') == 'common inp487') && (type == 'email')) {
					document.getElementById (type).style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById (type).className = 'common inp487';
					document.getElementById("lblEmail").style.color = "";
				}
				if ((document.getElementById (type).getAttribute('class') == 'common inp222 warn-input') || (document.getElementById (type).getAttribute('class') == 'common inp222') && (type == 'captchaCode')) {
					document.getElementById (type).style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById (type).className = 'common inp222';
					document.getElementById("lblCaptcha").style.color = "";
				}
				if ((document.getElementById (type).getAttribute('class') == 'common inp178 warn-input') || (document.getElementById (type).getAttribute('class') == 'common inp178') || (document.getElementById (type).getAttribute('class') == null) && (type == 'username1' || type == 'email')) {
					document.getElementById (type).style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';	
					document.getElementById (type).className = 'common inp178';
					document.getElementById("lblUname").style.color = "";
					document.getElementById("lblEmail").style.color = "";
				}
				
				if (document.getElementById (type+'Ptag').style.display == 'block') {
					document.getElementById (type+'Ptag').style.display = 'none';
				}
				var fieldVal = field.value;
				finalFieldVal = fieldVal.wordWrap(20, "<br>", true);
				//alert(fieldVal.wordWrap(10, "\n>", false));

				document.getElementById (type+'OkPtag').style.display = 'block';
				document.getElementById (type+'Okcheckitvalue').innerHTML = finalFieldVal + ": " +responsestring1;
				//document.getElementById (type+'Okcheckitvalue').style.wordWrap = 'break-word';
				
				form.checkbutton1.disabled = true;
				//form.checkbutton2.disabled = true;
			} else {
				imgsrc = imgSrc1+"/templates/yget/images/id-warning.gif";
				if(type == 'username')
				{
					if (document.getElementById ('usernameOkPtag').style.display == 'block') {
						document.getElementById ('usernameOkPtag').style.display = 'none';
					}
					document.getElementById ('usernamePtag').style.display = 'block';

					//document.getElementById ('invalidImage').setAttribute('src',imgsrc);
					
					//document.getElementById ('invalidImage').style.display='block';
					//document.getElementById ('invalidImagePtag').style.display='block';
					
					if ((document.getElementById ('username').getAttribute('class') == 'common inp284') || (document.getElementById ('username').getAttribute('class') == 'common inp284 warn-input')) {
					    document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('username').className='common inp284 warn-input';
						document.getElementById("lblUname").style.color = "#Ca5100";
					}
				}
				else if(type == 'username1')
				{
					if (document.getElementById ('username1OkPtag').style.display == 'block') {
						document.getElementById ('username1OkPtag').style.display = 'none';
					}
					document.getElementById ('username1Ptag').style.display = 'block';

					//document.getElementById ('invalidImage').setAttribute('src',imgsrc);
					
					//document.getElementById ('invalidImage').style.display='block';
					//document.getElementById ('invalidImagePtag').style.display='block';
					
					if ((document.getElementById ('username1').getAttribute('class') == 'common inp178') || (document.getElementById ('username1').getAttribute('class') == 'common inp178 warn-input')) {
					    document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('username1').className='common inp178 warn-input';
						document.getElementById("lblUname").style.color = "#Ca5100";
					}
					else if (document.getElementById ('username1').getAttribute('class') == null) {
						document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('username1').className='common inp178 warn-input';
						document.getElementById("lblUname").style.color = "#Ca5100";
					}
				}
				else if(type == 'email')
				{
					//document.getElementById ('invalidImageEmail').setAttribute('src',imgsrc);
					//document.getElementById ('invalidImageEmail').style.display='block';
					//document.getElementById ('invalidImageEmailPtag').style.display='block';
					
					if (document.getElementById ('emailOkPtag').style.display == 'block') {
						document.getElementById ('emailOkPtag').style.display = 'none';
					}
					document.getElementById ('emailPtag').style.display = 'block';
					
					if ((document.getElementById ('email').getAttribute('class') == 'common inp178')  || (document.getElementById ('email').getAttribute('class') == 'common inp178 warn-input') || (document.getElementById ('email').getAttribute('class') == null)) {
						//document.getElementById ('email').setAttribute('class','common inp178 warn-input');
						document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('email').className='common inp178 warn-input';
						document.getElementById("lblEmail").style.color = "#Ca5100";
					}
					else {
						//document.getElementById ('email').setAttribute('class','common inp487 warn-input');
						document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('email').className='common inp487 warn-input';
						document.getElementById("lblEmail").style.color = "#Ca5100";
					}
				}
				else if(type == 'captchaCode')
				{
					//document.getElementById ('captchaImaError').setAttribute('src',imgsrc);
					//document.getElementById ('captchaImaError').style.display='block';
					//document.getElementById ('captchaImaErrorPtag').style.display='block';
					
					//if (document.getElementById ('captchaCodeOkPtag').style.display == 'block') {
						//document.getElementById ('captchaCodeOkPtag').style.display = 'none';
					//}
					document.getElementById ('captchaCodePtag').style.display = 'block';
					
					if ((document.getElementById ('captchaCode').getAttribute('class') == 'common inp212') || (document.getElementById ('captchaCode').getAttribute('class') == 'common inp212 warn-input')) {
						//document.getElementById ('captchaCode').setAttribute('class','common inp212 warn-input');
						document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('captchaCode').className='common inp212 warn-input';
						document.getElementById("lblCaptcha").style.color = "#Ca5100";
					}
					else {
						//document.getElementById ('captchaCode').setAttribute('class','common inp222 warn-input');
						document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('captchaCode').className='common inp487 warn-input';
						document.getElementById("lblCaptcha").style.color = "#Ca5100";
					}
				}
				
			    document.getElementById (type+'checkitvalue').innerHTML = responsestring1;
				form.checkbutton1.disabled = true;
				//form.checkbutton2.disabled = true;
			}
		}
	}
  checkitxmlhttp.send (null);
  return false;
}


function checkfield1 (num)
{
	var username;
	var password;
	
	if (num == 1) {
		username = document.register.username1.value;
		password = document.register.password1.value;
	}
	else if (num == 2) {
		username = document.register.username.value;
		password = document.register.password.value;
	}
	 
	var email = document.register.email.value;
	
	var confPassword = document.register.confPassword.value;
	var captchaCode = document.register.captchaCode.value;
	//alert(captchaCode);
	url = 'http://www.gamindex.com/checkfield1.php/'+username+'/'+email+'/'+password+'/'+confPassword+'/'+captchaCode+'/'+num;
	
	imgSrc1 = 'http://www.gamindex.com';

	checkitxmlhttp = new myXMLHttpRequest ();
	checkitxmlhttp.open ("GET", url, true);
	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
		
		var brokenstring=responsestring.split("\n");
		responsestring1 = brokenstring[1];
		var responsestring2=responsestring1.split("|");
			if (responsestring1 == 'OK') { 
				document.register.hdnEmail.value = email;
				document.register.hdnUserLogin.value = username;
				document.register.hdnUserPwd.value = password;
				document.register.submit();
			} else {
				parent.frames["frameCapctha"].location.reload();	
				document.register.captchaCode.value = "";

				imgsrc = imgSrc1+"/templates/yget/images/id-warning.gif";
				//alert(type)
				if(responsestring2[0] != 'valid')
				{
					//document.getElementById ('invalidImage').setAttribute('src',imgsrc);
					//document.getElementById ('invalidImage').setAttribute('style','display:visible');
					
					if (num == 1) {
						if (document.getElementById ('username1').getAttribute('class') == 'common inp178') {
							document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('username1').className = 'common inp178 warn-input';
							document.getElementById("lblUname").style.color = "#Ca5100";
						}
						else if (document.getElementById ('username1').getAttribute('class') == null) {
							document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('username1').className = 'common inp178 warn-input';
							document.getElementById("lblUname").style.color = "#Ca5100";
						}
					}
					else if (num == 2) {
						if (document.getElementById ('username').getAttribute('class') == 'common inp284') {
							document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('username').className = 'common inp284 warn-input';
							document.getElementById("lblUname").style.color = "#Ca5100";
						}
						else if (document.getElementById ('username').getAttribute('class') == null) {
							document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('username').className = 'common inp284 warn-input';
							document.getElementById("lblUname").style.color = "#Ca5100";
						}
					}
					
					document.getElementById ('usernamePtag').style.display = 'block';
					document.getElementById ('usernamecheckitvalue').innerHTML = responsestring2[0];
				}
				
				if(responsestring2[1]!= 'valid')
				{
					//document.getElementById ('invalidImageEmail').setAttribute('src',imgsrc);
					//document.getElementById ('invalidImageEmail').setAttribute('style','display:visible');
					
					if (document.getElementById ('email').getAttribute('class') == 'common inp178') {
						document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('email').className = 'common inp178 warn-input';
						document.getElementById("lblEmail").style.color = "#Ca5100";
					}
					else {
						document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('email').className = 'common inp487 warn-input';
						document.getElementById("lblEmail").style.color = "#Ca5100";
					}
					document.getElementById ('emailPtag').style.display = 'block';
					document.getElementById ('emailcheckitvalue').innerHTML = responsestring2[1];
				}

				if(responsestring2[2]!= 'valid')
				{
					//document.getElementById("errImage").setAttribute('src',imgsrc);	
					//document.getElementById("errImage").setAttribute('style','display:visible');
					
					if (num == 1) {
						if (document.getElementById ('password1').getAttribute('class') == 'common inp261') {
							document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('password1').className = 'common inp261 warn-input';
							document.getElementById("lblPassword").style.color = "#Ca5100";
						}
					}
					else if (num == 2) {
						if (document.getElementById ('password').getAttribute('class') == 'common inp241') {
							document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
							document.getElementById ('password').className = 'common inp241 warn-input';
							document.getElementById("lblPassword").style.color = "#Ca5100";
						}
					}
					
					document.getElementById ('passPtag').style.display = 'block';
					document.getElementById("passcheckitvalue").innerHTML = responsestring2[2];
				}

				if(responsestring2[3]!= 'valid')
				{
					//document.getElementById("errConfImage").setAttribute('src',imgsrc);	
					//document.getElementById("errConfImage").setAttribute('style','display:visible');
					
					if (document.getElementById ('confPassword').getAttribute('class') == 'common inp178') {
						document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('confPassword').className = 'common inp178 warn-input';
						document.getElementById("lblConfPassword").style.color = "#Ca5100";
					}
					else {
						document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('confPassword').className = 'common inp241 warn-input';
						document.getElementById("lblConfPassword").style.color = "#Ca5100";
					}
					document.getElementById ('confPassPtag').style.display = 'block';					
					document.getElementById("confPasscheckitvalue").innerHTML  = responsestring2[3];
				}

				if(responsestring2[4]!= 'valid')
				{
					//document.getElementById ('captchaImaError').setAttribute('src',imgsrc);
					//document.getElementById ('captchaImaError').setAttribute('style','display:visible');
					
					if (document.getElementById ('captchaCode').getAttribute('class') == 'common inp178') {
						document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('captchaCode').className = 'common inp178 warn-input';
						document.getElementById("lblCaptcha").style.color = "#Ca5100";
					}
					else {
						document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
						document.getElementById ('captchaCode').className = 'common inp222 warn-input';
						document.getElementById("lblCaptcha").style.color = "#Ca5100";
					}
					document.getElementById ('captchaCodePtag').style.display = 'block';	
					document.getElementById ('captchaCodecheckitvalue').innerHTML = responsestring2[4];
				}
			}
		}
	}
  checkitxmlhttp.send (null);
  return false;
}

function validate(num,form,imgSrc1)
{
	if (num == 1) {
		//document.getElementById ('invalidImage').setAttribute('style','display:none');
		document.getElementById("username1Ptag").style.display = 'none';
		document.getElementById("username1checkitvalue").innerHTML = "";
		document.getElementById("username1OkPtag").style.display = 'none';
		document.getElementById("username1Okcheckitvalue").innerHTML = "";
		document.getElementById("lblUname").className = "uname";
	}
	else if (num == 2) {
		//document.getElementById ('invalidImage').setAttribute('style','display:none');
		document.getElementById("usernamePtag").style.display = 'none';
		document.getElementById("usernamecheckitvalue").innerHTML = "";
		document.getElementById("usernameOkPtag").style.display = 'none';
		document.getElementById("usernameOkcheckitvalue").innerHTML = "";
		document.getElementById("lblUname").className = "uname";
	}

	//document.getElementById ('invalidImageEmail').setAttribute('style','display:none');
	document.getElementById("emailPtag").style.display = 'none';
	document.getElementById("emailcheckitvalue").innerHTML = "";
	document.getElementById("emailOkPtag").style.display = 'none';
	document.getElementById("emailOkcheckitvalue").innerHTML = "";
	document.getElementById("lblEmail").className = "eaddress";
		
	//document.getElementById("errImage").setAttribute('style','display:none');
	document.getElementById("passPtag").style.display = 'none';
	document.getElementById("passcheckitvalue").innerHTML = "";
	document.getElementById("passOkPtag").style.display = 'none';
	document.getElementById("passOkcheckitvalue").innerHTML = "";
	document.getElementById("lblPassword").className = "choosepass";
	
	//document.getElementById("errConfImage").setAttribute('style','display:none');
	document.getElementById("confPassPtag").style.display = 'none';
	document.getElementById("confPasscheckitvalue").innerHTML = "";
	document.getElementById("confPassOkPtag").style.display = 'none';
	document.getElementById("confPassOkcheckitvalue").innerHTML = "";
	document.getElementById("lblConfPassword").className = "retypepass";
	
	//document.getElementById("dateImage").setAttribute('style','display:none');
	document.getElementById("errDatePtag").style.display = 'none';
	document.getElementById("errDatecheckitvalue").innerHTML = "";
	//document.getElementById("errDateOkPtag").style.display = 'none';
	//document.getElementById("errDateOkcheckitvalue").innerHTML = "";
	//document.getElementById("lblDate").className = "";
	
	//document.getElementById("agreement_checkboxError").setAttribute('style','display:none');
	document.getElementById("agreePtag").style.display = 'none';
	document.getElementById("agreecheckitvalue").innerHTML = "";
	//document.getElementById("agreeOkPtag").style.display = 'none';
	//document.getElementById("agreeOkcheckitvalue").innerHTML = "";
	
	//document.getElementById("captchaImaError").setAttribute('style','display:none');
	document.getElementById("captchaCodePtag").style.display = 'none';
	document.getElementById("captchaCodecheckitvalue").innerHTML = "";
	//document.getElementById("captchaCodeOkPtag").style.display = 'none';
	//document.getElementById("captchaCodeOkcheckitvalue").innerHTML = "";
	//document.getElementById("lblCaptcha").className = "";
	
	
	dateStr = document.register.month.value +'/'+ document.register.day.value+'/'+document.register.year.value;
	
	//var flagCkeck = true;
	var countInvalid = 0;
	
	imgsrc = imgSrc1+"/templates/yget/images/id-warning.gif";

	if (num == 1) {
		if(document.register.username1.value == '')
		{
		 	//flagCkeck = false;
			//document.getElementById ('invalidImage').setAttribute('src',imgsrc);
			//document.getElementById ('invalidImage').setAttribute('style','display:visible');
			
			if (document.getElementById ('username1').getAttribute('class') == 'common inp178' || document.getElementById ('username1').getAttribute('class') == 'common inp178 warn-input') {
				document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username1').className = 'common inp178 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			else if (document.getElementById ('username1').getAttribute('class') == null){
				document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username1').className = 'common inp178 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			document.getElementById ('username1Ptag').style.display = 'block';
			document.getElementById("username1checkitvalue").innerHTML = "Please enter the Member ID";
			countInvalid = countInvalid + 1;
		}
		else if(document.register.username1.value.length < 4)
		{
			//flagCkeck = false;
			//document.getElementById("invalidImage").setAttribute('src',imgsrc);	
			//document.getElementById("invalidImage").setAttribute('style','display:visible');
			
			if (document.getElementById ('username1').getAttribute('class') == 'common inp178' || document.getElementById ('username1').getAttribute('class') == 'common inp178 warn-input') {
				document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username1').className = 'common inp178 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			else if (document.getElementById ('username1').getAttribute('class') == null){
				document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username1').className = 'common inp178 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			document.getElementById ('username1Ptag').style.display = 'block';
			document.getElementById("username1checkitvalue").innerHTML = "Please enter the Member ID more than 4 characters";
			countInvalid = countInvalid + 1;
		}
		else
		{
			if(isSpecialusername("username", document.register.username1.value))
	     	{ 
	     		//flagCkeck = false;
	     		if (document.getElementById ('username1').getAttribute('class') == 'common inp178' || document.getElementById ('username1').getAttribute('class') == 'common inp178 warn-input') {
	     			document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('username1').className = 'common inp178 warn-input';
					document.getElementById("lblUname").style.color = "#Ca5100";
				}
				else if (document.getElementById ('username1').getAttribute('class') == null){
					document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('username1').className = 'common inp178 warn-input';
					document.getElementById("lblUname").style.color = "#Ca5100";
				}
				
				document.getElementById ('username1Ptag').style.display = 'block';
	       		document.getElementById("username1checkitvalue").innerHTML = "Please enter the Valid Member ID";
	       		countInvalid = countInvalid + 1;
	     	}
	     	else {
	     		if (document.getElementById ('username1').getAttribute('class') == 'common inp178 warn-input' || document.getElementById ('username1').getAttribute('class') == 'common inp178') {
	     			document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('username1').className = 'common inp178';
					document.getElementById("lblUname").style.color = "";
				}
				else if (document.getElementById ('username1').getAttribute('class') == null){
					document.getElementById ('username1').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('username1').className = 'common inp178';
					document.getElementById("lblUname").style.color = "";
				}
				document.getElementById ('username1Ptag').style.display = 'none';
	     		//flagCkeck = true;
	     		//countInvalid = 0;
	     	}
		}
	}
	else if (num == 2) {
		if(document.register.username.value == '')
		{
		 	//flagCkeck = false;
			//document.getElementById ('invalidImage').setAttribute('src',imgsrc);
			//document.getElementById ('invalidImage').setAttribute('style','display:visible');
			
			if (document.getElementById ('username').getAttribute('class') == 'common inp284' || document.getElementById ('username').getAttribute('class') == 'common inp284 warn-input') {
				document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username').className = 'common inp284 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			else if (document.getElementById ('username').getAttribute('class') == null) {
				document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username').className = 'common inp284 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			document.getElementById ('usernamePtag').style.display = 'block';
			document.getElementById("usernamecheckitvalue").innerHTML = "Please enter the Member ID";
			countInvalid = countInvalid + 1;
		}
		else if(document.register.username.value.length < 4)
		{
			//flagCkeck = false;
			//document.getElementById("invalidImage").setAttribute('src',imgsrc);	
			//document.getElementById("invalidImage").setAttribute('style','display:visible');
			
			if (document.getElementById ('username').getAttribute('class') == 'common inp284' || document.getElementById ('username').getAttribute('class') == 'common inp284 warn-input')  {
				document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username').className = 'common inp284 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			else if (document.getElementById ('username').getAttribute('class') == null) {
				document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('username').className = 'common inp284 warn-input';
				document.getElementById("lblUname").style.color = "#Ca5100";
			}
			document.getElementById ('usernamePtag').style.display = 'block';
			document.getElementById("usernamecheckitvalue").innerHTML = "Please enter the Member ID more than 4 characters";
			countInvalid = countInvalid + 1;
		}
		else
		{
			if(isSpecialusername("username", document.register.username.value))
	     	{ 
	     		//flagCkeck = false;
	     		if (document.getElementById ('username').getAttribute('class') == 'common inp284' || document.getElementById ('username').getAttribute('class') == 'common inp284 warn-input') {
					document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('username').className = 'common inp284 warn-input';
					document.getElementById("lblUname").style.color = "#Ca5100";
				}
				else if (document.getElementById ('username').getAttribute('class') == null) {
					document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('username').className = 'common inp284 warn-input';
					document.getElementById("lblUname").style.color = "#Ca5100";
				}
				document.getElementById ('usernamePtag').style.display = 'block';
	       		document.getElementById("usernamecheckitvalue").innerHTML = "Please enter the Valid Member ID";
	       		countInvalid = countInvalid + 1;
	     	}
	     	else {
	     		if (document.getElementById ('username').getAttribute('class') == 'common inp284 warn-input' || document.getElementById ('username').getAttribute('class') == 'common inp284') {
	     			document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('username').className = 'common inp284';
					document.getElementById("lblUname").style.color = "";
				}
				else if (document.getElementById ('username').getAttribute('class') == null) {
					document.getElementById ('username').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('username').className = 'common inp284';
					document.getElementById("lblUname").style.color = "";
				}
				document.getElementById ('usernamePtag').style.display = 'none';
	     		//flagCkeck = true;
	     		//countInvalid = 0;
	     	}
		}
	}

	if(document.register.email.value == '')
	{ 
		//flagCkeck = false;
		//document.getElementById ('invalidImageEmail').setAttribute('src',imgsrc);
		//document.getElementById ('invalidImageEmail').setAttribute('style','display:visible');
		
		if (document.getElementById ('email').getAttribute('class') == 'common inp178' || document.getElementById ('email').getAttribute('class') == 'common inp178 warn-input') {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp178 warn-input';
			document.getElementById("lblEmail").style.color = "#Ca5100";
		}
		else if (document.getElementById ('email').getAttribute('class') == 'common inp487' || document.getElementById ('email').getAttribute('class') == 'common inp487 warn-input') {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp487 warn-input';
			document.getElementById("lblEmail").style.color = "#Ca5100";
		}
		else if (document.getElementById ('email').getAttribute('class') == null && num == 1) {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp178 warn-input';
			document.getElementById("lblEmail").style.color = "#Ca5100";
		}
		else {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp487 warn-input';
			document.getElementById("lblEmail").style.color = "#Ca5100";
		}
		document.getElementById ('emailPtag').style.display = 'block';
		document.getElementById("emailcheckitvalue").innerHTML = "Please enter the Email";
		countInvalid = countInvalid + 1;
	}		
	else {
		if (document.getElementById ('email').getAttribute('class') == 'common inp178 warn-input' || document.getElementById ('email').getAttribute('class') == 'common inp178') {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp178';
			document.getElementById("lblEmail").style.color = "";
		}
		else if (document.getElementById ('email').getAttribute('class') == 'common inp487 warn-input' || document.getElementById ('email').getAttribute('class') == 'common inp487') {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp487';
			document.getElementById("lblEmail").style.color = "";
		}
		else if (document.getElementById ('email').getAttribute('class') == null && num == 1) {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp178';
			document.getElementById("lblEmail").style.color = "";
		}
		else {
			document.getElementById ('email').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('email').className = 'common inp487';
			document.getElementById("lblEmail").style.color = "";
		}
		document.getElementById ('emailPtag').style.display = 'none';
		//flagCkeck = true;
		//countInvalid = 0;
	}
		
	if (num == 1) {
		if(document.register.password1.value == '')
		{ 
			//flagCkeck = false;
			//document.getElementById("errImage").setAttribute('src',imgsrc);	
			//document.getElementById("errImage").setAttribute('style','display:visible');
			
			if (document.getElementById ('password1').getAttribute('class') == 'common inp261' || document.getElementById ('password1').getAttribute('class') == 'common inp261 warn-input') {
				document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('password1').className = 'common inp261 warn-input';
				document.getElementById("lblPassword").style.color = "#Ca5100";
			}
			else if (document.getElementById ('password1').getAttribute('class') == null) {
				document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('password1').className = 'common inp261 warn-input';
				document.getElementById("lblPassword").style.color = "#Ca5100";
			}
			document.getElementById ('passPtag').style.display = 'block';
			document.getElementById("passcheckitvalue").innerHTML = "Please enter the Password";
			countInvalid = countInvalid + 1;
		}
		else if(document.register.password1.value != '')
		{
			if(document.register.password1.value.length < 6)
			{ 
				//flagCkeck = false;
				//document.getElementById("errImage").setAttribute('src',imgsrc);	
				//document.getElementById("errImage").setAttribute('style','display:visible');
				
				if (document.getElementById ('password1').getAttribute('class') == 'common inp261' || document.getElementById ('password1').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('password1').className = 'common inp261 warn-input';
					document.getElementById("lblPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('password1').getAttribute('class') == null) {
					document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('password1').className = 'common inp261 warn-input';
					document.getElementById("lblPassword").style.color = "#Ca5100";
				}
				document.getElementById ('passPtag').style.display = 'block';
				document.getElementById("passcheckitvalue").innerHTML = "Please enter the Password more than 6 characters";
				countInvalid = countInvalid + 1;
			}
			else {
				if (document.getElementById ('password1').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('password1').className = 'common inp261';
					document.getElementById("lblPassword").style.color = "";
				}
				else if (document.getElementById ('password1').getAttribute('class') == null) {
					document.getElementById ('password1').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('password1').className = 'common inp261';
					document.getElementById("lblPassword").style.color = "";
				}
				document.getElementById ('passPtag').style.display = 'none';
				//flagCkeck = true;
				//countInvalid = 0;
			}
		}
	}
	else if (num == 2) {
		if(document.register.password.value == '')
		{ 
			//flagCkeck = false;
			//document.getElementById("errImage").setAttribute('src',imgsrc);	
			//document.getElementById("errImage").setAttribute('style','display:visible');
			
			if (document.getElementById ('password').getAttribute('class') == 'common inp241' || document.getElementById ('password').getAttribute('class') == 'common inp241 warn-input') {
				document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('password').className = 'common inp241 warn-input';
				document.getElementById("lblPassword").style.color = "#Ca5100";
			}
			else if (document.getElementById ('password').getAttribute('class') == null) {
				document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
				document.getElementById ('password').className = 'common inp241 warn-input';
				document.getElementById("lblPassword").style.color = "#Ca5100";
			}
			document.getElementById ('passPtag').style.display = 'block';
			document.getElementById("passcheckitvalue").innerHTML = "Please enter the Password";
			countInvalid = countInvalid + 1;
		}
		else if(document.register.password.value != '')
		{
			if(document.register.password.value.length < 6)
			{ 
				//flagCkeck = false;
				//document.getElementById("errImage").setAttribute('src',imgsrc);	
				//document.getElementById("errImage").setAttribute('style','display:visible');
				
				if (document.getElementById ('password').getAttribute('class') == 'common inp241' || document.getElementById ('password').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('password').className = 'common inp241 warn-input';
					document.getElementById("lblPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('password').getAttribute('class') == null) {
					document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('password').className = 'common inp241 warn-input';
					document.getElementById("lblPassword").style.color = "#Ca5100";
				}
				document.getElementById ('passPtag').style.display = 'block';
				document.getElementById("passcheckitvalue").innerHTML = "Please enter the Password more than 6 characters";
				countInvalid = countInvalid + 1;
			}
			else {
				if (document.getElementById ('password').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('password').className = 'common inp241';
					document.getElementById("lblPassword").style.color = "";
				}
				else if (document.getElementById ('password').getAttribute('class') == null) {
					document.getElementById ('password').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('password').className = 'common inp241';
					document.getElementById("lblPassword").style.color = "";
				}
				document.getElementById ('passPtag').style.display = 'none';
				//flagCkeck = true;
				//countInvalid = 0;
			}
		}
	}
	
	if(document.register.confPassword.value == '')
	{ 
		//flagCkeck = false;
		//document.getElementById("errConfImage").setAttribute('src',imgsrc);	
		//document.getElementById("errConfImage").setAttribute('style','display:visible');
		
		if (document.getElementById ('confPassword').getAttribute('class') == 'common inp261' || document.getElementById ('confPassword').getAttribute('class') == 'common inp261 warn-input') {
			document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('confPassword').className = 'common inp261 warn-input';
			document.getElementById("lblConfPassword").style.color = "#Ca5100";
		}
		else if (document.getElementById ('confPassword').getAttribute('class') == 'common inp241' || document.getElementById ('confPassword').getAttribute('class') == 'common inp241 warn-input') {
			document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('confPassword').className = 'common inp241 warn-input';
			document.getElementById("lblConfPassword").style.color = "#Ca5100";
		}
		else if (document.getElementById ('confPassword').getAttribute('class') == null && num == 1) {
			document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('confPassword').className = 'common inp261 warn-input';
			document.getElementById("lblConfPassword").style.color = "#Ca5100";
		}
		else {
			document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('confPassword').className = 'common inp241 warn-input';
			document.getElementById("lblConfPassword").style.color = "#Ca5100";
		}
		document.getElementById ('confPassPtag').style.display = 'block';
		document.getElementById("confPasscheckitvalue").innerHTML = "Please enter the Confirm Password";
		countInvalid = countInvalid + 1;
	}
	else if(document.register.confPassword.value != '')
	{
		if (num == 1) {	
			if(document.register.password1.value != document.register.confPassword.value)
			{ 
				//flagCkeck = false;
				//document.getElementById("errConfImage").setAttribute('src',imgsrc);	
				//document.getElementById("errConfImage").setAttribute('style','display:visible');
				
				if (document.getElementById ('confPassword').getAttribute('class') == 'common inp261' || document.getElementById ('confPassword').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == 'common inp241' || document.getElementById ('confPassword').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == null && num == 1) {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				document.getElementById ('confPassPtag').style.display = 'block';
				document.getElementById("confPasscheckitvalue").innerHTML = "Password Mismatch";
				countInvalid = countInvalid + 1;
			}
			else {
				if (document.getElementById ('confPassword').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == null && num == 1) {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241';
					document.getElementById("lblConfPassword").style.color = "";
				}
				document.getElementById ('confPassPtag').style.display = 'none';
				//flagCkeck = true;
				//countInvalid = 0;
			}
		}
		else if (num == 2) {
			if(document.register.password.value != document.register.confPassword.value)
			{ 
				//flagCkeck = false;
				//document.getElementById("errConfImage").setAttribute('src',imgsrc);	
				//document.getElementById("errConfImage").setAttribute('style','display:visible');
				
				if (document.getElementById ('confPassword').getAttribute('class') == 'common inp261' || document.getElementById ('confPassword').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == 'common inp241' || document.getElementById ('confPassword').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == null && num == 1) {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				else {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241 warn-input';
					document.getElementById("lblConfPassword").style.color = "#Ca5100";
				}
				document.getElementById ('confPassPtag').style.display = 'block';
				document.getElementById("confPasscheckitvalue").innerHTML = "Password Mismatch";
				countInvalid = countInvalid + 1;
			}
			else {
				if (document.getElementById ('confPassword').getAttribute('class') == 'common inp261 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == 'common inp241 warn-input') {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else if (document.getElementById ('confPassword').getAttribute('class') == null && num == 1) {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp261';
					document.getElementById("lblConfPassword").style.color = "";
				}
				else {
					document.getElementById ('confPassword').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
					document.getElementById ('confPassword').className = 'common inp241';
					document.getElementById("lblConfPassword").style.color = "";
				}
				document.getElementById ('confPassPtag').style.display = 'none';
				//flagCkeck = true;
				//countInvalid = 0;
			}
		}		
	}
	
	if(document.register.captchaCode.value == '')
	{ 	
		//flagCkeck = false;
		//document.getElementById("captchaImaError").setAttribute('src',imgsrc);	
		//document.getElementById("captchaImaError").setAttribute('style','display:visible');
		
		if (document.getElementById ('captchaCode').getAttribute('class') == 'common inp212' || document.getElementById ('captchaCode').getAttribute('class') == 'common inp212 warn-input') {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className ='common inp212 warn-input';
			document.getElementById("lblCaptcha").style.color = "#Ca5100";
		}
		else if (document.getElementById ('captchaCode').getAttribute('class') == 'common inp222' || document.getElementById ('captchaCode').getAttribute('class') == 'common inp222 warn-input') {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp222 warn-input';
			document.getElementById("lblCaptcha").style.color = "#Ca5100";
		}
		else if (document.getElementById ('captchaCode').getAttribute('class') == null && num == 1) {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className ='common inp212 warn-input';
			document.getElementById("lblCaptcha").style.color = "#Ca5100";
		}
		else {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/red-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp222 warn-input';
			document.getElementById("lblCaptcha").style.color = "#Ca5100";
		}
		document.getElementById ('captchaCodePtag').style.display = 'block';
		 if (num == 2) {
			document.getElementById("captchaCodecheckitvalue").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please enter the security code";
		 }
		 else {
		 	document.getElementById("captchaCodecheckitvalue").innerHTML = "Please enter the security code";
		 }
		countInvalid = countInvalid + 1;
	}
	else {
		if (document.getElementById ('captchaCode').getAttribute('class') == 'common inp212 warn-input') {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp212';
			document.getElementById("lblCaptcha").style.color = "";
		}
		else if (document.getElementById ('captchaCode').getAttribute('class') == 'common inp222 warn-input') {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp222';
			document.getElementById("lblCaptcha").style.color = "";
		}
		else if (document.getElementById ('captchaCode').getAttribute('class') == null && num == 1) {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp212';
			document.getElementById("lblCaptcha").style.color = "";
		}
		else {
			document.getElementById ('captchaCode').style.background = 'url(http://www.gamindex.com/images/green-input.gif) repeat-x left top';
			document.getElementById ('captchaCode').className = 'common inp222';
			document.getElementById("lblCaptcha").style.color = "";
		}
		document.getElementById ('captchaCodePtag').style.display = 'none';
		//flagCkeck = true;
		//countInvalid = 0;
	}
	
	if ( isValidDate (dateStr,imgsrc) == false ) {
		//flagCkeck = false;
		//document.getElementById("dateImage").setAttribute('src',imgsrc);	
		//document.getElementById("dateImage").setAttribute('style','display:visible');
		
		if(document.getElementById ('birthdayDiv')) {
			document.getElementById ('birthdayDiv').className = 'birthday warn-input';
			document.getElementById("lblDate1").style.color = "#Ca5100";
		}
		else {
			document.getElementById ('birthdayDivCenter').className = 'dateselect clearfix warnx4';
		}
		document.getElementById ('errDatePtag').style.display = 'block';
		if ( num == 2 ) {
			document.getElementById("errDatecheckitvalue").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please enter the Date";
		}
		else {
			document.getElementById("errDatecheckitvalue").innerHTML = "Please enter the Date";
		}
		countInvalid = countInvalid + 1;
	}
	else {
		if(document.getElementById ('birthdayDiv')) {
			document.getElementById ('birthdayDiv').className = 'birthday';
			document.getElementById("lblDate1").style.color = "";
		}
		else {
			document.getElementById ('birthdayDivCenter').className = 'dateselect clearfix';
		}
		document.getElementById ('errDatePtag').style.display = 'none';
		//flagCkeck = true;
		//countInvalid = 0;
	}
	
	if(document.register.agreement_checkbox.checked == false)
	{ 
		//flagCkeck = false;
		//document.getElementById("agreement_checkboxError").setAttribute('src',imgsrc);	
		//document.getElementById("agreement_checkboxError").setAttribute('style','display:visible');
				
		document.getElementById ('agreePtag').style.display = 'block';
		if ( num == 2 ) {
			document.getElementById("agreecheckitvalue").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please agree Terms and Conditions";
		}
		else {
			document.getElementById("agreecheckitvalue").innerHTML = "Please agree Terms and Conditions";
		}
		countInvalid = countInvalid + 1;
	}	
	else {
		document.getElementById ('agreePtag').style.display = 'none';
		//flagCkeck = true;
		//countInvalid = 0;
	}
	
	if(countInvalid == 0) {
		checkfield1(num);
	}
	else {
		parent.frames["frameCapctha"].location.reload();
		document.getElementById("captchaCode").value = "";
	}
	
	return false;
}

function isSpecialusername(name1, s)
  {
    var i;
    var splchars;
    splchars="+-@;,:*[]?|\\><'\"";
    var regExp = /[a-zA-Z]+/;

      // Search through string's characters one by one
      // until we find a special characters
      // When we do, return true; if we don't, return false.

    if(!regExp.test(s))
    {   
      return true;
    }
    for (i = 0; i < s.length; i++)
    {
          // Check that current character isn't whitespace.
      var c = s.charAt(i);
      if (splchars.indexOf(c) != -1) 
      {
        return true;
      }
    }
}

function emailto (original_id, htmlid, instpath, address_count)
{
	email_message = document.getElementById('email_message' + htmlid).value;
	email_address = document.getElementById('email_address_1_' + htmlid).value;
	if (address_count > 1){ 
		for ($i = 2; $i <= address_count; $i++) {
			if(document.getElementById('email_address_' + $i + '_' + htmlid).value != "") {
				email_address = email_address + ', ' + document.getElementById('email_address_' + $i + '_' + htmlid).value;
			}
		}
	}
	
	if (xmlhttp) {
		url = "http://www.gamindex.com/recommend.php";
		mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
		
		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = "<br>Sending, please wait....";
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];						
					} else {
						target2 = document.getElementById ('emailtoERR-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
						
						if(document.getElementById ('sucessful').innerHTML == 'Email has been sent successfully')
						{
							document.getElementById('emailto-' + htmlid).style.display = 'none';
						}	
					}
				}
			}
		}
	}
}

function show_recommend(htmlid, linkid, instpath)
{
	var emailtodisplay=document.getElementById('emailto-' + htmlid).style.display ? '' : 'none';
	document.getElementById('emailto-' + htmlid).style.display = emailtodisplay;

	if (xmlhttp) {
		url = "http://www.gamindex.com/recommend.php";
		mycontent = "draw=small&htmlid=" + htmlid + "&linkid=" + linkid;
		target2 = document.getElementById ('emailto-' + htmlid);
		target2.innerHTML = "<br>Loading, please wait....";		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];						
					} else {
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
					}
				}
			}
		}
	}
}

function isValidDate(dateStr,imgsrc) {
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
		//alert("Date is not in a valid format.")
		//document.getElementById("dateImage").setAttribute('src',imgsrc);	
		//document.getElementById("dateImage").setAttribute('style','display:visible');
	
		document.getElementById ('errDatePtag').style.display = 'block';
		document.getElementById("errDatecheckitvalue").innerHTML = "Invalid Date";
		return false;
	}
	
		
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		document.getElementById("dateImage").setAttribute('src',imgsrc);	
		document.getElementById("dateImage").setAttribute('style','display:visible');
		document.getElementById("errDate").innerHTML = "This month doesn't have 31 days!";
		return false
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			document.getElementById("dateImage").setAttribute('src',imgsrc);	
			document.getElementById("dateImage").setAttribute('style','display:visible');
			document.getElementById("errDate").innerHTML = "February " + year + " doesn't have " + day + " days!";
			return false;
		}
	}
return true;  // date is valid
} 

