var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;


function switchContent(topic) {
	
	
	unloadStage();
	str = 'inpage.php?topic='+topic;
	
		jQuery.ajax({
			  url: str,async: true,
				success: function(data) {	
				jQuery("#Content").html(data);
			//	window.location.hash = topic;
				// focus on details
			//	Shadowbox.init();
											
			  }
			});
			
}

function getMediaButton(track_id,randid) {
	// this takes a member id and gets the first video in their video list.

	//$(randid).innerHTML = '<img src="_images/loading.gif" width="22" height="22"/>';	
	str = 'dbread.php?action=getMediaButton&track_id='+track_id;
		jQuery.ajax({
			  url: str,async: true,
				success: function(data) {
			//	jQuery(".track-"+track_id).html(data);	
				$(randid).innerHTML = data;
			  }
			});		
}

function setOpacity(elem, opacityAsInt) {  
	var opacityAsDecimal = opacityAsInt;
	if (opacityAsInt > 100) 
		opacityAsInt = opacityAsDecimal = 100;  
	else if (opacityAsInt < 0)  
		opacityAsInt = opacityAsDecimal = 0; 
	
	if (opacityAsInt < 1) 
		opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
	opacityAsDecimal /= 100;
	document.getElementById(elem).style.opacity = (opacityAsDecimal);
	document.getElementById(elem).style.filter = "alpha(opacity=" + opacityAsInt + ")";
}

function goToPage(catid) { 
	window.location = 'index.php?page=4&cid='+catid;
	} 

function navSet(currPage, amount) {
	
	for (i=1;i<=10;i=i+1) {
		if (i != currPage) {
		
			setOpacity('main'+i,amount);
		}
	}
}

function navFade(currPage) {
	// This fucntion takes the current page we are on and fades the main nav items that are not needed for that page.   gives focus to the pages we are on.

	switch (currPage) {
	/*	case 4: navSet(currPage,65);
		break;*/
		case 8: navSet(currPage,100);
		break;
		default: navSet(99,100);  // set all to 100% opacity
	}
}

function equalizePanels() {
	// this function makes sure that all panels, main nave, nav2 and content are of equal height
var col1 = $('leftCol');
var col2 = $('rightCol');
var col3 = $('mainCol');
var str='';
if (col1 != null) { col1h = Element.getHeight(col1); str+='col1h,';}
if (col2 != null) { col2h = Element.getHeight(col2); str+='col2h,';}
if (col3 != null) { col3h = Element.getHeight(col3); str+='col3h,';}
var str2 = rtrim(str,',') ;

	highest = Math.max(eval(str2));
	col1.style.height = highest + 'px';
	col2.style.height = highest+10 + 'px';
	col3.style.height = highest+30 + 'px';
	
}

function initTip(){
	jQuery(".tooltip-target").ezpz_tooltip();
	jQuery(".toolpic-target").ezpz_tooltip({
	contentPosition: 'aboveFollow'});
}

function pageit(actions, page, rpp, searchit,loc) {
//	alert('here');
	if (loc == 'admin') {   // whether we are running from admin panel or main
		str = '../flow.php?page='+page+'&action='+actions+'&rpp='+rpp+'&search='+searchit+'&loc='+loc;
	} else {
		str = 'flow.php?page='+page+'&action='+actions+'&rpp='+rpp+'&search='+searchit+'&loc='+loc;
	}
	var myAjax = new Ajax.Request(
			str, 
			{
				method: 'post', 
				asynchronous: true,  
				parameters: '', 
				onFailure: function (response) {  
                   $('showContent').update(response.statusText);
                     },  
				onLoading: function (response) {
                $('showStatus').update('<span class="loading"><img src="_images/loading.gif" title="Loading..." alt="Loading..." border="0" /></span>')},
				onComplete: function(response) {
					result = response.responseText;
					$('showContent').update(result);
					$('showStatus').update('');
				//	initTip();
				//	resarray = result.split("**SPLIT**",2);
               	 //       $('showContent').update(resarray[0]);
				//		$('showNav').update(resarray[1]);
				//	$('showPeople').innerHTML = response.responseText;
				}
			});	
}



/* menu Code START */

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = jQuery(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

jQuery(document).ready(function()
{	jQuery('#jsddm > li').bind('mouseover', jsddm_open);
	jQuery('#jsddm > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;

/* Menu CODE END */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function commentProcess(commentid,statuschange) {
//	var rcountstr;

jQuery.prompt('Are You Sure?', { 
			buttons:{Ok:true, Cancel: false},
			prefix:'hp',
			opacity: 0.4,
			focus: 1,
			overlayspeed : 'fast',
			callback: function(v,m,f){
			if(v){
	var myAjax = new Ajax.Request(
			'dbmodify.php?action=commentProcess'+'&commentid='+commentid+'&statuschange='+statuschange, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					updateresult = response.responseText;
					window.location.reload( true );
				}
			});
			
			}}});
	
}

function sendFormAddComment(event) {  
	
                 // we stop the default submit behaviour  
				 $('commentFeedback').show();
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_comment"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                         $('commentFeedback').update('<span class="saving"><img src="_images/loading.gif" title="Saving..." alt="Saving..." border="0" /></span>');  
                     },                            
                     onSuccess: function(oXHR) {  
                        $('commentFeedback').update(oXHR.responseText);
					    $('comment').value = '';
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=commentAdd", oOptions);             
   }  

function sendFormAddComment2(event) {  
	
                 // we stop the default submit behaviour  
				 $('commentFeedback').show();
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_contact"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                         $('commentFeedback').update('<span class="saving"><img src="_images/loading2.gif" title="Saving..." alt="Saving..." border="0" /></span>');  
                     },                            
                     onSuccess: function(oXHR) {  
                        $('commentFeedback').update(oXHR.responseText);
						$('name').value = '';
					    $('email').value = '';
						$('phone').value = '';
					    $('message').value = '';
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=contact", oOptions);             
   }
   
function sendFormAddComment3() {  	
                 // we stop the default submit behaviour  
				 $('commentFeedback').show();
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_design"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                         $('commentFeedback').update('<span class="saving"><img src="_images/loading2.gif" title="Saving..." alt="Saving..." border="0" /></span>');  
                     },                            
                     onSuccess: function(oXHR) {  
                        $('commentFeedback').update(oXHR.responseText);
						$('name').value = '';
					    $('email').value = '';
						$('business').value = '';
						$('colors').value = '';
					    $('industry').value = '';
						$('message').value = '';
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=design", oOptions);             
   }
   
function sendFormAddComment4(event) {  
	
                 // we stop the default submit behaviour  
				 $('commentFeedback').show();
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_contact"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                         $('loadFeedback').update('<span class="saving"><img src="_images/loading.gif" title="Saveing..." alt="Saving..." border="0" /></span>');  
                     },                            
                     onSuccess: function(oXHR) {  
                        $('loadFeedback').update('');
                        $('commentFeedback').update(oXHR.responseText);
					
					    $('email').value = '';
						$('subject').value = '';
						$('message').value = '';
						
						jQuery("#frm_contact").validationEngine({	
		  success : function() { sendFormAddComment4() },
		  failure : false })
						
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=contact", oOptions);             
   }   
   

function sendFormPromoJoin() {  	
                 // we stop the default submit behaviour  
				 $('commentFeedback').show();
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_promoJoin"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                         $('commentFeedback').update('<span class="Wait..."><img src="_images/loading.gif" title="Wait..." alt="Wait..." border="0" /></span>');  
                     },                            
                     onSuccess: function(oXHR) {  
					    $('txtEmail').value = 'Email';
						$('commentFeedback').update(oXHR.responseText);
                     }                 
                 };  
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=promoJoin", oOptions);             
   }  
   
function sendFormAddMessage(event) {  
                 // we stop the default submit behaviour  
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_chat"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                        /* $('loadFeedback').update('<span class="saving"><img src="_images/loading.gif" title="Saveing..." alt="Saving..." border="0" /></span>');*/  
                     },                            
                     onSuccess: function(oXHR) {  
				/*     	$('loadFeedback').update('');*/
                  //      $('commentFeedback').update(oXHR.responseText);
						$('message').value = '';
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=addMessage", oOptions);             
   }
   
   
function updateChatWindow(lastId) {
	
	var myAjax = new Ajax.Request(
			'dbmodify.php?action=updateChatWindow&lastId='+lastId, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onSuccess: function(response) {
					result = response.responseText;	
					if (result != 'uptodate') {
						resultList = result.split('<--*-->'); // split on <--*-->
						$('chatWindow').innerHTML += resultList[0];
						$('lastId').innerHTML = resultList[1];
						/*var objDiv = document.getElementById("chatWindow");
						objDiv.scrollTop = objDiv.scrollHeight;*/
						autoScroll = jQuery('#chatWindow').data('jScrollPanePosition') == jQuery('#chatWindow').data('jScrollPaneMaxScroll');
						
						jQuery(function(){jQuery('#chatWindow').jScrollPane({showArrows:true})});
						if (autoScroll)
						{
							jQuery('#chatWindow')[0].scrollTo(jQuery('#chatWindow').data('jScrollPaneMaxScroll'));
						}
						

					}
				}
			});		
}
  
function sendFormBanNickname(event) {  
                 // we stop the default submit behaviour  
                 var oOptions = {  
                     method: "POST",  
                     parameters: Form.serialize("frm_ban"),  
                     asynchronous: true,  
                     onFailure: function (oXHR) {  
                         $('commentFeedback').update(oXHR.statusText);
                     },  
                     onLoading: function (oXHR) {
                        /* $('loadFeedback').update('<span class="saving"><img src="_images/loading.gif" title="Saveing..." alt="Saving..." border="0" /></span>');*/  
                     },                            
                     onSuccess: function(oXHR) {  
				/*     	$('loadFeedback').update('');*/
                  //      $('commentFeedback').update(oXHR.responseText);
						$('ban').value = '';
						$('unban').value = '';
                     }                 
                 };  
//				 var currdiaryid = 14;
                 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "dbmodify.php?action=banNickname", oOptions);             
   }  
     

function showRecord(memid) { 

        var myAjax = new Ajax.Request(
			'../dbread.php?action=showRecord&memid='+memid, 
			{
				method: 'get', 
				parameters: '', 
				/*onLoading: function (response) {
                $('rateMe').update('<span class="ratewait"><img src="_images/loading-black.gif" title="Working..." alt="Working..." border="0" /></span>')},*/
				onComplete: function(response) {
					$('showRecord').innerHTML = response.responseText;
					jQuery(document).ready(function() {
jQuery("#frm_record").validationEngine()
      });
				}
			});	             
   }       
   
function showItem(id) { 

        var myAjax = new Ajax.Request(
			'../dbread.php?action=showItem&id='+id, 
			{
				method: 'get', 
				parameters: '', 
				/*onLoading: function (response) {
                $('rateMe').update('<span class="ratewait"><img src="_images/loading-black.gif" title="Working..." alt="Working..." border="0" /></span>')},*/
				onComplete: function(response) {
					$('showItem').innerHTML = response.responseText;
					jQuery(document).ready(function(){			
					jQuery('textarea').elastic();
							});	
					jQuery(document).ready(function() {
					jQuery("#frm_Item").validationEngine()
     				 });
					
					<!-- TinyMCE -->
					tinyMCE.init({
						// General options
						mode : "textareas",
						theme : "advanced",
						editor_deselector : "mceNoEditor", 
				
						// Theme options
					
						theme_advanced_buttons1_add : "forecolor, bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect",
						force_br_newlines : true,
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "left",
						theme_advanced_statusbar_location : "bottom",
						// Example content CSS (should be your site CSS)
						content_css : "js/tiny_mce/css/content.css",
				
						// Replace values for the template plugin
						template_replace_values : {
							username : "Some User",
							staffid : "991234"
						}
					});
					
						
					
				}
			});	             
   }

function showItemMain(id) { 

        var myAjax = new Ajax.Request(
			'dbread.php?action=showItemMain&id='+id, 
			{
				method: 'get', 
				parameters: '', 
				onLoading: function (response) {
                $('showItem').update('<span class="loading"><img src="_images/loading.gif" title="Loading..." alt="Loading..." border="0" /></span>')},
				onComplete: function(response) {
					$('showItem').innerHTML = response.responseText;
				}
			});	             
   }    

function doDelItem(itemID) {  
	
	var myAjax = new Ajax.Request(
			'../dbmodify.php?action=delItem&itemID='+itemID, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					jQuery.prompt('Item has been deleted', {
								  callback: function(){window.location.href = 'index.php?page=3';}
								  }
								  );
						
				}
			});	
}

function delItem(itemID) {

var txt = 'Are you sure you want to delete this Item?';

jQuery.prompt(txt, { 
			buttons:{Delete:true, Cancel: false},
			opacity: 0.4,
			overlayspeed : 1,
			callback: function(v,m,f){
			if(v){
				doDelItem(itemID);
		 	}}});

}

function editCat(level){
	
	var name = "content";
	var description = "content";
	
	
// fetch name and description from database
if (level == 'parent') {
var index = document.getElementById('catlist').options[document.getElementById('catlist').selectedIndex].value;
} else {
var index = document.getElementById('subcatlist').options[document.getElementById('subcatlist').selectedIndex].value;
	
}


var catInfo = getCatInfo(level,index);
    name = catInfo[0];
	description = catInfo[1];
	
var txt = '<div class="txt4">Modify the Category information<br /><form id="frm_catEdit" method="post">Name<br /><input type="text" class="niceInput shortField2" id="cname" name="cname" value="'+ name +'" /><br />Description<br /><textarea class="niceArea shortField2" id="cdescription" name="cdescription">'+description+'</textarea></form></div>';	

			jQuery.prompt(txt,{ 
					buttons:{Change:true, Cancel:false},
					overlayspeed : 1,
					opacity: 0.4,
					callback: function(v,m,f){
						if(v){	
						var myAjax = new Ajax.Request('../dbmodify.php?action=updateCatInfo&cid='+index+'&level='+level+'&name='+f.cname+'&description='+f.cdescription,
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					results = response.responseText;
					jQuery.prompt(results, {
								  callback: function(){window.location.href = 'index.php?page=4';}
								  }
								  );
				}
			});
						
					}
					
					}});

}


function addCat(level){

// add name and description to database
	
var index = 0;

var txt = '<div class="txt4">Create a New Category<br /><form id="frm_catAdd" method="post">Name<br /><input type="text" class="niceInput shortField2" id="cname" name="cname" value="" /><br />Description<br /><textarea class="niceArea shortField2" id="cdescription" name="cdescription"></textarea></form></div>';	

if (level == 'child') {   //find the parent category
index = document.getElementById('catlist').options[document.getElementById('catlist').selectedIndex].value;	
}

			jQuery.prompt(txt,{ 
					buttons:{Create:true, Cancel:false},
					overlayspeed : 1,
					opacity: 0.4,
					callback: function(v,m,f){
						if(v){	
						
				/*		jQuery.prompt(v +' ' + f.cname + f.cdescription);*/
						var myAjax = new Ajax.Request('../dbmodify.php?action=addCatInfo&cid='+index+'&level='+level+'&name='+f.cname+'&description='+f.cdescription,
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					results = response.responseText;
					jQuery.prompt(results, {
								  callback: function(){window.location.href = 'index.php?page=4';}
								  }
								  );
					
				}
			});
						
					}
					
					}});


}

function doDelCust(custID) {  
	
	var myAjax = new Ajax.Request(
			'../dbmodify.php?action=delCust&custID='+custID, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					jQuery(this).dialog('close');
					window.location="index.php?page=2&messagefeedback=Customer Has been Deleted";	
						
				}
			});	
}

function getCatInfo(level,cid) {  
		
	var myAjax = new Ajax.Request(
			'../dbread.php?action=getCatInfo&cid='+cid+'&level='+level, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: false,
				onComplete: function(response) {
				//	resarray = "hello";	
					result = response.responseText;
				    resarray = result.split("**SPLIT**",2);	
				}
			});
	return resarray;
}

function delCat(level) {
	
	if (level == 'parent') {
		txt = 'Are you sure you want to delete this Category? <br/> This will also delete any subcategories it might have.';
		var index = document.getElementById('catlist').options[document.getElementById('catlist').selectedIndex].value
	} else {
		txt = 'Are you sure you want to delete this Sub Category?';
		var index = document.getElementById('subcatlist').options[document.getElementById('subcatlist').selectedIndex].value
	}
	jQuery.prompt(txt, { 
			buttons:{Delete:true, Cancel: false},
			opacity: 0.4,
			focus: 1,
			overlayspeed : 'fast',
			callback: function(v,m,f){
			if(v){
				var myAjax = new Ajax.Request('../dbmodify.php?action=delCat&cid='+index+'&level='+level, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: true,
				onComplete: function(response) {
					results = response.responseText;
					jQuery.prompt(results, {
								  callback: function(){window.location.href = 'index.php?page=4';}
								  }
								  );
				}
			});
	
		 	}}});
}

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function updateSelect(cat_id,subcat_id) {
	
	// takes category code and return all subcats
	var myAjax = new Ajax.Request(
			'../dbread.php?action=updateSelect&cid='+cat_id+'&subcat_id'+subcat_id, 
			{
				method: 'get', 
				asynchronous: true,  
				parameters: '', 
				onFailure: function (response) {  
                   	alert('failed to grab list');},  
				onComplete: function(response) {
					$('subCatBox').update(response.responseText);
				}
			});	
}

function loadProducts() {
	
var id = getUrlVars()["id"];
var subid = getUrlVars()["subid"];
var searchit = getUrlVars()["search"];

	if ((id == null) && (subid == null)) {
		id = 9997;  // denotes show featured products
	}
	if (searchit != null) {
		id = '**SEARCH**'+searchit;
	}
	if (subid != null) {  // denotes show sub category
		id = '**SUBCAT**'+subid;
	}				
Event.observe(window, 'load', pageit('showProd',1,12,id,'main'), false);
}

function loadProducts() {

var id = getUrlVars()["id"];
var subid = getUrlVars()["subid"];
var searchit = getUrlVars()["search"];

	if ((id == null) && (subid == null)) {
		id = 9997;  // denotes show featured products
	}
	if (searchit != null) {
		id = '**SEARCH**'+searchit;
	}
	if (subid != null) {  // denotes show sub category
		id = '**SUBCAT**'+subid;
	}				
Event.observe(window, 'load', pageit('showProd',1,12,id,'main'), false);
}

function cart_StatUpdate() {
	
		var myAjax = new Ajax.Request(
				'dbmodify.php?action=cart_StatUpdate', 
				{
					method: 'get', 
					parameters: '', 
					asynchronous: true, 
					onComplete: function(response) {
						res = '<strong class="txt2 fleft"><a href="index.php?page=6&topic=cart">View Cart ('+response.responseText+')</strong>'+'&nbsp;<img src="_images/cart.png" width="15px"/></a><div class="clear"></div>';
						$('cart_Status').update(res);
					}		
				});	
	
}

function cart(id,action) {
	// this is the main Cart function
	
	switch (action) {
		case 'add':   //add items to cart
			var myAjax = new Ajax.Request(
				'dbmodify.php?action=cart_Add&id='+id, 
				{
					method: 'get', 
					parameters: '', 
					asynchronous: true,
					onLoading: function (response) {
              		$('cart_Feedback').update('<span class="loading"><img src="_images/loading.gif" title="Loading..." alt="Loading..." border="0" /></span>')},
					onFailure: function (response) {  
                  	 	alert('failed to add to cart, please try again');},  
					onComplete: function(response) {
						$('cart_Feedback').update('<strong><i class="txt3">Item Added</i></strong>');
						cart_StatUpdate();  // refresh cart status
					}		
				});	
		break;
		case 'remove':
		break;
		case 'checkout':
		break;
	}
}

function letmeknow(what) {  

	// send request to phpbb3 and change default language
	var myAjax = new Ajax.Request(
			'dbmodify.php?action=letmeknow&what='+what, 
			{
				method: 'get', 
				parameters: '', 
				asynchronous: false,
				onSuccess: function(response) {
					translate = response.responseText;
				}
			});	
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

// input field return to defaul

function remName(a, b){
if(a.value==b){
a.value='';
}else if(a.value==''){
a.value=b;
}else{
a.value=a.value;
}
}
 
function chkName(a, b){
if(a.value==''){
a.value=b;
}else{
a.value=a.value;
}
}

// input field return to default
