function makeObject(){
	var x; 
	var browser = navigator.appName; 
	//detect the client browser
	if(browser == "Microsoft Internet Explorer"){
		x = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		x = new XMLHttpRequest();
	}
	
	return x;
}
	//call the function makeObject()
		//call the function makeObject()	
	//call the function makeObject()
	var request = makeObject();
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
  var imageSeparator = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparator);
  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = nextImage;
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }
  var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
    + ';' + nextImage;
  setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
    displaySecs*2000);
  // Cache the next image to improve performance.
  imageSeparator = futureImages.indexOf(";");
  nextImage = futureImages.substring(0,imageSeparator);
  if (slideCache[nextImage] == null) {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].src = nextImage;
  }
}
//-----------------------------------Show Category--------------------------

// **********************************   ajax functions	 **********************************************
	var x=0;//stores the x coordinate of the mouse click in add_to_cart
	var y=0;//stores the y coordinate of the mouse click in add_to_cart
function get_subcat_to_add_show(k){
var e = window.event;
		var browser = navigator.appName; 
		//detect the client browser
		if(browser == "Microsoft Internet Explorer"){
			x=e.clientX;
			y=e.clientY;
			
		}
		
		var scrOfX = 0, scrOfY = 0;

		if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
			
		
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}

		y=y+scrOfY;
	//if(document.showcategory.show_category.value=="EMPTY"){
		//document.addfile.addfile_submit.disabled=true;
		//document.showcategory.show_subcategory.disabled=true;																								
	//}
	
		request.open('get', 'admin/process.php?val=show_add&prsn='+k);
		request.onreadystatechange = subcat_to_add_show; 
		request.send('');
	
}

function subcat_to_add_show(){
 	if (request.readyState == 1) {
		document.all.showsubcategory.innerHTML="Loading.....";
		document.getElementById("showsubcategory").style.left=(x+60)+ "px";
		document.getElementById("showsubcategory").style.top=(y-5)+ "px";
		document.getElementById("showsubcategory").style.display="";
		//while(document.showcategory.show_subcategory.options.length>0){document.showcategory.show_subcategory.options[0]=null;}
	}

	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="";

    	if (request.status == 200) {
		document.getElementById("showsubcategory").innerHTML=request.responseText;
		 
		
			/*document.showcategory.show_submit.disabled=false;
			document.showcategory.show_subcategory.disabled=false;													
			var ajax_result_array=request.responseText.split("#*");
			var newoption=new Option('Select Sub Category','EMPTY');
			document.showcategory.show_subcategory.options[0]=newoption;
			
			for(var j=1;j<(ajax_result_array.length);j++){
				var temp=ajax_result_array[j].split("$@");
				var newoption=new Option(temp[1],temp[0]);
				document.showcategory.show_subcategory.options[j]=newoption;
			}*/																																							
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}
function mouse_out(){
		document.getElementById("showsubcategory").innerHTML='';
}
function get_subcat_to_add(){

	if(document.addfile.addfile_category.value=="EMPTY"){
		document.addfile.addfile_submit.disabled=true;
		document.addfile.addfile_subcategory.disabled=true;																								
	}
	else{
		request.open('get', 'admin/process.php?val=file_add&prsn='+document.addfile.addfile_category.value);
		request.onreadystatechange = subcat_to_add; 
		request.send('');
	}
}

function subcat_to_add(){
 	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		while(document.addfile.addfile_subcategory.options.length>0){document.addfile.addfile_subcategory.options[0]=null;}
	}

	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="";

    	if (request.status == 200) {
		 
		
			document.addfile.addfile_submit.disabled=false;
			document.addfile.addfile_subcategory.disabled=false;													
			var ajax_result_array=request.responseText.split("#*");
			var newoption=new Option('Select Sub Category','EMPTY');
			document.addfile.addfile_subcategory.options[0]=newoption;
			
			for(var j=1;j<(ajax_result_array.length);j++){
				var temp=ajax_result_array[j].split("$@");
				var newoption=new Option(temp[1],temp[0]);
				document.addfile.addfile_subcategory.options[j]=newoption;
			}																																							
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}
function get_subcat_to_edit(){

	if(document.addfile.editfile_category.value=="EMPTY"){
		document.addfile.editfile_submit.disabled=true;
		document.addfile.editfile_subcategory.disabled=true;																								
	}
	else{
		request.open('get', 'admin/process.php?val=file_edit&prsn='+document.addfile.editfile_category.value);
		request.onreadystatechange = file_to_edit; 
		request.send('');
	}
}

function file_to_edit(){
	if (request.readyState == 1) {
		document.all.aj_msg.innerHTML="Loading.....";
		while(document.addfile.editfile_subcategory.options.length>0){document.addfile.editfile_subcategory.options[0]=null;}
	}

	if (request.readyState == 4) {
		document.all.aj_msg.innerHTML="";

    	if (request.status == 200) {
		
			document.addfile.editfile_submit.disabled=false;
			document.addfile.editfile_subcategory.disabled=false;
																												
			var ajax_result_array=request.responseText.split("#*");
			var newoption=new Option('Select Sub Category','EMPTY');
			document.addfile.editfile_subcategory.options[0]=newoption;
			
			for(var j=1;j<(ajax_result_array.length);j++){
				var temp=ajax_result_array[j].split("$@");
				var newoption=new Option(temp[1],temp[0]);
				document.addfile.editfile_subcategory.options[j]=newoption;
			}																																							
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}

function get_sub_cat(v,i){

for(j=1;j<21;j++){
	if(document.getElementById("subcategory_"+j)!=null){document.getElementById("subcategory_"+j).style.backgroundColor="#f4ffd2";}
}
document.getElementById(i).style.backgroundColor="#f2f8d2";
	request.open('get', "ajax.php?val=get_subcat&v="+v);
	request.onreadystatechange = display_sub_cat; 
	request.send('');
}
function display_sub_cat(){
	if (request.readyState == 1) {
		document.getElementById("subcategory").style.display="";
	}

	if (request.readyState == 4) {
//		document.getElementById("subcatwait").style.display="none";
    	if (request.status == 200) {
			document.getElementById("subcategory").innerHTML=request.responseText ;
		}
		else {
    		alert('There was a problem with the request.');
		}
	}		
}


function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

function validateForm(theForm)
{
	// Customize these calls for your form

	// Start ------->
	if (!validRequired(theForm.fNameisandi,"Name"))
		return false;

	if (!validRequired(theForm.fCompanyisandi,"Company"))
		return false;

	if (!validRequired(theForm.fPhoneisandi,"telephone"))
		return false;

		if (!validEmail(theForm.fEmailisandi,"Email Address",true))
		return false;

	if (!validRequired(theForm.fCommentisandi,"Comments",true))
		return false;
	// <--------- End
	
	return true;
}
function add_file(){
	if((chk_empty(document.addfile.file_firstname))&&(chk_empty(document.addfile.file_lastname))&&(validEmail(document.addfile.file_email))&&(chk_empty(document.addfile.file_country))&&(is_selected(document.addfile.addfile_category))&&(is_selected(document.addfile.addfile_subcategory))&&(chk_empty(document.addfile.file_title))&&(chk_empty(document.addfile.file_description))&&(chk_empty(document.addfile.add_articles_img))){
			document.addfile.action="admin/process.php?val=add_file";
			document.addfile.submit();
			return true;
	}
	else{return false;}	
}

// JavaScript Document
function login_submit(){
	if((document.admin_login.username.value!="")&&(document.admin_login.password.value!="")){
		document.admin_login.action="process.php?val=login";
		document.admin_login.submit();
	}
	else{alert("Username and Password cannot be empty. Please enter valid values");}	
}
var popupwindow;
function show_large(ne){
	popupwindow=window.open('view_large.php?val='+ne,'popup','height=300,width=450');
	popupwindow.focus();
}
function search_area(){
	document.search_a.action="search.php";
	document.search_a.submit();
	return true;
}
function add_bulletin(){
			document.bulletin.action="admin/process.php?val=bulletin";
			document.bulletin.submit();
			return true;
}
function add_subscribers(){
			if((chk_empty(document.addsubscribers.addsubscribers_name))&&(validEmail(document.addsubscribers.addsubscribers_email))){
			document.addsubscribers.action="admin/process.php?val=add_subscribers";
			document.addsubscribers.submit();
			}
	else{return false;}	
}
function chk_empty(bx){
	if(bx.value==""){
		var nm=bx.name.split("_");
		var b_nm=nm[1].toUpperCase();
		alert("The field \'"+b_nm+"\' cannot be empty. Please enter a valid value");
		bx.focus();
		return false;
	}
	else{return true;}	
}

function is_selected(cbo){
	if(cbo.value=="EMPTY"){
		var nm=cbo.name.split("_");
		var b_nm=nm[1].toUpperCase();
		alert("The field \'"+b_nm+"\' cannot be empty. Please Select an aritist form the drop down");
		cbo.focus();
		return false;
	}
	else{return true;}	
}
/*function add_file(){
			document.file.action="ajax.php?val=add_file";
			document.file.submit();
			//popupwindow=window.open('http://67.19.12.131/ssl/online_booking.html','popup','height=600,width=800,resizable,scrollbars');			
			//popupwindow.focus();
			return true;
}*/
/*function hidediv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'hidden'; 
} 
} 

function showdiv() { 
var e = window.event;
		var browser = navigator.appName; 
		//detect the client browser
		if(browser == "Microsoft Internet Explorer"){
			x=e.clientX;
			y=e.clientY;
			
		}
		
		var scrOfX = 0, scrOfY = 0;

		if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
			
		
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}

		y=y+scrOfY;
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideshow').style.visibility = 'visible'; 
} 
}
 function hidediv()
  {
   var divX=document.getElementById("hideshow");
   var divY=document.getElementById("divY");
   
   hideshow.style.visibility="hidden";
   divY.style.visibility="hidden";
  }
  function showdiv()
  {
   var divX=document.getElementById("hideshow");
   var divY=document.getElementById("divY");
   
   hideshow.style.visibility="visible";
   divY.style.visibility="visible";
  } */
  var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
