/*========================================================================*\
|| ###################################################################### ||
|| # Copyright © 2002 - 2008 Reuter & Bloeß GbR.                          ||
|| # http://www.vbdesigns.de | http://www.vbdesigns.de/license.html     # ||
|| ###################################################################### ||
\*========================================================================*/

var vbcms_divslide  = null;
var vbcms_divheight = null;
var vbcms_ajaxobj   = null;

/**
* Ajax Class
*
* @param	string	GET or POST
* @param	boolean	asyncron
*/
function vBCMS_AJAX(type, asyncron)
{
        this.type       = type;
        this.asyncron   = asyncron;
        
        if(this.type == 'GET')
        {
                this.headeroveride = true;
        }
}

/**
* Check that ajax available an set the XMLHttpRequest or ActiveXObject
*
* @return	mixed
*/
vBCMS_AJAX.prototype.check = function()
{
        if(typeof XMLHttpRequest != 'undefined')
        {
                this.request = new XMLHttpRequest();
                if(this.request.overrideMimeType && this.headeroveride) 
                {
                        this.request.overrideMimeType('text/xml');
                }        
                return true;
                
        }else if(ActiveXObject){
                try{
                        this.request = new ActiveXObject("Msxml2.XMLHTTP");
                }catch(e){
                        try{
                                this.request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch(e){
                                return false;
                        }
                }
                return true;
        }else{
                return false;
        }
}

/**
* Set the onreadystatechange
*
* @param	string the function name
* @return	mixed
*/
vBCMS_AJAX.prototype.onreadystatechange = function(name)
{
        if(!this.request)
        {
                return false;
        }
	if(typeof name == 'function')
	{
		this.request.onreadystatechange = name;
	}else{
		alert('onreadystatechange parameter ' + name + ' is not a function');
	}
	return false;        
}

/**
* Send the ajax request
*
* @param	string url
* @param	string datas
* @return	mixed
*/
vBCMS_AJAX.prototype.send = function(url, data)
{
	if(!this.request)
	{
	        return false;
	}

	this.request.open(this.type, url, this.asyncron);
	if(!this.headeroveride)
	{
		this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	}
	this.request.send(data);
	if(!this.asyncron && this.request.readyState == 4 && this.request.status == 200)
	{
		return true;
	}
	return false;
}

/**
* Send the ajax request
*
* @param	string datas
* @return	mixed
*/
vBCMS_AJAX.prototype.tag_array = function(tag)
{
	if(!this.request.responseXML)
	{
	        return false;
	}
        return this.request.responseXML.getElementsByTagName(tag);
}

/**
* Fetches the contents of an XML node
*
* @param	object	XML node
*
* @return	string	XML node contents
*/
vBCMS_AJAX.prototype.return_data = function(tag)
{	
	return tag.firstChild.nodeValue;
}

/**
* Fetch the selected text of the document
*
* return mixed
*/
function vBCMS_getselectedtext()
{
         if(window.getSelection)  
         {
                 return window.getSelection();
                 
         }else if(document.getSelection){
         
                 return document.getSelection();
                 
         }else if(document.selection) {
         
                 return document.selection.createRange().text;
         }
         return false;
}



function vBCMS_slidediv(id, speed, value)
{
        if(document.getElementById) 
        {
                var vbcms_divelm = document.getElementById(id);
                
                if(vbcms_divelm.style.visibility == 'visible')
                {
                        console.log('hide' + id);
                        var Y = Math.floor(vbcms_divheight / speed);
                        var pos = 1;
                        var posY = vbcms_divheight;
                        
                }else{
                console.log('slide' + id);
                        vbcms_divelm.innerHTML = value;
                        if(!vbcms_divheight)
                        {
                                vbcms_divheight = vbcms_divelm.offsetHeight;
                        }
                        
                        vbcms_divelm.style.overflow = 'hidden';
                        vbcms_divelm.style.visibility = 'visible';
                        
                        var pos = 2;
                        var posY = 0;
                        var Y = Math.ceil(vbcms_divheight  / speed);
	        
                }               
                
                sliding(id, posY, Y, vbcms_divheight, pos, speed); 
        }
}

function vbcms_check_hides()
{
	var left = document.getElementById('collapseobj_vbcms_table_left');
	var right = document.getElementById('collapseobj_vbcms_table_right');

	if (left && right)
	{
		if((left.style.display == 'none' && right.style.display == 'none'))
		{
			document.getElementById('col3').style.margin = '0 0 0 0';
			document.getElementById('col3p').style.padding = '0 0 0 0';			
		} 
		else if(left.style.display == 'none')
		{
			document.getElementById('col3').style.margin = '0 ' + vbcms_right_colum + ' 0 0';
			document.getElementById('col3p').style.padding = '0 10px 0 0';	
		}
		else if(right.style.display == 'none')
		{
			document.getElementById('col3').style.margin = '0 0 0 ' + vbcms_left_colum;
			document.getElementById('col3p').style.padding = '0 0 0 10px';			
		}
	}
	else if (left && !right)
	{
		if(left.style.display == 'none')
		{
			document.getElementById('col3').style.margin = '0 0 0 0';
			document.getElementById('col3p').style.padding = '0 0 0 0';		
		}
		else
		{
			document.getElementById('col3').style.margin = '0 0 0 ' + vbcms_left_colum;
			document.getElementById('col3p').style.padding = '0 0 0 10px';	
		}	
	}
	else if (!left && right)
	{
		if(right.style.display == 'none')
		{
			document.getElementById('col3').style.margin = '0 0 0 0';
			document.getElementById('col3p').style.padding = '0 0 0 0';		
		}
		else
		{
			document.getElementById('col3').style.margin = '0 ' + vbcms_right_colum + ' 0 0';
			document.getElementById('col3p').style.padding = '0 10px 0 0';			
		}	
	}
	else
	{
		document.getElementById('col3').style.margin = '0 0 0 0';
		document.getElementById('col3p').style.padding = '0 0 0 0';		
	}
}

function vbcms_table(pos)
{
	var left = document.getElementById('collapseobj_vbcms_table_left');
	var right = document.getElementById('collapseobj_vbcms_table_right');
	
 	switch(pos)
 	{
 		case 'left': 
 		{
 		
 			if(left.style.display == 'none')
 			{
 				document.getElementById('col3').style.marginLeft = '0';
 				document.getElementById('col3p').style.paddingLeft = '0';
 			}
 			else
 			{
 				document.getElementById('col3').style.marginLeft = vbcms_left_colum;
 				document.getElementById('col3p').style.paddingLeft = '10px';
 			}
 		}
 		break;
 		case 'right':
 		{
 			if(right.style.display == 'none')
 			{
 				document.getElementById('col3').style.marginRight = '0';
 				document.getElementById('col3p').style.paddingRight = '0';
 			}
 			else
 			{
 				document.getElementById('col3').style.marginRight = vbcms_right_colum;
 				document.getElementById('col3p').style.paddingRight = '10px';
 			}	
 		}
 		break;
	}
}

function change_elm(elm)
{
	switch(elm)
	{
		case 'vbcmsarea_content':
		{
			document.getElementById('c_do').value = 'results';
			document.getElementById('c_area').value = elm;
			document.getElementById('c_show').value = '';
		}
		break;
		case 'vbcmsarea_links':
		case 'vbcmsarea_products':
		{
			document.getElementById('c_do').value = 'search';
			document.getElementById('c_area').value = elm;
			document.getElementById('c_show').value = 'results';
		}
		break;
		case 'forum':
		{
			document.getElementById('c_forum').action = vbcms_forumfolder + '/search.php?do=process';
			document.getElementById('c_do').value = 'process';
		}
		break;		
	}
	return false;
}

function sliding_(id, posY, Y, max, pos, over, divoverflow, divoverflowmoz)
{
        var elm = document.getElementById(id);
        var ie = Math.ceil(100 / over);
        var moz = 1 / over;

	if(pos == 2)
	{
	        if(posY <= max)
	        {      
	                if(!divoverflow)
		        {
		                divoverflow=divoverflowmoz=null;
                        }
	        
	                divoverflow += ie;
                        divoverflowmoz += moz;
                        posY += Y;
		        elm.style.height = posY+"px";
		        elm.style.filter = "alpha(style=0,opacity=" + divoverflow + ");";
		        elm.style.opacity = divoverflowmoz;
		        
		        vbcms_divslide = setTimeout("sliding('" + id + "', " + posY + ", " + Y + ", " + max + ", " + pos + ", " + over + ", " + divoverflow + ", " + divoverflowmoz + ")", 10);
	        }else{
	                elm.style.height = max+"px";
		        clearTimeout(vbcms_divslide);
	        }
	        
	}else{
	        if((posY - Y) > 0)
	        {    
	                if(!divoverflow)
		        {
		                divoverflow=100;
		                divoverflowmoz=1;
                        }
	        
	                divoverflow -= ie;
                        divoverflowmoz -= moz;
                        
                        posY -= Y;
		        elm.style.height = posY+"px";
		        elm.style.filter = "alpha(style=0,opacity=" + divoverflow + ")";
		        elm.style.opacity = divoverflowmoz;
		        vbcms_divslide = setTimeout("sliding('" + id + "', " + posY + ", " + Y + ", " + max + ", " + pos + ", " + over + ", " + divoverflow + ", " + divoverflowmoz + ")", 10);
	        }else{
	                elm.style.height = '0px';
	                
	                elm.style.visibility = 'hidden';
			
	                clearTimeout(vbcms_divslide);
	        }
	}
	
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 14:52:37 12.01.2010
|| # SVN: $RCSfile$ - $Revision: $
|| ####################################################################
\*======================================================================*/