// Common Javascript

var baseUrl = 'http://localhost/i-am-tutor/';

function CheckShiftKey_in_Lightbox(e)
{
    if(!e) e = window.event;      
    if(e.shiftKey)
    {
        alert('shiftKey');
        return true;
    }  
}

/*
function showloading()
{
    //show loading
    $('loading').show();   
}

function hideloading()
{ 
    //hide loading
    $('loading').hide();   
}       

function pausecomp(millis)
{
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

*/
function gotoajax(e,myform,target)
{    
   // showloading() ;
    
    var param  = new Array();  
    for(var i=0;i< myform.elements.length; i++)
    {
        if(myform.elements[i].type != "radio" || myform.elements[i].checked) {
        param[i] = new Array(2);        
        param[i][0]  =  myform.elements[i].name;  
        param[i][1]  =  myform.elements[i].value  ;
        }
    }
    var url_action = myform.action;
    new Ajax.Request(url_action, {
      method: 'post',
      parameters: { 
        myparam : param.toJSON()
      },
      onSuccess: function(transport) {
            $(target).innerHTML = transport.responseText;       
        }

     });

   //    hideloading() ; 
      return false;     
    
}

function callajax(url,target)
{    
	$('loading').show();
    new Ajax.Request(url, {
      method: 'post',
      onSuccess: function(transport) {
            $(target).innerHTML = transport.responseText; 
           //alert('success');    
		   
        }
     });
     //alert('exit');

	 $('loading').hide();
     return false;     
}

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}


// use
//javascript:displayHTML($('panel').innerHTML,$('map').innerHTML); 
function displayHTML(x,y) {
var inf = '<table width="800"><tr><td width="600">'+y+'</td><td width="400">'+x+'</td></tr></table>';


var win = window.open("print.htm", 'popup', 'toolbar = no, status = no');
win.document.write(inf);
win.document.close(); // new line
}

document.getElementById('button1').style.display = "none";
function image_submit(action)
{
    if(action == 'over')
    {
        document.getElementById('button2').style.display = "none";
        document.getElementById('button1').style.display = "inline";
    }
    else if(action == 'out')
    {
        document.getElementById('button2').style.display = "inline";
        document.getElementById('button1').style.display = "none";
    }
}

function submit()
{
    
    var what = $('what').value.replace(" ", "-");
        what = what.replace("+", "-");
        
    var where = ($('where').value).replace(" ", "-");
        where = where.replace("+", "-");
    $('searchform').action =  $('searchform').action + what + "/" + where;
    window.location = $('searchform').action;     
}