// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function myToggle() {
	for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}

/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(set,num,numelems,opennum,animate,swfPath) {
	if (document.getElementById("testimonialContent")){
		if (document.getElementById("testimonialContent").nodeName == "object"){
			var mydoc = document.getElementById("testimonialContent").parentNode;
			swfobject.removeSWF("testimonialContent");
			mydoc.innerHTML = "<div id='testimonialContent'>test</div>";
		}else if (document.getElementById("commercialContent").nodeName == "object"){
			var mydoc = document.getElementById("commercialContent").parentNode;
			swfobject.removeSWF("commercialContent");
			mydoc.innerHTML = "<div id='commercialContent'>test</div>";
		}		
	}
   if ($('tabContent'+num+set).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i+set;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive'+set.toUpperCase()); // may need a set designator
                    h.id = temph;
                }
                var tempc = 'tabContent'+i+set;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'slide',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num+set);
        if (h)
            h.id = 'tabHeaderActive'+set.toUpperCase();
        h.blur();
        var c = $('tabContent'+num+set);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num+set,'slide',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num+set);
        }
    }
	if (swfPath){
		// alert("swfPath is not empty");
		if (num == 1){
			swfobject.embedSWF(swfPath,'testimonialContent','322','250','9.0.0',{},{},{bgcolor:'#000000'}); //'340','260'
		}else{
			swfobject.embedSWF(swfPath,'commercialContent','322','261','9.0.0',{},{},{bgcolor:'#000000'});
		}
	}
}
	

function addText(newtext,tagId) {
	oldtext = document.myForm.tagsForArticle.value; // text that already exists in the form
	if (oldtext.indexOf(newtext) < 0) { // looks for the new tag clicked on in the oldtext
		document.myForm.tagsForArticle.value += newtext; // adds the new tag to the oldtext
		document.getElementById(tagId).className="used";
	}else{
		document.myForm.tagsForArticle.value = oldtext.replace(newtext,"");
		document.getElementById(tagId).className="none";
	}
}

// ADD VARIABLES AS NEEDED BY OTHER SCRIPTS


