function createXHR(){
	var xhr;
	try{
		xhr = new ActiveXObject("MSXML2.XMLHTTP");
	}catch(e){
		try{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xhr=false;
		}
	}
	if(!xhr && typeof XMLHttpRequest != 'undefined'){
		xhr = new XMLHttpRequest();
	}
	return xhr;
}
function get(str){
	return document.getElementById(str);
}
function getN(str){
	return document.getElementsByName(str);
}
function setTitle(sTitle){
  try{
     var titleString = get('beginTitle').value;
	sTitle.replace(/<br>/,'');
	sTitle = sTitle.replace(/<br>/,' ');
     document.title = titleString+': '+sTitle;
  }catch(e){
  }
}
function loadCurves(){
	settings8 = {
          tl: { radius: 8 },
          tr: { radius: 8 },
          bl: { radius: 8 },
          br: { radius: 8 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
	}
	var myBoxObjectMain = new curvyCorners(settings8, "curve8");
	myBoxObjectMain.applyCornersToAll();
}


function loadInit(){
	if(ttl != null){
		var ttl =  get('title').innerHTML;
		ttl.replace(/<br>/,'');
		ttl = ttl.replace(/<br>/,' ');
		setTitle(ttl);
	} else {
		var ttl = 'Home';
	}
}
function setDiv(){
	if (xhr.readyState == 4){
		var res = xhr.responseText;
		l = getN("container").length -1;
		get('container').innerHTML = res;
	}
}
var glblFile;
function getFile(id){
	glblFile = id;
	xhr = createXHR();
	xhr.onreadystatechange = setDiv;
	xhr.open("GET","index.php?id=" + id);
	xhr.send(null);
}
function RunFoo()
{
    document.write('<object id="plyr" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="260" height="194">\n');
    document.write('<param name="movie" value="flash/main.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="quality" value="high">');
    document.write('<embed src="flash/main.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="260" height="194" wmode="transparent"></embed></object>');
}
function RunFoo2()
{
	document.write('<object id="player1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.115" width="245" height="170">');
	document.write('<param name=bgcolor value="#FFFFFF"><param name=movie value="player.swf"><param name=allowfullscreen value="true"><param name=allowscriptaccess value="always"><param name="autostart" value="true"><param name="flashvars" value="file=flash/draft_02_sm.flv&controlbar=bottom">');
	document.write('<embed name="player1" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="245" height="170" bgcolor="#FFFFFF" src="player.swf" allowfullscreen="true" allowscriptaccess="always" flashvars="file=flash/draft_02_sm.flv&controlbar=bottom" autostart="true"></embed></object>');
}

// FORM VALIDATION
function checkKey(evt){
	if (evt.keyCode == 13){
	    //f.submit();
	    return jcap();
	}
}
function validate(){
  var f = document.getElementById("f");
  fn=f.first_name.value;
  ln=f.last_name.value;
  em=f.email.value;
  ti=f.title.value;
  co=f.company.value;
  ind=f.industry.value;

function isEmail(strValue){
  var objRegExp = /^[a-z0-9](.+)@[a-z0-9](.+)$/;
   return objRegExp.test(strValue);
}
function isNumeric(strValue){
  return (strValue.replace(/[0-9]/g,"") == "");
}
function isLetters(strValue){
 return (strValue.replace(/[A-Za-z]/g,"") == "");
}
msg=new String("");
if(fn.length==0){
  msg+="First Name is required\n ";
}
if(ln.length==0){
  msg+="Last Name is required\n ";
}
if(ti.length==0){
  msg+="Title is required\n ";
}
if(co.length==0){
  msg+="Company is required\n ";
}
if(ind.length==0){
  msg+="Industry is required\n ";
}
if(!isLetters(f.first_name.value)){
	msg+="Please enter Letters Only for your first name\n";
	//f.first_name.focus();
}
if(!isLetters(f.last_name.value)){
	msg+="Please enter Letters Only for your last name\n";
	//f.last_name.focus();
}
if(em.length==0){
	msg+="E-mail is required\n";
	//f.email.focus();
}
if(msg.length>0){
  msg="The following errors occurred:\n "+msg;
  alert(msg);
  return false;
} else {
  return jcap();
  }
}


function validateSrv(){
    var rad = get('val').value;
    if(rad < 1){
	alert('Please select an item from the poll list.');
    } else {
	document.location.href = 'results.php';
    }
}


// COPYRIGHT
var TheSeparator = "/";
var TheSeparator2 = ", ";
var ShowDay ="yes";
var Days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var TheDate = new Date();

var TheWeekDay = TheDate.getDay();
var Day ="";
if (ShowDay == "yes"){
    Day = Days[TheWeekDay];
    Day += "";}

var TheMonth = TheDate.getMonth() + 1;
if (TheMonth < 10) TheMonth = "0" + TheMonth;

var TheMonthDay = TheDate.getDate();
if (TheMonthDay < 10) TheMonthDay = "0" + TheMonthDay;

var TheYear = TheDate.getYear();
if (TheYear < 1000) TheYear += 1900;

var D = "";
D += TheYear;


// ROTATE
var aryimg = new Array(7);
var arytxt = new Array(7);
var aryurl = new Array(7);
var dt = new Date();
var idx = 0;

aryimg[0] = "images/btmpic1.gif";
aryimg[1] = "images/btmpic2.gif";
aryimg[2] = "images/btmpic3.gif";
aryimg[3] = "images/btmpic4.gif";
aryimg[4] = "images/btmpic5.gif";
aryimg[5] = "images/btmpic6.gif";
aryimg[6] = "images/btmpic7.gif";

arytxt[0] = "Cross-Industry Pattern Matching is the Key to Your 'Next'";
arytxt[1] = "Capitalizing on future trends";
arytxt[2] = "Streamlining processes";
arytxt[3] = "Product innovation";
arytxt[4] = "Customer impact";
arytxt[5] = "Talent acquisition";
arytxt[6] = "Defining your<br>secret sauce";

aryurl[0] = "article1.php";
aryurl[1] = "article2.php";
aryurl[2] = "article3.php";
aryurl[3] = "article4.php";
aryurl[4] = "article5.php";
aryurl[5] = "article6.php";
aryurl[6] = "article7.php";

function rotate(){
    idx = dt.getTime()%7;
    get('myImg').src=aryimg[idx];
    get('myTxt').innerHTML=arytxt[idx];
    get('myURL').href=aryurl[idx];
}





Array.prototype.indexOf = function(item){
	var idx = -1;
	for(var i=0; i < this.length;i++){
		if(this[i] == item){
			idx = i;
			break;
		}
	}
	return idx;          
};
Array.prototype.copy = function(){
	var newAry = Array();
	for(var i=0; i < this.length;i++){
		newAry[newAry.length] = this[i];
	}
	return newAry;
}
Array.prototype.subtract = function(ary){
	this.tmpAry = this.copy();
	for(var i = 0; i < ary.length;i++){
		this.tmpAry.splice(this.tmpAry.indexOf(ary[i]),1);
	}
	return this.tmpAry;
}
Array.prototype.removeRandom = function(numItems){
	this.tmpAry = this.copy();
	var dt = new Date();
	idx = dt.getTime()%this.tmpAry.length;
	this.tmpAry.splice(idx,1);
	numItems--;
	if(numItems > 0){
		this.tmpAry = this.tmpAry.removeRandom(numItems);
	}
	return this.tmpAry;
}
Array.prototype.getRandom = function(numItems){
	var aryB = this.removeRandom(numItems);
	var aryC = this.subtract(aryB);
	return aryC;
}

