// JavaScript Document

function LTrim(str){
	if (str==null){return null;}
	for(var i=0;str.charAt(i)==" ";i++);
	return str.substring(i,str.length);
}
function RTrim(str){
	if (str==null){return null;}
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
}
function Trim(str){
	return LTrim(RTrim(str));
}

/* Update 11/08/2009 */
function search_products(GcatID){
	var Vsearch	= $('TxtSearch').value;
	if(Trim(Vsearch)=='')
	{
		$('TxtSearch').style.cssText = "background-color:#f9a6b7;border:1px solid #e3e3e3;color:#FFFFFF;";
		$('TxtSearch').focus();
	}else{
		var CatID		=	Trim(GcatID);
		var VCatID	= (parseInt(CatID) == 0)?'':'&category_id='+parseInt(CatID);
		Vsearch		=	Vsearch.replace("-", "~");
		window.location='/CT0-Category-Product all-1-'+Vsearch+'.html';
	}
}

/* Update 13/10/2009 */
function searchKeyPress(e,GcatID)
{
                // look for window.event in case event isn't passed in
                if (window.event) { e = window.event; }
                if (e.keyCode == 13)
                {
                       search_products(GcatID)
					   // document.getElementById('btnSearch').click();
                }
}

/* Update21/12/2009 */
function switch2value(vel1,vel2,type)
{
	//update 2/9/2011
	//if (confirm("Are you sure you wish to continue?")){
	
		 switch(type)
		 {
			case 'textbox':
				$(vel2).value = $(vel1).value;
			break;
			case 'texteditor':
				tinyMCE.get(vel2).setContent('');
				tinyMCE.execInstanceCommand(vel2,'mceInsertContent',false,tinyMCE.get(vel1).getContent());
			break;
			case 'textcount':
				$(vel2).value = $(vel1).value;
				limiter();
		   		Elimiter();
			break;
		 }
	//}
}

/* * * * Update 31/05/2010 :: Popup in prototype.js use wiht VDO Help&Support * * * */
/* http://jehiah.cz/archive/prototype-powered-popup-script */
var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 680,
      height: 570,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"no",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}

// Disable "copy and paste"  ( Update 16 / 7 / 2010 )
function disableSelection(target)
{
	if (typeof target.onselectstart!="undefined") //IE route

		target.onselectstart=function(){return false}

	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route

		target.style.MozUserSelect="none"

	else //All other route (ie: Opera)

		target.onmousedown=function(){return false}
		target.style.cursor = "default"
}
// Disable "copy and paste"  ( Update 16 / 7 / 2010 )

