function toggleAccordionContent(h,b){		
	var header = document.getElementById(h);	
	var box = document.getElementById(b);		
	Effect.toggle(box, 'slide', { duration:.5 }); 
	if(header.style.background == "rgb(238, 238, 238) url(arroweye/images/accordion-up.jpg) no-repeat scroll 458px center"){
		header.style.background = "rgb(238, 238, 238) url(arroweye/images/accordion-down.jpg) no-repeat scroll 458px center";
	}else{
		header.style.background = "rgb(238, 238, 238) url(arroweye/images/accordion-up.jpg) no-repeat scroll 458px center";
	}
}

function click_prodbtn(b){
	var num = b-1;			
	var btns = new Array('prodbtn1','prodbtn2','prodbtn3','prodbtn4','prodbtn5','prodbtn6','prodbtn7','prodbtn8','prodbtn9','prodbtn10', 'prodbtn11');
	var icons = new Array('prodicon1','prodicon2','prodicon3','prodicon4','prodicon5','prodicon6','prodicon7','prodicon8','prodicon9','prodicon10', 'prodicon11');
	var headers = new Array('subheader1','subheader2','subheader3','subheader4','subheader5','subheader6','subheader7','subheader8','subheader9','subheader10', 'subheader11');
	var contents = new Array('subtext1','subtext2','subtext3','subtext4','subtext5','subtext6','subtext7','subtext8','subtext9','subtext10', 'subtext11');
	showContent(num,btns,icons,headers,contents);
}

function click_aboutbtn(b){	
	var num = b-1;			
	var btns = new Array('aboutbtn1','aboutbtn2','aboutbtn3','aboutbtn4','aboutbtn5');
	var icons = new Array('abouticon1','abouticon2','abouticon3','abouticon4','abouticon5');
	var headers = new Array('subheader1','subheader2','subheader3','subheader4','subheader5');
	var contents = new Array('subtext1','subtext2','subtext3','subtext4','subtext5');
	showContent(num,btns,icons,headers,contents);
}

function click_newsbtn(b){		
	var btn = document.getElementById(b);			
	var icons = new Array('newsicon1','newsicon2','newsicon3', 'newsicon4');
	
	switch(b){
		case 'newsbtn1':			
			Effect.BlindDown('sub_article', { duration: .5, delay:.7 });
			Effect.BlindUp('sub_media', { duration: .5, afterFinish:changeText });
			Effect.BlindUp('sub_releases', { duration: .5 });
			Effect.BlindUp('sub_study', { duration: .5 });
			break;
		case 'newsbtn2':
			Effect.BlindUp('sub_article', { duration: .5, afterFinish:changeText });
			Effect.BlindDown('sub_media', { duration: .5, delay:.7 });
			Effect.BlindUp('sub_releases', { duration: .5 });
			Effect.BlindUp('sub_study', { duration: .5 });
			break;
		case 'newsbtn3':
			Effect.BlindUp('sub_article', { duration: .5, afterFinish:changeText });
			Effect.BlindUp('sub_media', { duration: .5 });
			Effect.BlindDown('sub_releases', { duration: .5, delay:.7 });
			Effect.BlindUp('sub_study', { duration: .5 });
			break;
		case 'newsbtn4':
			Effect.BlindUp('sub_article', { duration: .5, afterFinish:changeText });
			Effect.BlindUp('sub_media', { duration: .5 });
			Effect.BlindUp('sub_releases', { duration: .5 });
			Effect.BlindDown('sub_study', { duration: .5, delay:.7 });
			break;	
	}

	
	function changeText(){
		var subt = document.getElementById('subtext');
		switch(b){
			case 'newsbtn1':			
				showSelected('newsicon1',icons);	
				Effect.BlindDown('newsdesc1', { duration: .5, delay:.5, scaleContent:false});
				Effect.BlindUp('newsdesc2', { duration: .5, delay:0, scaleContent:false  });
				Effect.BlindUp('newsdesc3', { duration: .5, delay:0, scaleContent:false  });
				Effect.BlindUp('newsdesc4', { duration: .5, delay:0, scaleContent:false });
				break;
			case 'newsbtn2':
				showSelected('newsicon2',icons);				
				Effect.BlindUp('newsdesc1', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindDown('newsdesc2', { duration: .5, delay:.5, scaleContent:false });
				Effect.BlindUp('newsdesc3', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindUp('newsdesc4', { duration: .5, delay:0, scaleContent:false });
				break;
			case 'newsbtn3':
				showSelected('newsicon3',icons);				
				Effect.BlindUp('newsdesc1', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindUp('newsdesc2', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindDown('newsdesc3', { duration: .5, delay:.5, scaleContent:false });
				Effect.BlindUp('newsdesc4', { duration: .5, delay:0, scaleContent:false });
				break;
			case 'newsbtn4':
				showSelected('newsicon4',icons);				
				Effect.BlindUp('newsdesc1', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindUp('newsdesc2', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindUp('newsdesc3', { duration: .5, delay:0, scaleContent:false });
				Effect.BlindDown('newsdesc4', { duration: .5, delay:.5, scaleContent:false });
				break;	
		}
	}
}

function showSelected(currSelection,icons){		
	for(i=0;i<icons.length;i++){		
		if(icons[i]!=currSelection){		
			if(document.getElementById(icons[i]).style.display!='none'){
				Effect.BlindUp(icons[i], { duration: .35, scaleX:true, scaleY:false, scaleContent:false });
			}
		}
	}		
	Effect.BlindDown(currSelection, { duration: .35, scaleX:true, scaleY:false, scaleContent:false });
}
function showContent(num,btns,icons,headers,contents){	

	for(i=0;i<icons.length;i++){
		if(i==num){		
			document.getElementById(btns[i]).style.color="#E68F1A";
			Effect.BlindDown(icons[i], { duration: .35, scaleX:true, scaleY:false, scaleContent:false });				
			Effect.BlindDown(headers[i], { duration: .5, delay:.7 });
			Effect.BlindDown(contents[i], { duration: .5, delay:.7 });
			
		}else{		
			document.getElementById(btns[i]).style.color="";
			if(document.getElementById(icons[i]).style.display=="none" || document.getElementById(icons[i]).style.display==""){
				Effect.BlindUp(icons[i], { duration: .35, scaleX:true, scaleY:false, scaleContent:false });	
				Effect.BlindUp(headers[i], { duration: .5 });
				Effect.BlindUp(contents[i], { duration: .5 });
			}
			if(document.getElementById('subtext0')!=null && document.getElementById('subtext0').style.display!="none"){
				Effect.BlindUp('subheader0', { duration: .5 });
				Effect.BlindUp('subtext0', { duration: .5 });
			}
		}
	}		
}

				
//===== contact form validation ==========//
String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};	

function validateForm(){
	var isValid = true;
	var _FirstName = document.getElementsByName('FirstName').item(0);
	var _LastName = document.getElementsByName('LastName').item(0);
	var _Company = document.getElementsByName('Company').item(0);
	var _Title = document.getElementsByName('Title').item(0);
	var _Phone = document.getElementsByName('Phone').item(0);
	var _Email = document.getElementsByName('Email').item(0);
	
	if(_FirstName.value.trim()==""){
		alert("Please Enter Your First Name");
		_FirstName.focus();
		isValid = false;
	}else if(_LastName.value.trim()==""){
		alert("Please Enter Your Last Name");
		_LastName.focus();
		isValid = false;
	}else if(!is_valid_phone(_Phone)){
		isValid = false;
	}else if(!is_valid_email(_Email.value)){
		alert("Please Enter Your Valid Email Address");
		_Email.focus();
		isValid = false;
	}
	var _ContactMe = document.getElementsByName('ContactMe').item(0).checked;
	
	return isValid;	
}
	

function is_valid_email(email){
	return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email);
}

var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function is_valid_phone(Phone){	

	if ((trim(Phone.value)!="") && checkInternationalPhone(Phone.value)==false){
		alert("Please Enter Your a Phone Number");
		Phone.focus();
		return false;
	}
	return true
 }
		