//
// Javascript for Project Foodie Recipe Saving
//

// Create a link to save a recipe from the Mercury News website
function MNSaveRecipe()
{
  thisURL = location.href;
  mnGUID = "";

  var regex = /ci_(\d+).*/;
  if ( regex.test( thisURL ) ) {
    mnGUID = RegExp.$1;
  } 
	
  SaveRecipe( mnGUID, "MN");
}


function CCSaveRecipe()
{
  thisURL = location.href;
  ccGUID = "";

  var regex = /ci_(\d+).*/;
  if ( regex.test( thisURL ) ) {
    ccGUID = RegExp.$1;
  } 
	
  SaveRecipe( ccGUID, "CC");

}


function IBASaveRecipe()
{
  thisURL = location.href;
  GUID = "";
  
  var regex = /ci_(\d+).*/;
  if ( regex.test( thisURL ) ) {
    GUID = RegExp.$1;
  } 

  SaveRecipe( GUID, "IBA");

}



function MHSaveRecipe()
{
  thisURL = location.href;
  GUID = "";

  var regex = /ci_(\d+).*/;
  if ( regex.test( thisURL ) ) {
    GUID = RegExp.$1;
  } 

  SaveRecipe( GUID, "MH");

}


function SaveRecipe(GUID, SRC)
{

  link = '<a href=http://www.projectfoodie.com/index2.php?option=com_pfrecipetracker&action=recipe&sourcename=';
  link += SRC;
  link += '&guid=';
  link += GUID;
  link += '>Save Recipe</a>';

  document.writeln(link); 

}
