function closeBox()
{
	
	shiftOpacity('report_box', 1000);
	//document.getElementById("report_box").style.display="none";
}
function openBox()
{
	
	document.getElementById('report_box').style.opacity = 0;
	shiftOpacity('report_box', 2000);
	
	
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 


function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

function validEmail(email) 
{ 
    if (email == ""){return false;} 
    badStuff = ";:/,' \"\\"; 
     
    for (i=0; i<badStuff.length; i++) 
    { 
        badCheck = badStuff.charAt(i) 
        if (email.indexOf(badCheck,0) != -1){return false;} 
    } 

    posOfAtSign = email.indexOf("@",1) 
     
    if (posOfAtSign == -1){return false;} 

    if (email.indexOf("@",posOfAtSign+1) != -1){return false;} 
    posOfPeriod = email.indexOf(".", posOfAtSign) 
     
    if (posOfPeriod == -1){return false;} 
    if (posOfPeriod+2 > email.length){return false;} 
     
return true; 
} 



function IsEmpty(objWord)
{
	var blnIsEmpty = true;	
	var blnObjectPrm=false;
	var i=0;	
	var strWord='';
	var objThis;
	strWord = objWord;
	while(i<strWord.length && blnIsEmpty) {
		if (strWord.charAt(i)!=' ')
			blnIsEmpty=false;
		i++;
  	}
	if (blnIsEmpty)
	{
		return true;
	}
	else
	{
		return false;
	}
	
}




// product add form
function validate1(frm)
{
	var errorstr = '';
	var msgstr = "There is a slight problem with your form submission.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (IsEmpty(name.value)) { errorstr += "- Please enter your name.\n";}
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}



// product add form
function validate2(frm)
{
	var errorstr = '';
	var msgstr = "There is a slight problem with your form submission.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	
	with(frm)
	{ 	
		if (frm.account_exists.checked==false)
		{
			if (IsEmpty(name.value)) { errorstr += "- Please enter your name.\n";}
		}
		
		if (!validEmail(email.value)) { errorstr += "- Please enter a valid email address.\n";}
	}	
	
	if (errorstr != ''){msgstr = msgstr + errorstr;alert(msgstr);return false;}
	else{return true;}	
}



var ajax = null; 

// Create AJAX Object
function createObject()
{
	var ajaxObj;
	if (window.XMLHttpRequest)
	{
		ajaxObj = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		ajaxObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return ajaxObj;	
}


// Pass the url and function name here
function makeRequest(url,functionName)
{
	
	
	
	
	ajax = createObject();
	ajax.onreadystatechange = eval(functionName);		
	ajax.open("GET", url, true);
	ajax.send(null);	
	
}





// Specific Functions
function check_email_availability()
{
		
	if (ajax.readyState==4 && ajax.status==200)
	{
		xmlData = ajax.responseText;
		document.getElementById("ajax_result").innerHTML = xmlData;
		
	}
	else
	{
		
		document.getElementById("ajax_result").innerHTML = "<span class='small'>Processing...</span>";
	}
}






function check_group_availability()
{
	
	if (ajax.readyState==4 && ajax.status==200)
	{
		xmlData = ajax.responseText;
		document.getElementById("group_result").innerHTML = xmlData;
		
	}
	else
	{
		
		document.getElementById("group_result").innerHTML = "Processing...";
	}
	
}


