anilMathewM.prototype.menu=function(){};
anilMathewM.prototype.menu.createHolder=function(){
	var string='<div style="position: absolute;z-index:1000001;top:0px;left:0px;border:5px solid #EBEBEB;text-align:center;height:auto;" id="menu_df">menu</div>';
	$('body').append(string);
}

anilMathewM.prototype.menu.int=function(){
	anilMathewM.prototype.menu.createHolder();
}
anilMathewM.prototype.menu.AutoHideCurrentMenu=false;
anilMathewM.prototype.menu.menus={};
anilMathewM.prototype.menu.menuprf={};
anilMathewM.prototype.menu.createMenu=function(name,autoHide){
	anilMathewM.prototype.menu.menus[name]=[];
	anilMathewM.prototype.menu.menuprf[name]={};
	if(autoHide==true){
		anilMathewM.prototype.menu.menuprf[name].autoHide=true;
	}else{
		anilMathewM.prototype.menu.menuprf[name].autoHide=false;
	}
}

anilMathewM.prototype.menu.addMenuItem=function(name,itm){
anilMathewM.prototype.menu.menus[name].push(itm);
}
anilMathewM.prototype.menu.showMenu=function(name,pos){
	anilMathewM.prototype.menu.AutoHideCurrentMenu=anilMathewM.prototype.menu.menuprf[name].autoHide;
	var appHeight=$(pos).height();
	var copy=anilMathewM.prototype.menu.menus[name];
	var tstr="";
	for($i=0;$i<copy.length;$i++){
		tstr +="<div>"+copy[$i]+"</div>";
	}
	$('#menu_df').html(tstr);
	var posd=anilMathewM.editEngine.getAbsolutePosition(pos);
	//alert(posd.x+"-"+$('body').width()+":"+$('#menu_df').width());
	//alert(posd.x+$('#menu_df').width()>$('body').width());
	//alert(Number(posd.x+$('#menu_df').width())+":"+Number($('body').width()));
	if(posd.x+$('#menu_df').width()>$('body').width()){
		posd.x=posd.x-$('#menu_df').width();
	}else{
		posd.x=posd.x-$('#menu_df').width()/2
	}
	$('#menu_df').css('top',(posd.y+appHeight+5)+"px");
	$('#menu_df').css('left',posd.x+"px");

	$('#menu_df').show(150);
}
anilMathewM.prototype.menu.hideMenu=function(){
	$('#menu_df').hide(150);
}
$(document).click( function() { if(anilMathewM.prototype.menu.AutoHideCurrentMenu==false){$('#menu_df').hide();} } );

$(document).ready(function() { 
	anilMathewM.prototype.menu.int();
	$('#menu_df').hide();
	///
	$('#menu_df').css('widht',"100px");
	anilMathewM.prototype.menu.createMenu("newplaylistmenu",true);
	anilMathewM.prototype.menu.addMenuItem('newplaylistmenu','<table cellpadding="0" cellspacing="0" border="0" align="center" style="padding:0px" width="209">	<tr><td align="right" colspan="2" bgcolor="#BBE9FF"><a href="javascript:anilMathewM.prototype.menu.hideMenu()" style="text-decoration: none"><b>X</b></a>&nbsp;&nbsp;</td></tr> </table>');
	anilMathewM.prototype.menu.addMenuItem('newplaylistmenu','<table cellpadding="0" cellspacing="0" border="0" align="center" style="padding:3px" width="209">	<tr>	<td><input type="text" id="new_plist" name="new_plist" style="color:#91C8FF;border:solid 1px #CAEEFF"/></td><td><input type="button" value="Add" style="color:#D5EAFF;border:solid 1px #CAEEFF;background-color:#BBF1FB;color:black" onclick="return newPlayList()"/></td></tr> </table>');
	/////
	anilMathewM.prototype.menu.createMenu("signup",true);
	anilMathewM.prototype.menu.addMenuItem('signup','<table cellpadding="0" cellspacing="0" border="0" align="center" style="padding:0px" width="360">	<tr><td align="right" colspan="2" bgcolor="white"><a href="javascript:anilMathewM.prototype.menu.hideMenu()" style="text-decoration: none"><b>X</b></a>&nbsp;&nbsp;</td></tr> </table>');
	anilMathewM.prototype.menu.addMenuItem('signup',$('#form_hidden').html());
	$('#form_hidden').remove();

	anilMathewM.prototype.menu.createMenu("login",true);
	anilMathewM.prototype.menu.addMenuItem('login','<table cellpadding="0" cellspacing="0" border="0" align="center" style="padding:0px" width="250">	<tr><td align="right" colspan="2" bgcolor="white"><a href="javascript:anilMathewM.prototype.menu.hideMenu()" style="text-decoration: none"><b>X</b></a>&nbsp;&nbsp;</td></tr> </table>');
	anilMathewM.prototype.menu.addMenuItem('login',$('#form_hidden2').html());
	$('#form_hidden2').remove();


}); 

