
/*

Svn id ramkumar_071at09

*/


/* Product content action */
var gID;
var gPage;
var gStatus;
function mFunAboutProduct(url,id,status,URLSegment){
	if (document.getElementById('ContentContainer'))
		document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';	
	gStatus = status;
	if (id !='')
	{
		listClass();
		if (document.getElementById(id))
			document.getElementById(id).className = 'current';  	
	}
	if ((status != '') && (status != undefined)){
		document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
		if (document.getElementById('idFeaturedTemplate'))
			document.getElementById('idFeaturedTemplate').style.display = 'none';
		if (status == 2)
		{
			  var mytool_array=url.split("/");
			  var headID = document.getElementsByTagName("head")[0];         
			  var newScript = document.createElement('script');
			  newScript.type = 'text/javascript';
			  if (mytool_array[0] != '')
			  	urlval = mytool_array[0]+'/'+mytool_array[1]+'JS/'+mytool_array[2]+ '/' + mytool_array[3];
			  else
			  	urlval = mytool_array[1]+'/'+mytool_array[2]+'JS/'+mytool_array[3]+ '/' ;
			  newScript.src = urlval;
			  headID.appendChild(newScript);
			  gID = mytool_array[2];
			  gPage = mytool_array[3];
		}	
	}
	else{
		if (document.getElementById('idFeaturedTemplate'))
			document.getElementById('idFeaturedTemplate').style.display = 'block';		

	}

	pars = url;
	var myAjax = new Ajax.Request(
	url,
	{
	method: 'POST',
	parameters: pars,
	onLoading: setLoadingStatus('idProductPageRight'),	
	onSuccess: process,
	onFailure: function() { 
		alert("There was an error with the connection"); 
	}
	
	});
	if (status != '')
		location.hash = 'product';	
	return false;	

}

function process(transport) {
  var response = transport.responseText;
  document.getElementById('idProductPageRight').innerHTML = response;
  if (document.getElementById('idBottomTemplateDiv'))
  {
	document.getElementById('ContentContainer').className = 'clsContentContainer';
  }
  else
  {
	  document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
  }  
  if ( gStatus == 2 ){
	setTimeout(initTemplatePreview(),100);
  }
}
function listClass()
{
var ul = document.getElementById("ullist");
var li = ul.getElementsByTagName("li");
	for( var i = 0; i < li.length; i++ )
	{
		atag  = li.item(i).getElementsByTagName("a");
		if (atag.item(0).className == 'current')
		{
			atag.item(0).className = 'link'
		}
		
	}

}
function mFunProduct(url,id,last){
	document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
	if (id !='')
	{
		listOnlyClass(last);
		if (document.getElementById(id)){
			if (last != '')
				document.getElementById(id).className = 'current CurrentLast';
			else
				document.getElementById(id).className = 'current';
		}
	}
	if (document.getElementById('idFeaturedTemplate'))
		document.getElementById('idFeaturedTemplate').style.display = 'block';		
	pars = url;
	var myAjax = new Ajax.Request(
	url,
	{
	method: 'POST',
	parameters: pars,
	onLoading: setLoadingStatus('ProductPageContent'),
	onSuccess: processContent,
	onFailure: function() { 
		alert("There was an error with the connection"); 
	}
	
	});
	return false;	

}

function processContent(transport) {
  var response = transport.responseText;
  document.getElementById('ProductPageContent').innerHTML = response;
  if (document.getElementById('idBottomTemplateDiv'))
  {
	document.getElementById('ContentContainer').className = 'clsContentContainer';
  }
  else
  {
	  document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
  }
  

}
function onProcessContent(){
	
}

function listOnlyClass(last)
{

var ul = document.getElementById("ultop");
var li = ul.getElementsByTagName("li");
	for( var i = 0; i < li.length; i++ )
	{
		if ((li.item(i).className == 'current') || (li.item(i).className == 'section'))
		{
			li.item(i).className = 'link';
		}
		else if ((li.item(i).className == 'current CurrentLast') || (li.item(i).className == 'section CurrentLast'))
		{
			li.item(i).className = 'link last';
		}
		
	}

}


function setLoadingStatus(loadingdiv)
{
if( $(loadingdiv) )
	{
		$(loadingdiv).innerHTML='<p class="clsLoding"><img src="themes/rayzz/images/loading.gif" /> <br/><span style="color:#DD6C34">Loading..</span></p>';
	}
}


function mFunTemplateProduct(url,id,status,URLSegment){
	if (document.getElementById('ContentContainer'))
		document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';	
	gStatus = status;
	if (id !='')
	{
		listClass();
		if (document.getElementById(id))
			document.getElementById(id).className = 'current';  	
	}
	if ((status != '') && (status != undefined)){
		document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
		if (document.getElementById('idFeaturedTemplate'))
			document.getElementById('idFeaturedTemplate').style.display = 'none';
		if (status == 2)
		{
			  var mytool_array=url.split("/");
			  var headID = document.getElementsByTagName("head")[0];         
			  var newScript = document.createElement('script');
			  newScript.type = 'text/javascript';
			  if (mytool_array[0] != '')
			  	urlval = mytool_array[0]+'/'+mytool_array[1]+'JS/'+mytool_array[2]+ '/' + mytool_array[3];
			  else
			  	urlval = mytool_array[1]+'/'+mytool_array[2]+'JS/'+mytool_array[3]+ '/' ;
			  newScript.src = urlval;
			  headID.appendChild(newScript);
			  gID = mytool_array[2];
			  gPage = mytool_array[3];
		}	
	}
	else{
		if (document.getElementById('idFeaturedTemplate'))
			document.getElementById('idFeaturedTemplate').style.display = 'block';		

	}

	pars = url;
	var myAjax = new Ajax.Request(
	url,
	{
	method: 'POST',
	parameters: pars,
	onLoading: setLoadingStatus('ProductPageContent'),	
	onSuccess: templateprocess,
	onFailure: function() { 
		alert("There was an error with the connection"); 
	}
	
	});
	if (status != '')
		location.hash = 'product';	
	return false;	

}

function templateprocess(transport) {
  var response = transport.responseText;
  document.getElementById('ProductPageContent').innerHTML = response;
  if (document.getElementById('idBottomTemplateDiv'))
  {
	document.getElementById('ContentContainer').className = 'clsContentContainer';
  }
  else
  {
	  document.getElementById('ContentContainer').className = 'clsContentContainer clsNoWebtemplate';
  }  
  if ( gStatus == 2 ){
	setTimeout(initTemplatePreview(),100);
  }
}