
/*
 * FAQ Call Back v. 1.0 © 2006 Dotality (www.dotality.com)
   							pan = HttpContext.Current.Request("pan")
                GroupsMode = HttpContext.Current.Request("Gm")
                GroupsSort = HttpContext.Current.Request("Gs")
                GroupsLimit = HttpContext.Current.Request("Gl")
                QuestionsMode = HttpContext.Current.Request("Qm")
                QuestionsGroup = HttpContext.Current.Request("Qg")
                QuestionsSort = HttpContext.Current.Request("Qs")
                QuestionsLimit = HttpContext.Current.Request("Ql")
                QuestionsKeyWord = HttpContext.Current.Request("Qk")
                Answermode = HttpContext.Current.Request("Am")
                Affiliate = HttpContext.Current.Request("aff")
                sel_cat = HttpContext.Current.Request("sG")
                sel_quest = HttpContext.Current.Request("sQ")
                sel_answ = HttpContext.Current.Request("sA")
                limit = HttpContext.Current.Request("lim")
 - call menufunc with link
 - splitlink for aj_
 - if aj_ exist in link search for div
 	- if div exist check if ajax is supported
 		- if ajax is supported inisiate callback
else call real link
 	
 */
 var faqUrl = 'http://localhost/project4/a_faq.aspx' // //URL of FAQ handler
 var Gm = 2 //Group Mode
 var Gs = 't' //Group Sort: t-title; p-priority ; i-id
 var Gl = '' // Goup Limit (limit how many Group titles will be listed)
 var Qm = 1 //Questions Mode
 
 var FAQcatDIV = 'FAQcatDIV';
 var typed;
 var ajlinkprefix = 'aj_'


function getFAQcat(pars) {
	var myAjax = new Ajax.Request(faqUrl,{method: 'get', parameters: pars, onComplete: showFAQcat	});
}

function showFAQcat(mainResponse) {
	var finalcontent = cleanContent(mainResponse.responseText, 'div', true);
	//alert(finalcontent);
	//return finalcontent;
	//return 'gfjhdfgh';
	$(FAQcatDIV).innerHTML = finalcontent;
}


function cleanContent(content, tag, onlyInside)	{
	//alert(content);
	nFragment_1_start = content.toLowerCase().indexOf("<"+tag.toLowerCase(),0);
	nFragment_1_end = content.toLowerCase().lastIndexOf("</"+tag.toLowerCase(),content.length)+tag.length+3;
	content = content.substring(nFragment_1_start,nFragment_1_end-nFragment_1_start);
	if (onlyInside) {
		nFragment_2_start = content.toLowerCase().indexOf(">",0)+1;
		nFragment_2_end = content.toLowerCase().lastIndexOf("<",0);
		content = content.substring(nFragment_2_start,content.length-nFragment_2_start-nFragment_2_end);
	//alert(content);
	}
	//put returned XML in the textarea
	return content;
	//return '</form><form>'+content;
}

function toggle(o) {var e = document.getElementById(o);e.style.display = e.style.display == 'block' ? 'none' : 'block';return false;}


function go2(linkurl,linkid,linkcssOFF,linkcssON) {
//				document.location.href = linkurl;
//				return;
	if (linkid) {
		flipclass(linkid,linkcssOFF,linkcssON)
	}	
	//alert(editfields);
	var indexx = linkurl.indexOf('?');
//	var params = new Array();
	if (editfields) {if ( editfields == 1 ) { document.location.href = linkurl; return; }}
	if ( indexx != -1 ) {
		var nameValuePairs=linkurl.substring(indexx+1,linkurl.length).split('&');
		for ( var i=0; i<nameValuePairs.length; i++ ) {
			nameVal = nameValuePairs[i].split('=');
			if (nameVal[0].substring(0,ajlinkprefix.length) != ajlinkprefix ) {
				document.location.href = linkurl;
				return;
			}
		}
		for ( var i=0; i<nameValuePairs.length; i++ ) {
			nameVal = nameValuePairs[i].split('=');
			if (nameVal[0].substring(0,ajlinkprefix.length) == ajlinkprefix ) {
				divname = nameVal[0].substring(ajlinkprefix.length,nameVal[0].length);
				docurl = document.location.href;
				if (docurl.indexOf('?') != -1 ) { docurl = docurl.substring(0,docurl.indexOf('?'));}
				ajparam = 'ajx_'+divname+'='+nameVal[1];
				cburl = docurl+'?ajx_'+divname+'='+nameVal[1];
				//alert(document.getElementById(divname+'_ajxdiv'));
				if ($(divname+'_ajxdiv') == null ) {
					document.location.href = linkurl;
					return;
				}
				//new Ajax.Updater(divname+'_ajxdiv', docurl, {method: 'get', parameters: ajparam	});
				new Ajax.Updater(divname+'_ajxdiv', '_inc/'+nameVal[1], {method: 'get'});
		}
		
//			params[nameVal[0]] = nameVal[1];
		}
	} else { document.location.href = linkurl; return;}
}



function ShowDiv(divid){
   if (document.layers) document.layers[divid].visibility="show";
   else document.getElementById(divid).style.visibility="visible";}

function HideDiv(divid){
   if (document.layers) document.layers[divid].visibility="hide";
   else document.getElementById(divid).style.visibility="hidden";}

function BodyLoad(){
    HideDiv("autocomplete");
    document.form1.keyword.focus();}

function SugestClick(newvalsug,pid) {
	document.getElementById(pid).value = newvalsug;
//  HideDiv("cb_"+pid);
}




// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="popin_TM"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="popin_TM"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}


function faqShowQA(Aid,xM,yM){
  if ($(Aid+'_c')) {
  	$('popin_title').innerHTML = $(Aid+'_t').innerHTML;
  	$('popin_content').innerHTML = $(Aid+'_c').innerHTML;
  	if (xM == -1) xM=Math.round((xMousePosMax/2)-200);
  	if (yM == -1) yM=Math.round((yMousePosMax/2)-150);
  	if (xM == undefined) {xM=xMousePos;}
  	if (yM == undefined) yM=yMousePos;
	  if (isIE||isNN) {
  	//alert('xM= '+xM);
  	//alert('whichDog.style.left= '+whichDog.style.left);
	  	if (whichDog.style.visibility=="hidden") {
		  		whichDog.style.visibility="visible";
					whichDog.style.left=xM;
					whichDog.style.top=yM;
				}
	  	}
	  else if (isN4) {
	  		document.theLayer.visibility="show";
				document.theLayer.left=xMousePos
				document.theLayer.top=yMousePos
			}
	}
}
function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) {
  		whichDog.style.visibility="visible";
  		if (whichDog.style.left=="300px"){
				whichDog.style.left=xMousePos;
				whichDog.style.top=yMousePos;
			}
  	}
  else if (isN4) {
  		document.theLayer.visibility="show";
			document.theLayer.left=xMousePos
			document.theLayer.top=yMousePos
		}
}

function toggleMe() {
	//alert(whichDog.style.left);
  if (isIE||isNN) {
  	if (whichDog.style.visibility=="hidden") {
  		whichDog.style.visibility="visible";
  		if (whichDog.style.left=="400px"){
				whichDog.style.left=xMousePos;
				whichDog.style.top=yMousePos;
			}
  	}
  	else {whichDog.style.visibility="hidden";}
  }
  else if (isN4) {
  	if (document.theLayer.visibility=="hide") {
  		document.theLayer.visibility="show";
			document.theLayer.left=xMousePos
			document.theLayer.top=yMousePos
		}
  	else {document.theLayer.visibility="hide";}
  }
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");



////drag drop functions end here//////

function hidebox(e){
	if (ie4||ns6)
	crossobj.style.visibility="hidden"
	else if (ns4)
	document.e.visibility="hide"
}


function showbox(divobj){

	if (ie4||ns6){
	//if crossobj.style.visibility="visible" {
	//	hidebox() }
	crossobj.style.visibility="visible"
	crossobj.style.left=xMousePos
	crossobj.style.top=yMousePos
	//alert(locateobj.offsetx);
	//alert(xMousePos)
	}
	else if (ns4){
	document.quickadd.visibility="show"
	document.quickadd.left=xMousePos
	document.quickadd.top=yMousePos
	}
}

// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}
