/*
********************************************************************************
Author	Name	:	Xyfosys Technologies
Script Name		:	scripts.js
Starting Date	:	17-September-2007
Last Modified	:	18-September-2007
********************************************************************************
*/


// Function open new window
function popBox(_url, _size, _scrolls, _resize)
{
	if(typeof _scrolls == 'undefined')
		_scrolls = 'no';
	if(typeof _resize == 'undefined')
		_resize = 'no';
	
	var _splits = _size.split('x');
	var _w = _splits[0];
	var _h = _splits[1];
	window.open(_url, 'popWin', 'width='+_w+', height='+_h+', resizable='+_resize+', alwaysRaised=yes, scrollbars='+_scrolls);
}



// Prompt comfirm
function confirms(_msg, _url, _isGo)
{
	var _go = _isGo?_isGo:false;
	var isOk = confirm(_msg, _url);
	if(isOk)
	{
		if(_go)
		{
			window.location.href = _url;
		}
		else
		{
			document.forms[0].action = _url;
			document.forms[0].submit();
			return true;
		}
	}
	else
	{
		return false;
	}
}


function wclose(_bool)
{
	var _bools = _bool?_bool:false;
	if(_bools)
	{
		window.opener.location = window.opener.location;
		window.close();
	}
	else
	{
		window.close();
	}
}




// Edit Vedio title
var editVContent = function(){
	var _obj = document.getElementById('_htid122');
	var _obj1 = document.getElementById('_htid11');
	var _strvalue = getInnerText(_obj);
	_obj1.innerHTML = '<input type="text" onBlur="updateContent1();" size="25" maxlength="200" name="heading" id="_heading1" value="'+_strvalue+'" />';
	document.getElementById('spanid1').innerHTML = '';
	document.getElementById('_heading1').focus();
}

// update title
var updateContent1 = function(){
	var _obj = document.getElementById('_heading1');
	_strv = _obj.value;
	_strv1 = _strv.replace(/#/g,'!8!');
	_strv2 = _strv1.replace(/@/g,'!%!');
	
	var postUrl = './ajax.php?wr=vediowrite&k='+_strv2;
	new AJAXRequest('get', postUrl, processContent1, true);
	var obj2 = document.getElementById('_htid11');
	obj2.innerHTML = '';
	document.getElementById('spanid1').innerHTML = '<b style="cursor:pointer;cursor:hand;" class="colorbox">Click Here to Edit Vedio Title</b>';
	setInnerText(document.getElementById('_htid122'), _obj.value);
}

// Process Content
var processContent1 = function(myAJAX){
	if(myAJAX.readyState == 4)
	{
		if(myAJAX.status == 200)
		{
			// Blank
		}
	}
}



// Edit title
var editContent = function(){
	var _obj = document.getElementById('_htid');
	var _strvalue = getInnerText(_obj);
	_obj.innerHTML = '<input type="text" onBlur="updateContent();" size="120" maxlength="200" name="heading" id="_heading" value="'+_strvalue+'" />';
	document.getElementById('spanid').innerHTML = '';
	document.getElementById('_heading').focus();
}

// update title
var updateContent = function(){
	var _obj = document.getElementById('_heading');
	_strv = _obj.value;
	_strv1 = _strv.replace(/#/g,'!8!');
	_strv2 = _strv1.replace(/@/g,'!%!');
	
	var postUrl = './ajax.php?wr=write&k='+_strv2;
	new AJAXRequest('get', postUrl, processContent, true);
	var obj = document.getElementById('_htid');
	obj.innerHTML = '';
	document.getElementById('spanid').innerHTML = '<b style="cursor:pointer;cursor:hand;" class="colorbox">Click Here to Edit Title</b>';
	setInnerText(obj, _obj.value);
}

// Process Content
var processContent = function(myAJAX){
	if(myAJAX.readyState == 4)
	{
		if(myAJAX.status == 200)
		{
			// Blank
		}
	}
}



// FF set textContent property
function setInnerText(obj, text)
{
	if(typeof obj.textContent == 'undefined')
	{
		obj.innerText = text;
  	}
	else
	{
		obj.textContent = text;
	}
}


// FF got textContent property instead
function getInnerText(obj)
{
	if(obj.innerText)
	{
  		return obj.innerText;
  	}
	else
	{
		return obj.textContent;
	}
}





// If IE
var ie = document.all;
// If NetScape
var ns6 = document.getElementById && !document.all;


function geObj(_id)
{
	return document.all?document.all[_id]:document.getElementById?document.getElementById(_id):'';
}


// Is true body
function ieTrueBody()
{
	return (document.compatMode && document.compatMode != 'BackCompat')?document.documentElement:document.body;
}


// Function to show tool tips
function addEditVideo(_id, _ids, _width)
{
	if(ie || ns6)
	{
		var tipObj = geObj(_id);
		_width = _width?_width:500
		
		var _tipDivs = '\
			<div style="position:absolute;width:'+_width+'px;border:4px solid #005984;">\
				<div id="videoid1" style="width:auto;background-color:#FFFFFF;padding:2px;"></div>\
			</div>';
		
		tipObj.innerHTML = _tipDivs;
		
		tipObj.style.left = '400px';
		tipObj.style.top = '80px';
		ajaxpage('vdo.php?ids='+_ids, 'videoid1');
	}
}

// Function to hide tips
function hideTips(_id)
{
	if(ie || ns6)
	{
		var tipObj = geObj(_id);
		
		tipObj.innerHTML = '';
		tipObj.style.left = '-1000px';
	}
}

// Submit form
var fgoto = function(_url){
	window.location = _url;
}